PromQL: Your First PromQL Query
PromQL is the query language of Prometheus. One short query asks Prometheus a question and returns a list of matching series.
Ask whether targets are up
The simplest useful query asks Prometheus about target health.
upAsk for one counter
Naming a metric returns every series that carries that name.
http_requests_total{route="/",status="200"}Ask for a range of values
Square brackets ask for the last two minutes of values instead of one moment.
http_requests_total{route="/"}[2m]Example
curl -s -G "http://localhost:19102/api/v1/query" --data-urlencode 'query=up'Key points
- PromQL is the language you type into the expression browser to ask questions.
- A query names a metric, and Prometheus returns every series with that name.
- An instant vector is one value per series at one moment in time.
- A range vector is a set of values per series across a window of time.
- Square brackets turn an instant vector into a range vector, like [2m] for two minutes.
- The query up asks whether each scrape target is answering right now.
In this example, the query up returns three series, one per scrape target. Each one reads 1, so all three targets answer. The same query in the expression browser shows the same three rows in a table.
Note
A query with no filters returns every series, so start narrow and widen slowly.
Try it Yourself
Edit the code, then press Run.
Running is simulated · Rust Playground
Exercise
What does the query up return?