Recording rule for expensive ratio
precompute SLO error ratio to keep dashboards and alerts fast
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]))
- tool
- prometheus30 commands
More prometheus commands
-
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
-
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