prometheus commands
30 commands, each with a one-line explanation. Click a command to copy it, or its title for details.
Commands 30 shown
-
curl -sG 'http://prometheus:9090/api/v1/query' --data-urlencode 'query=up' | jq .Ad-hoc PromQL query from CLI
-
promtool query instant http://prometheus:9090 'up{job="kubelet"}'Run an instant PromQL query using promtool
-
curl -sG 'http://prometheus:9090/api/v1/query_range' --data-urlencode 'query=rate(http_requests_total[5m])' --data-urlencode 'start=2024-01-01T00:00:00Z' --data-urlencode 'end=2024-01-01T01:00:00Z' --data-urlencode 'step=60s' | jq .Query Prometheus for a time range via HTTP API
-
promtool check rules rules.ymlValidate Prometheus alert/recording rule files for syntax
-
amtool silence add --alertmanager.url=http://alertmanager:9093 alertname=<name> --duration=2h --comment='Maintenance'Create a silence to mute alert notifications during maintenance
-
amtool silence query --alertmanager.url=http://alertmanager:9093Show all active silences in Alertmanager
-
amtool silence expire <id> --alertmanager.url=http://alertmanager:9093Immediately end an active silence
-
amtool check-config alertmanager.ymlValidate Alertmanager configuration file
-
amtool alert query --alertmanager.url=http://alertmanager:9093Show all firing alerts in Alertmanager
-
curl -X POST http://prometheus:9090/-/reloadHot-reload Prometheus configuration without restart
-
curl -sG 'http://prometheus:9090/api/v1/query' --data-urlencode 'query=up' | jq '.data.result'Run an instant PromQL query via HTTP API
-
curl -sG 'http://prometheus:9090/api/v1/query_range' --data-urlencode 'query=rate(http_requests_total[5m])' --data-urlencode 'start=1h' --data-urlencode 'end=now' --data-urlencode 'step=60'Fetch time-series data over a range for a rate metric
-
topk(10, sum by (pod) (rate(container_cpu_usage_seconds_total[5m])))PromQL: top 10 pods by CPU usage rate
-
100 - (node_filesystem_avail_bytes{mountpoint="/"} / node_filesystem_size_bytes{mountpoint="/"} * 100) > 85PromQL expression: fire when root disk > 85% used
-
curl -X POST http://prometheus:9090/-/reloadHot reload Prometheus config and rules without restart
-
curl -s http://prometheus:9090/api/v1/alerts | jq '.data.alerts[] | select(.state=="firing") | {name: .labels.alertname, severity: .labels.severity}'Show only firing alerts with name and severity
-
curl -s http://prometheus:9090/api/v1/label/__name__/values | jq '.data | length, .[0:20]'Count total metric names and preview first 20
-
count by (job) ({__name__=~".+"})PromQL: count active time series grouped by job label
-
amtool silence add alertname=HighMemory --duration=2h --comment='Investigating'Create an Alertmanager silence for 2 hours
-
curl -s http://prometheus:9090/api/v1/status/tsdb | jq '{head_chunks: .data.headStats.numChunks, series: .data.headStats.numSeries}'View TSDB head stats: chunks and active series
-
histogram_quantile(0.95, sum by(le,job)(rate(http_request_duration_seconds_bucket[5m])))p95 latency per job; note: always aggregate _bucket by le before histogram_quantile
-
predict_linear(node_filesystem_avail_bytes{mountpoint="/"}[6h], 4*3600) < 0alert when linear trend predicts disk full within 4h based on last 6h
-
absent(up{job="node"} == 1)fires when no series match; catches a job that vanished from discovery entirely
-
label_replace(node_uname_info, "host", "$1", "nodename", "(.+)")extract/derive a new label via regex capture; useful for joins and tidy dashboards
-
max_over_time(rate(node_network_receive_bytes_total[5m])[1h:1m])subquery: peak 5m rate sampled each minute over the last hour; spot bursts
-
sum without(instance) (rate(http_requests_total{code=~"5.."}[5m]))without() keeps every label except instance; cleaner than listing many by() labels
-
groups: - name: slo rules: - record: job:request_errors:ratio5m expr: sum by(job)(rate(http_requests_total{code=~"5.."}[5m])) / sum by(job)(rate(http_requests_total[5m]))precompute SLO error ratio to keep dashboards and alerts fast
-
promtool check rules rules.yml && promtool check config prometheus.ymllint before reload; run in CI to catch broken expr/yaml before deploy
-
promtool query instant http://localhost:9090 'topk(5, sum by(pod)(rate(container_cpu_usage_seconds_total[5m])))'run PromQL without a browser; great for scripted top-N investigations
-
promtool tsdb analyze /prometheus --limit 20lists highest-cardinality metrics and label pairs; first stop for memory blowups
no commands match — try a different search