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
6curl 'http://HOST:9090/api/v1/targets'All scrape targets and health
curl 'http://HOST:9090/api/v1/query?query=up' | jqInstant 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
6kill -HUP PIDReload config if scrape intervals are unchanged
curl -X POST http://HOST:9090/-/reloadReload via HTTP (with --web.enable-lifecycle)
curl -X POST http://HOST:9090/-/quitGraceful shutdown
promtool check config prometheus.ymlValidate the config
promtool check rules rules.ymlValidate recording/alert rules
curl -s http://HOST:9090/-/readyReadiness probe
TSDB & Storage
6promtool 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
5scrape_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: 30sGlobal scrape cadence
relabel_configs: [{ source_labels: [__name__], regex: 'http.*', action: drop }]Keep or drop series at scrape