Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
56 lines (40 sloc) 2.04 KB

Expose Custom Metrics in Kyma

Overview

This example shows how to expose custom metrics to Prometheus with a Golang service in Kyma. To do so, follow these steps:

  1. Expose a sample application serving metrics on the 8081 port.
  2. Access the exposed metrics in Prometheus.

Prerequisites

  • Kyma as the target deployment environment.
  • A Namespace to which you deploy the example with the env: "true" label. For more information, read the related documentation.

Installation

Expose a sample metrics application

  1. Export your Namespace as a variable. Replace the {namespace} placeholder in the following command and run it:

    export KYMA_EXAMPLE_NS="{namespace}"
  2. Deploy the service:

    kubectl apply -f deployment/deployment.yaml -n $KYMA_EXAMPLE_NS
  3. Deploy the ServiceMonitor:

    kubectl apply -f deployment/service-monitor.yaml

Access the exposed metrics in Prometheus

  1. Run the port-forward command on the core-prometheus service:

    kubectl port-forward -n kyma-system svc/core-prometheus 9090:9090

All the sample-metrics endpoints appear as the Targets list.

  1. Use either cpu_temperature_celsius or hd_errors_total in the expression field here.
  2. Click the Execute button to check the values scrapped by Prometheus.

Cleanup

Run the following commands to completely remove the example and all its resources from the cluster:

  1. Remove ServiceMonitor in the kyma-system Namespace.
    kubectl delete servicemonitor -l example=monitoring-custom-metrics -n kyma-system
  2. Run the following command to completely remove the example service and all its resources from the cluster:
    kubectl delete all -l example=monitoring-custom-metrics -n $KYMA_EXAMPLE_NS