PromQL Query Builder

Visually build Prometheus queries with metric selection, label matchers, aggregation functions, rate/irate, and more. Runs entirely in your browser.

Templates:

Metric Name

Label Matchers

Function (Outer)

Aggregation

Offset Modifier

Generated PromQL Query

http_requests_total
Keyboard shortcuts: Ctrl+Shift+C Copy query • Ctrl+L Clear

PromQL Cheat Sheet

Request Rate

rate(http_requests_total[5m])

Per-second rate of HTTP requests over 5 minutes

Error Percentage

sum(rate(http_requests_total{status=~"5.."}[5m])) / sum(rate(http_requests_total[5m])) * 100

Percentage of 5xx responses

Latency P99

histogram_quantile(0.99, sum(rate(http_request_duration_seconds_bucket[5m])) by (le))

99th percentile request latency

CPU Usage %

100 - (avg by (instance) (rate(node_cpu_seconds_total{mode="idle"}[5m])) * 100)

CPU usage as a percentage per node

Memory Usage

node_memory_MemTotal_bytes - node_memory_MemAvailable_bytes

Used memory in bytes per node

Disk Usage %

(1 - node_filesystem_avail_bytes / node_filesystem_size_bytes) * 100

Filesystem usage percentage

Top 5 by Requests

topk(5, sum(rate(http_requests_total[5m])) by (handler))

Top 5 most-requested endpoints

Up/Down Targets

up == 0

All Prometheus targets that are currently down

Absent Alert

absent(up{job="myservice"})

Returns 1 if the metric is missing (for dead-man alerts)

Counter Resets

resets(http_requests_total[1h])

Number of counter resets in the last hour

Embed this tool

Add this PromQL Query Builder to your website:

<iframe src="https://devtoolbox.dedyn.io/tools/promql-builder" width="100%" height="700" frameborder="0"></iframe>

Frequently Asked Questions

What is PromQL and what is it used for?
PromQL (Prometheus Query Language) is the query language used by Prometheus to select and aggregate time-series data. It supports instant and range queries, aggregation operators like sum/avg/max, functions like rate and histogram_quantile, and label-based filtering. It is the foundation for building dashboards in Grafana and setting up alerting rules.
What is the difference between rate() and irate() in PromQL?
rate() calculates the per-second average rate of increase over the entire range vector window, making it smoother and better for alerting and slow-moving counters. irate() uses only the last two data points in the range to calculate an instant rate, making it more responsive to spikes but noisier. Use rate() for alerts and dashboards, and irate() when you need to see short-lived peaks.
How do I calculate the 99th percentile latency with PromQL?
Use the histogram_quantile function: histogram_quantile(0.99, sum(rate(http_request_duration_seconds_bucket[5m])) by (le)). This calculates the 99th percentile from a histogram metric. The 'le' label (less-than-or-equal) is required for histogram bucket boundaries. You can change 0.99 to 0.95 or 0.50 for other percentiles.
How do label matchers work in PromQL?
PromQL supports four label matching operators: = (exact match), != (not equal), =~ (regex match), and !~ (negative regex match). For example, http_requests_total{method="GET", status=~"2.."} selects HTTP GET requests with any 2xx status code. Label matchers filter which time series are included in the query results.