Monitor Kubernetes Cluster with Prometheus and Grafana
In this article I will demonstrate how to monitor kubernetes cluster resources with prometheus and grafana.
Let’s first give a bit intro about Prometheus and Grafana, So prometheus is an open source tool for monitoring targets like kubernetes resources, databases, virtual machines etc … It can be also configured with ALERTMANAGER to handle alerts or integrated with Grafana to visualise metrics and build dashboards based on it.
Prometheus uses promQL to query metrics in the below format:
METRIC{condition,anotherCondition}
Also Prometheus by design implements a pull-based approach for collecting metrics which makes it easy to enroll new targets dynamically through service discovery.
Grafana as mentioned is the GUI part of the monitoring system through which you can add “datasources” to bring other systems metrics, also you can import dashboards or create it from scratch.
Now let’s jump to the demo.
Kubernetes version in this demo will be 1.21.9
I’m assuming that you have your kubernetes cluster up and running and you have helm and kubectl installed also then you can proceed with the below steps.
Steps: