curl -s '<prometheus>:9090/api/v1/query?query=<PromQL>'
curl -s '<prometheus>:9090/api/v1/query?query=<PromQL>'
Risk: Safe
What it does
Runs a PromQL query through Prometheus's HTTP API and prints the answer as JSON.
When to use it
From scripts, or when you have no browser.
Example
$ curl -s 'localhost:9090/api/v1/query?query=up'An instant vector: one value per target, at this moment.
$ curl -s localhost:9090/api/v1/query --data-urlencode 'query=rate(prometheus_http_requests_total[1m])'Let curl encode the brackets and spaces for you.
Learn it in: Instant and range vectors · Official docs