NewWork mode: your Claude Code or Codex on work calls, answering from your project's codeSkip to content
Middle1 view

How does Prometheus work once it has started?

Practice

Asked at

AI answer

After startup, Prometheus loads its configuration and rules, opens its local TSDB, and starts operating as a monitoring server:

  1. Discovers targets for metric collection — using static configuration or service discovery. It applies relabeling to filter targets and configure their parameters.
  2. Collects metrics using the pull method — it periodically contacts targets’ HTTP endpoints, usually /metrics, and parses the returned data. Pushgateway is sometimes used for systems that cannot expose metrics directly.
  3. Stores time series — new values are written to the in-memory portion of the TSDB and the WAL; the data is then compacted into blocks on disk. The retention policy determines how long data is kept.
  4. Evaluates rules — it runs recording rules and alerting rules on a schedule. It sends firing alerts to Alertmanager, which handles grouping, routing, and notifications.
  5. Serves queries — PromQL queries arrive through the HTTP API or UI and are executed against the stored data.

If a target is unavailable, Prometheus does not receive a sample from it during that cycle and usually sets its up metric to 0.