Monitoring¶
Installation¶
We use the YAML files of the GitHub repository prometheus/prometheus and from giantswarm/prometheus for the installation of Prometheus modified for our use.
Install it:
kubectl apply -f install/kubernetes/monitoring
Prometheus¶
To open Prometheus dashboard, enter the following command:
kubectl port-forward -n monitoring $(kubectl get pods --namespace monitoring --selector="app=prometheus,component=core" --output=jsonpath="{.items..metadata.name}") 9090:9090
API¶
Prometheus HTTP API Documentation
Example 1:
curl -g 'http://localhost:9090/api/v1/query?query=container_cpu_load_average_10s{container_name="mico-core"}'
Example 2:
curl -g 'http://localhost:9090/api/v1/query?query=container_memory_working_set_bytes{pod_name="POD_NAME"}'
This query uses the metric container_memory_working_set_bytes that provides the memory usage. It is limited to the memory usage of the pod with a specified name.
Prometheus provides three different values for this request:
- total memory usage of a pod
- memory usage of a container running in the pod
- difference between total memory usage of the pod and the memory usage the containers
Example 3:
curl -g 'http://localhost:9090/api/v1/query?query=sum(container_memory_working_set_bytes{pod_name="POD_NAME",container_name=""})'
This query adds the requirement container_name="". This filters the three values from example 2. Only the total memory usage value of the pod has an empty container name (because it is a whole pod, not just the container inside). The sum function removes metadata provided together with the metric itself.