Query Language

To make use of the collected data, Prometheus implements its own query language called PromQL. PromQL is a functional language that is optimized for evaluating flexible and efficient computations on time series data. In contrast to SQL-like languages, PromQL is only used for reading data, not for inserting, updating, or deleting data (this happens outside of the query engine).

PromQL in the Prometheus architecture

You can learn everything about PromQL in our "Understanding PromQL" training, but we will look at some examples here.

The following selects the total count of all handled HTTP requests that resulted in a 500 status code:


The following gives you the per-second rate of increase for each series, as averaged over a window of 5 minutes:


And you can calculate the ratio of status="500" errors to the total rate of requests grouped by HTTP path like this:

  sum by(path) (rate(http_requests_total{status="500"}[5m]))
  sum by(path) (rate(http_requests_total[5m]))

These are some of the more common constructs you will see in PromQL, but the language has many more features and capabilities that you can learn about in our Understanding PromQL training.