Sub topic 2
How Prometheus, exporters, Alertmanager, and Grafana fit together
Assume you are comfortable with the Linux command line, systemd, YAML, TCP ports, HTTP, and basic server resources. This chapter uses those skills to explain how the monitoring components exchange data.
The monitoring path
Prometheus is a time-series database and monitoring server. It collects numeric measurements, called metrics, at regular intervals. A time series is one metric and its label values recorded over time.
Prometheus uses a pull model. Instead of waiting for servers to send data, Prometheus connects to an HTTP endpoint on each target and requests the current metrics. This makes the collection schedule and target list visible in one place.
An exporter is a small service that translates information from another system into Prometheus’s text format. The node_exporter service, for example, reads Linux information about CPU, memory, disks, and network devices. It usually listens on TCP port 9100.
Grafana is the visualization layer. It sends PromQL queries to Prometheus and displays the returned time series in panels, dashboards, and tables. Grafana does not normally collect or store the metrics itself.
Alertmanager handles notifications after Prometheus decides that an alert is active. It groups related alerts, suppresses duplicates, and routes messages to receivers such as email, chat, or a webhook.
What each component owns
| Component | Main responsibility | Typical connection |
|---|---|---|
| node_exporter | Exposes Linux host metrics | Prometheus pulls `server:9100` |
| Prometheus | Scrapes, stores, queries, and evaluates metrics | Scrapes exporters and serves PromQL |
| Grafana | Builds dashboards from query results | Queries Prometheus on port 9090 |
| Alertmanager | Groups and routes active alerts | Receives alerts from Prometheus on port 9093 |
Prometheus configuration defines scrape jobs. A scrape job names a group of targets and tells Prometheus how often to request their metrics. During a scrape, Prometheus also creates an up metric. The value is 1 when the target responded successfully and 0 when the scrape failed.
Prometheus evaluates alerting rules against its stored data. When a rule remains true for its configured duration, Prometheus sends an alert to Alertmanager. Alertmanager then applies routing and notification settings. A failed notification does not change the original metric data in Prometheus.
A request walkthrough
For a CPU panel, Grafana sends a PromQL query to Prometheus. Prometheus selects the matching CPU series and calculates a value from recent samples. Grafana renders that result as a graph.
At the same time, Prometheus may evaluate a rule that checks whether a target is down. If the condition lasts long enough, Alertmanager receives the alert and sends it to the configured receiver. The dashboard and the notification use the same underlying metric data, but each component has a different job.
Exercise
Which component should you inspect first if Prometheus shows up{job="node"} == 0 for a server?
Show answer
Inspect the node_exporter service, its listening port, network access, and the target address before investigating Grafana.