PromQL Query Builder & Explainer

PromQL Query Builder & Explainer

Build Prometheus queries, explore common PromQL examples, explain query components, and review syntax diagnostics and common pitfalls in one browser-based workspace.

Local Browser Engine

Build, explain and troubleshoot PromQL

Browser-based PromQL workspace

Generate queries from common building blocks, explore templates, inspect explanations and review static diagnostics before using a query in Prometheus.

Build a query

Compose metric selectors, label filters, range functions, and aggregations.

Structured inputs
Time series identifier

Use a metric that exists in your Prometheus environment (e.g., http_requests_total, node_cpu_seconds_total).

2. Label matchers

Filter series by exact match (=, !=) or regex (=~, !~).

Comma-separated label names.

Start from a common query

Load curated PromQL patterns for HTTP traffic, node resources, targets, and SLOs.

No templates match that search.

Explain any PromQL expression

Edit the query on the right. The explanation and static checks update from the current expression.

Expression Summary

Component Breakdown

Static diagnostics

Generate an alert-rule draft

Creates a YAML rule draft for a common HTTP 5xx error ratio. Review the metric labels, expression and threshold before deployment.

0.05 means 5% error rate.

PromQL editor

Syntax highlighting, autocomplete and parser diagnostics

No live server connection

Parser diagnostics validate syntax only. They cannot confirm that a metric or label exists, that the query returns data, or that it is efficient for your environment.

Query review

✓

Syntax feedback

Use the editor's parser diagnostics to spot malformed expressions before testing them against Prometheus.

!

Rule-based warnings

Heuristics highlight common pitfalls, but a warning is not always an error and an empty warning list does not guarantee correctness.

⌘

Copy and adapt

Copy a query into Prometheus or Grafana and validate it with your actual metric names, labels, scrape interval and data.

i

Important: This workspace builds and reviews PromQL locally in your browser. It does not connect to your Prometheus server, inspect your metrics, execute queries or guarantee alert correctness. Always validate generated expressions against your own instrumentation and Prometheus version.

⚡

Fast to use

Designed to help you complete the task without unnecessary steps.

◇

Works in your browser

No separate desktop software is needed for this online tool.

✓

Simple workflow

Enter your information, use the tool and work with the result.

What Is a PromQL Query Builder?

A PromQL query builder is a tool for creating expressions in Prometheus Query Language, the query language used to select and calculate values from Prometheus time-series metrics. It can help developers construct metric selectors, label matchers, range functions and aggregations without assembling every expression from memory.

AabiTech combines a visual query builder with a PromQL editor, reusable examples, a query explainer and selected rule-based diagnostics. It is intended as a practical companion to Prometheus documentation and your monitoring environment, not a replacement for testing queries against real data.

How to Build a PromQL Query

  1. Enter a metric name that is available in your Prometheus server.
  2. Add label matchers such as job="api" or status=~"5.." to select the relevant series.
  3. Choose a range function such as rate() when working with a counter over a time window.
  4. Select an aggregation such as sum and specify grouping labels when needed.
  5. Review the generated PromQL, read its explanation and check parser diagnostics.
  6. Run the query in your own Prometheus or Grafana environment and verify the returned series.

Metric names, labels and suitable range windows depend on your instrumentation, scrape interval and monitoring goal.

Explain a PromQL Query in Plain English

The explainer identifies recognized metric selectors, functions, aggregation patterns and range windows, then describes their usual purpose in plain language. This is useful when reviewing a query written by a teammate, learning PromQL syntax or understanding a monitoring dashboard.

Explanations are static and pattern-based. Complex nested expressions, experimental functions, newer language features and environment-specific semantics may not be described completely. A readable explanation does not prove that a query is valid for your metric data or produces the intended result.

PromQL Syntax Validation and Common Pitfalls

