liveBook · Manning

PromQL

As explained in Cloud Observability in Action

PromQL is the query language used to select, aggregate, and calculate time-series data in Prometheus.

PromQL is Prometheus’s query language for selecting, aggregating, and calculating time-series metrics. It supports operational analysis, Grafana visualizations, and alert conditions. section 2.4.2 section 7.2.1

A common pattern calculates an HTTP error rate by dividing the five-minute rate of status-code-500 requests by the five-minute rate of all requests, then multiplying by 100. section 2.4.2

PromQL supports several practical workflows:

  • Filter metric series with label matchers, such as selecting a particular HTTP status code or handler. section 6.1.1
  • Aggregate and transform series with functions such as rate and sum for service-level measurements. section 2.4.2
  • Parameterize Grafana dashboards with variables so users can choose label values, including HTTP status codes and handlers. section 6.1.1
  • Define alert expressions that Prometheus evaluates periodically before handing firing alerts to Alertmanager. section 7.2.1

Service error-rate query

sum (rate(echo_total{http_status_code="500"}[5m])) / sum (rate(echo_total[5m])) * 100 produces the percentage of recent requests returning HTTP 500. The same metric can be explored in Grafana through a Prometheus data source.

Parameterized dashboard query

rate(prometheus_http_requests_total{code="$test"}[5m]) lets a Grafana dashboard variable choose the HTTP status code. Selecting a label value that does not exist can leave the panel empty. section 6.1.1

How Cloud Observability in Action covers it

How deep it goes
Explains label filtering, rates, aggregation, parameterization, and periodic alert evaluation through concrete queries and configurations.
Examples
Uses service error rates, HTTP status filters, handler variables, missing targets, and excessive API-call alerts.
What it assumes
Assumes metrics, labels, Prometheus data sources, and Grafana dashboards; teaches label filtering, rates, and alert expressions.
What you can do after
Apply it via Prometheus and Grafana to calculate service rates, parameterize dashboards, and define alert conditions.
How it connects
Connects Prometheus metrics with Grafana dashboards, dashboard variables, and Alertmanager notification workflows.

Also explained in

Compare how 4 books explain PromQL →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Cloud Observability in Action. The section links point to the parts of the book it draws on.