In many DevOps teams, especially those running Kubernetes, monitoring means Prometheus and Grafana. Prometheus collects and stores metrics; Grafana displays them on dashboards. Both are open source and appear in many job descriptions.
How Prometheus works
- Applications and servers expose metrics on an HTTP endpoint, usually
/metrics. - Prometheus scrapes (pulls) those endpoints every few seconds and stores the values as time series.
- Exporters expose metrics for things that do not do it themselves: Node Exporter for server CPU, memory and disk; exporters for MySQL, Nginx and more.
Metric types
- Counter: only goes up, such as total requests.
- Gauge: goes up and down, such as memory in use.
- Histogram: distributions, such as request duration, used for percentiles.
A first PromQL query
rate(http_requests_total[5m]) shows requests per second over the last five minutes. Counters are almost always wrapped in rate(), because the raw total only ever climbs. Add labels to filter: rate(http_requests_total{status="500"}[5m]) shows the server error rate.
Grafana dashboards
Connect Grafana to Prometheus as a data source, then build panels from PromQL queries. Ready-made community dashboards, such as the Node Exporter dashboard, give you a useful view in minutes. A good service dashboard shows the four “golden signals”: traffic, errors, latency and saturation.
Alerting
Prometheus alerting rules, routed through Alertmanager, notify the team when, for example, the error rate stays above a threshold for five minutes. Alert on symptoms users feel, not on every small spike.
A practice lab
Run Prometheus, Node Exporter and Grafana with Docker Compose on your laptop, import a Node Exporter dashboard, and create one alert for high CPU. It makes a strong DevOps portfolio item.
Related: AWS CloudWatch basics, Kubernetes for beginners and Docker Compose.
Hands-on labs like this are part of our AWS and DevOps course in Bangalore.
Book a free demo class at our BTM Layout centre, and ask a counsellor for batch details.