The editor integrates a PromQL language extension for syntax highlighting, autocomplete and parser diagnostics. Additional static checks flag selected patterns, including potentially incorrect rate/aggregation order, classic histogram queries that may not preserve the le label, broad regular-expression matchers and example metric names.

Static checks are advisory. Some flagged patterns may be intentional, and a query with no warnings can still be incorrect, expensive or incompatible with the labels in your environment. For definitive validation, use a Prometheus server with the same version and relevant data as production.

Using rate(), increase() and irate()

rate() estimates the per-second average rate of increase of a counter over a range and is commonly used for request rates. increase() estimates the total increase over a range. irate() calculates an instant rate from the last two samples and can be more volatile.

For counters, apply rate() or increase() to each series before aggregating so counter resets can be handled per series. Choose a range that provides enough samples for your scrape interval and desired responsiveness.

PromQL Aggregation and Grouping Labels

Aggregators such as sum, avg, min, max and count combine values across input series. The by(...) modifier retains the specified label dimensions, while without(...) aggregates while excluding the named labels.

Choose grouping labels based on the question you need to answer. Grouping by high-cardinality labels can produce many output series, while removing important dimensions may hide differences between services, instances or endpoints.

PromQL Histogram Quantile Queries

For classic Prometheus histograms, histogram_quantile() commonly operates on bucket rates while preserving the le bucket label. A typical p95 pattern is histogram_quantile(0.95, sum by (le, job) (rate(http_request_duration_seconds_bucket[5m]))).

Replace the example metric and grouping labels with the ones your application exposes. Native histograms have different query considerations, so do not assume that every histogram metric uses classic bucket series.

Prometheus Query Examples and Templates

The template library includes common patterns for HTTP request rates, 5xx error ratios, histogram latency percentiles, CPU and memory utilization, filesystem usage, unavailable scrape targets, Kubernetes container restarts, firing alerts and top-valued series.

Templates are starting points, not universal drop-in queries. For example, an HTTP error query assumes an appropriate status label, while Node Exporter and Kubernetes examples assume their respective exporters and metric names are present. Adapt selectors and exclusions to your own environment.

Generate Prometheus Alert Rule YAML

The alert helper generates a draft YAML rule for a common HTTP 5xx error-ratio scenario. You can set the alert name, metric, threshold, evaluation window, grouping labels and description, then copy the draft for review.

The output is a template and is not automatically validated against your metric schema, Prometheus version or alerting policy. Confirm that the status label and counter semantics are correct, test the expression, validate the YAML and review the alert's behavior before deploying it.

Vector Matching, Labels and Query Results

PromQL binary operations between instant vectors match series using their labels unless modifiers such as on(...), ignoring(...), group_left or group_right change the matching behavior. Unexpected label sets can lead to empty results or many-to-many matching errors.

A static browser tool cannot inspect your actual label sets. When a query returns no data or a vector-matching error, compare the labels on both sides of the expression in Prometheus, then adjust the matching modifiers only when the intended relationship is clear.

Browser Processing, Privacy and Limitations

The builder, static explanations and local diagnostics operate in the browser. The tool does not need a Prometheus connection to construct a query and does not execute the expression against a monitoring server.

The PromQL editor's core language features are configured for offline use; remote metric autocomplete is not enabled. As with any website, normal page requests and hosting infrastructure may process standard connection data. Do not paste credentials, tokens or confidential query information into any online tool unless you are comfortable with the site's applicable privacy terms.

Troubleshooting Common PromQL Problems

  • No data: verify the metric name, label values, time range and scrape status.
  • Unexpected aggregation: review by and without labels and check whether important dimensions were removed.
  • Counter rate looks wrong: apply rate() before aggregation and use a suitable range window.
  • Histogram percentile is incorrect: check the metric type and preserve le for classic histograms.
  • Many-to-many matching error: inspect the labels on both sides of a binary vector operation.
  • Slow query: narrow selectors where possible and review range duration, series cardinality and aggregation choices.

