Prometheus Cheat Sheet

Operate a Prometheus server — targets, rules, storage, and the TSDB lifecycle that keeps metrics humming.

Observability4 sections · 23 commands
⌘K

HTTP API

6
curl 'http://HOST:9090/api/v1/targets'

All scrape targets and health

curl 'http://HOST:9090/api/v1/query?query=up' | jq

Instant query

curl -G 'http://HOST:9090/api/v1/query_range' --data-urlencode 'query=rate(http_requests_total[5m])' --data-urlencode 'start=...' --data-urlencode 'end=...' --data-urlencode 'step=60'

Range query

curl 'http://HOST:9090/api/v1/status/config'

Effective config

curl 'http://HOST:9090/api/v1/status/flags'

Run flags

curl 'http://HOST:9090/api/v1/series?match[]=up'

Discover series

Reload & Operations

6
kill -HUP PID

Reload config if scrape intervals are unchanged

curl -X POST http://HOST:9090/-/reload

Reload via HTTP (with --web.enable-lifecycle)

curl -X POST http://HOST:9090/-/quit

Graceful shutdown

promtool check config prometheus.yml

Validate the config

promtool check rules rules.yml

Validate recording/alert rules

curl -s http://HOST:9090/-/ready

Readiness probe

TSDB & Storage

6
promtool tsdb list tsdb/

Block list on disk

promtool tsdb analyze tsdb/

Highest-cardinality series

promtool tsdb stats tsdb/

Series and samples per block

curl 'http://HOST:9090/api/v1/status/tsdb'

Head block and compaction info

promtool tsdb clean tombstones tsdb/

Drop tombstones after deletes

curl 'http://HOST:9090/federate?match[]=up'

Federation endpoint

Service Discovery & Exporters

5
scrape_configs: [{ job_name: 'node', static_configs: [targets: ['1.2.3.4:9100']] }]

Static scrape target

scrape_configs: [{ job_name: 'k8s', kubernetes_sd_configs: [{ role: pod }] }]

Discover pods from k8s

scrape_configs: [{ job_name: 'e2', ec2_sd_configs: [{ region: us-east-1 }] }]

Discover EC2 instances

scrape_interval: 30s

Global scrape cadence

relabel_configs: [{ source_labels: [__name__], regex: 'http.*', action: drop }]

Keep or drop series at scrape