Run an instant query from the CLI

Run PromQL without a browser, handy for top-N checks in scripts

promtool query instant http://localhost:9090 'topk(5, sum by(pod)(rate(container_cpu_usage_seconds_total[5m])))'

tool
prometheus30 commands
tags
prometheusdebugtroubleshootingperformance

More prometheus commands

  • promtool tsdb analyze /prometheus --limit 20

    List metrics and label pairs with the highest cardinality, the first thing to check when memory grows

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

    Run a quick PromQL query from the command line

  • promtool query instant http://prometheus:9090 'up{job="kubelet"}'

    Run an instant PromQL query with 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 .

    Get Prometheus data for a time range through the HTTP API

  • promtool check rules rules.yml

    Check the syntax of Prometheus alerting and recording rule files

all 30 prometheus commands