These checks guide investigation; the actual cause must be confirmed against the target Prometheus environment.

Questions & answers

Frequently Asked Questions

What is PromQL?
PromQL is Prometheus Query Language, used to select, transform and aggregate time-series metrics stored in Prometheus.
Can I build PromQL queries without knowing the syntax?
Yes. Use the visual builder to select a metric, label matchers, range function, time window and aggregation. Review the generated expression before using it.
Can this tool explain an existing PromQL query?
Yes. Paste or edit an expression in the editor and open Explain & lint. The built-in explainer describes recognized selectors, functions, aggregations and range windows; complex expressions may need manual review.
Does the tool validate PromQL syntax?
The integrated PromQL editor provides syntax highlighting, autocomplete and parser diagnostics. You should still test the expression against the Prometheus version used in your environment.
Does the query builder connect to my Prometheus server?
No. The current tool builds and reviews expressions in the browser but does not execute queries, inspect live metrics or retrieve remote metric metadata.
Why does a valid PromQL query return no data?
The metric may not exist, labels may not match, the selected time range may contain no samples, or the target may not be scraped. Run the query in your own Prometheus UI and inspect the available series.
What is the difference between rate() and increase()?
rate() estimates a counter’s average per-second increase over a range, while increase() estimates the total increase over that range. Both account for counter resets and extrapolate to range boundaries.
When should I use irate() instead of rate()?
irate() calculates a rate from the last two samples in the range and can be useful for highly volatile counters, but it is noisier. rate() is generally preferred for alerting and stable trends.
Why should rate() usually come before sum()?
Applying rate() to each counter series first allows Prometheus to detect resets per series. Aggregating counters first can hide resets and produce misleading rates.
How do I write a p95 latency query in PromQL?
For a classic histogram, a common pattern is histogram_quantile(0.95, sum by (le, job) (rate(http_request_duration_seconds_bucket[5m]))). Replace the example metric and grouping labels with those used by your instrumentation.
What does the le label mean in histogram queries?
In classic Prometheus histograms, le identifies the upper bound of a bucket. It is normally retained during aggregation for histogram_quantile() to calculate a quantile.
What does sum by (job) do?
It aggregates input series while retaining separate output groups for each job label value. Other labels are not retained unless included in the grouping.
What causes a many-to-many matching error?
A binary operation between vectors has matching label sets that do not satisfy the required one-to-one or explicitly allowed many-to-one relationship. Inspect both sides and use matching modifiers only when the relationship is appropriate.
Can I generate Prometheus alert rules?
Yes. The alert helper generates a draft YAML rule for a common HTTP 5xx error ratio. Review metric names, label assumptions, threshold, duration and YAML compatibility before deploying it.
Are the query templates guaranteed to work in my environment?
No. Templates assume common exporter metrics and label conventions. Replace example metrics and labels and verify the result against your own instrumentation.
Does the tool send my queries to an AI service?
No AI service is required for the builder, built-in explanations or rule-based checks. The current tool does not execute queries against a remote Prometheus server.
Can this tool tell me whether a metric exists?
No. The current tool does not connect to your Prometheus server or retrieve metric metadata. Check the metric in your Prometheus UI or query API.
How do I make a PromQL query faster?
Use selectors that narrow the relevant series, avoid unnecessary high-cardinality grouping, choose reasonable range windows and inspect query cost in your Prometheus environment. The tool cannot benchmark your live query.
Is PromQL the same as SQL?
No. SQL is primarily used for relational data, while PromQL evaluates time-series metrics and supports instant vectors, range vectors, label matching, time windows and vector operations.
Can beginners learn PromQL with this tool?
Yes. Start from a template, change one component at a time, read the explanation and compare the output with Prometheus documentation. Validate examples against real data to understand their behavior.

Explore more AabiTech tools

Browse the complete collection of practical online tools for development, text, design, calculations and everyday digital work.