Agent Wranglers

STK-63Default Open source

Use Prometheus for metrics

Store and query numeric metrics with Prometheus, and alert on them with its rules and Alertmanager.

Review by

2027-07-31

How to do it

Prometheus reached 1.0 in July 2016 and is under Apache-2.0. Version 3.13 is a long-term support release, supported until 31 July 2027, and 3.13.5, a security release, came out on 21 October 2026. Its image prom/prometheus has about 2 billion pulls on Docker Hub. The client prometheus-client has about 37 million weekly PyPI downloads. The npm client prom-client has about 5.7 million weekly downloads, but its last release was in June 2024. In JavaScript, export metrics through OpenTelemetry instead. Its text format and PromQL are known to every AI tool. Which metrics to record is in Measure rate, errors and duration. Write the alert rules as Alert on symptoms says. Choose something else when you keep metrics for more than a year across many servers, and add long-term storage such as Grafana Mimir.

Examples

YAML example

# prometheus.yml
scrape_configs:
  - job_name: orders-api
    scrape_interval: 15s
    static_configs:
      - targets: ['orders.internal.example.com:9464']

Python example

from prometheus_client import Counter, start_http_server

ORDERS = Counter("orders_total", "Orders placed", ["status"])

start_http_server(9464)
ORDERS.labels(status="paid").inc()

How to check

Every service has a /metrics endpoint or pushes OTLP metrics. The Prometheus targets page shows 0 targets down, and promtool check rules passes in the build.

Sources

For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/stack/operations-tools/prometheus">Agent Wranglers software choices playbook</a>. In code you write, add a comment next to it with the same link.