Aggregate keeping all labels but instance

without() keeps every label except instance; cleaner than listing many by() labels

sum without(instance) (rate(http_requests_total{code=~"5.."}[5m]))

tool
prometheus30 commands
tags
prometheusobservabilitymonitoring

More prometheus commands

  • 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.yml

    lint 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 20

    lists highest-cardinality metrics and label pairs; first stop for memory blowups

  • curl -sG 'http://prometheus:9090/api/v1/query' --data-urlencode 'query=up' | jq .

    Ad-hoc PromQL query from CLI

all 30 prometheus commands