In cloud-native environments, monitoring the health, performance, and security of your applications is critical. This is especially true when extending SAP solutions using microservices and serverless functions deployed on Kubernetes. SAP Kyma, a Kubernetes-based runtime, comes with built-in observability features, enabling developers and operators to implement effective metrics collection and logging for their applications.
This article covers how to implement and leverage metrics and logging within SAP Kyma to ensure visibility, diagnose issues, and optimize the performance of your cloud-native extensions.
When building extensions on SAP Kyma, you run multiple microservices and functions that communicate asynchronously. Metrics and logs provide the insight needed to:
SAP Kyma simplifies these tasks by integrating industry-standard tools natively into its platform.
SAP Kyma bundles several open-source tools to deliver observability out of the box:
| Component | Purpose |
|---|---|
| Prometheus | Metrics collection and storage |
| Grafana | Visualization dashboards |
| Loki | Log aggregation and querying |
| Jaeger | Distributed tracing |
These tools integrate seamlessly, providing a holistic view of your Kubernetes workloads.
Prometheus scrapes metrics from instrumented applications and Kubernetes components.
/metrics).You can use client libraries to add custom metrics:
prom-clientMicrometer or Prometheus Java Clientprometheus_clientExample (Node.js):
const client = require('prom-client');
const express = require('express');
const app = express();
const counter = new client.Counter({
name: 'myapp_requests_total',
help: 'Total number of requests'
});
app.get('/api/data', (req, res) => {
counter.inc();
res.send('Hello Kyma!');
});
app.get('/metrics', (req, res) => {
res.set('Content-Type', client.register.contentType);
res.end(client.register.metrics());
});
app.listen(3000);
Make sure your deployment exposes the /metrics endpoint and allows Prometheus to scrape it.
Kyma uses Grafana Loki for log aggregation, designed to be cost-effective and scalable.
Example Loki query:
{app="kyma-api"} |= "error"
Kyma ships with pre-configured Grafana dashboards:
You can create custom dashboards to monitor business-specific KPIs or infrastructure metrics.
Using Jaeger, Kyma supports tracing requests across multiple microservices:
Consider a custom Node.js microservice deployed in Kyma:
SAP Kyma's integrated observability stack empowers you to implement robust metrics and logging strategies essential for managing cloud-native SAP extensions. By leveraging Prometheus, Grafana, Loki, and Jaeger, you gain deep insights into your applications' behavior, enabling improved reliability, performance, and maintainability.
Implementing metrics and logging in Kyma is not just a technical necessity but a best practice that enhances your SAP cloud landscape’s agility and resilience.