After completing this lesson, you will be able to monitor extensions with custom metrics in Kyma
Monitor Extensions with Custom Metrics in Kyma
Business Scenario
After deploying your microservice-based application to Kyma, you want to monitor it continuously with Kyma's observability capabilities.
Exercise Options
You can perform this exercise in two ways:
Platform Simulation – follow the step-by-step instructions within the simulation.
Live Environment - by using the instructions provided below, you can perform the steps in the SAP BTP Free Tier account.
Note
We strongly recommend first performing the steps in the live environment.
Platform Simulation
Choose the Start Exercise button below to open a simulation of the platform. Then follow the step-by-step instructions to monitor extensions with custom metrics in Kyma.
In this exercise, you will perform the following steps:
Create a deployment and service for a sample application that exposes a metrics endpoint.
Configure Prometheus to scrape the metrics endpoint and use Prometheus UI to query the metrics.
Use Grafana to visualize metrics.
Prerequisites
You have successfully created a SAP BTP, Kyma runtime instance in the SAP BTP subaccount.
You have configured kubectl to work with your SAP BTP, Kyma runtime instance.
Task 1: Create a deployment and service for a sample application
Steps
Create a deployment and service for a sample application that exposes a metrics endpoint.
In this task, you will create a new hello-kyma deployment and service in a new namespace called monitoring-exercise. The deployment will use the ghcr.io/sap-samples/kyma-runtime-learning-journey/hello-kyma:1.0.0 image, which exposes a metrics endpoint on port 8080.
Create a new namespace called monitoring-exercise:
Code Snippet
1
kubectl create namespace monitoring-exercise
Create a new deployment called hello-kyma in the monitoring-exercise namespace:
Leave this terminal window open and open http://localhost:8080/metrics in a new browser tab. You should see a lot of metrics being exposed by the hello-kyma application.
Stop the port-forwarding by pressing Ctrl+C in the terminal window.
Result
Bravo! You have completed this exercise: you have used Kyma's observability capabilities to monitor your extensions and custom metrics with Prometheus and Grafana.
Task 2: Configure Prometheus to scrape the metrics endpoint and use Prometheus UI to query the metrics
Steps
Create a deployment and service for a sample application that exposes a metrics endpoint.
In this task, you will create a new hello-kyma deployment and service in a new namespace called monitoring-exercise. The deployment will use the ghcr.io/sap-samples/kyma-runtime-learning-journey/hello-kyma:1.0.0 image, which exposes a metrics endpoint on port 8080.
Create a new namespace called monitoring-exercise:
Code Snippet
1
kubectl create namespace monitoring-exercise
Create a new deployment called hello-kyma in the monitoring-exercise namespace:
Leave this terminal window open and open http://localhost:8080/metrics in a new browser tab. You should see a lot of metrics being exposed by the hello-kyma application.
Stop the port-forwarding by pressing Ctrl+C in the terminal window.
Configure Prometheus to scrape the metrics endpoint and use Prometheus UI to query the metrics.
Create a ServiceMonitor resource for the hello-kyma service:
In a new file called hello-kyma-servicemonitor.yaml, add the following content:
Bravo! You have completed this exercise: you have used Kyma's observability capabilities to monitor your extensions and custom metrics with Prometheus and Grafana.