OnCallReady

Commands

promtool - Tooling for the Prometheus monitoring system

promtool check config|rules|metrics ...
promtool test rules <test.yml>...
promtool query instant|range <server> <expr>

Options you will use

check config <file>...
Validate prometheus.yml and every rule file it references. Exit 1 on error. Warns about missing file_sd files.
check rules <file>...
Validate rule files: YAML, field names, every expr parses, recording rule names are valid metric names.
check metrics
Lint exposition text read from stdin: counters without _total, missing HELP, non-base units. Exit 3 on problems.
test rules <file>...
Unit-test rules against synthetic series (input_series, alert_rule_test, promql_expr_test). Only FIRING alerts are compared; labels and annotations must match exactly.
query instant <server> <expr>
Run an instant query. --time=<rfc3339|unix> to evaluate in the past.
query range <server> <expr>
Run a range query. --start, --end, --step.
query labels <server> <name>
List values of a label.

Examples

$ promtool check config /etc/prometheus/prometheus.yml

the first thing to run after any edit, before reloading

$ promtool query instant http://localhost:9090 'sum by (job) (up)'

query from the shell

$ promtool test rules slo_test.yml

prove an alert fires, without waiting for an outage

$ curl -s localhost:9100/metrics | promtool check metrics

lint what an exporter exposes

Gotchas

Taught in

Try promtool in a real terminal Free, in your browser - a real Ubuntu terminal to try it in, with missions that check your work.