Les pubs vous déplaisent ? Aller Sans pub Auj.

PromQL Query Formatter & Validator

DonnéesPromoteur
ANNONCE · Supprimer ?

Ou
Function calls and binary operators wrap when a line would exceed this width.
Used as the `record:` field. Must follow Prometheus naming rules (a-z, 0-9, _, :).
ANNONCE · Supprimer ?

Guide

PromQL Query Formatter & Validator

Format and Validate Prometheus PromQL Queries Instantly

The PromQL Query Formatter & Validator tidies up the queries you write against Prometheus and other compatible time-series databases. Paste in a metric expression and the tool normalises spacing around binary operators, lays out aggregation, function calls and label matchers on their own lines when the query gets long, and points out unbalanced brackets, mismatched braces, missing durations and other syntactic problems before you ever paste the query into a dashboard or alerting rule. Everything runs locally in your browser, so the queries — which often expose internal metric names and labels — never leave your device.

Comment utiliser

  1. Paste your PromQL query into the input area, or upload a .promql or text file using the file picker.
  2. Pick an indent width — 2 spaces, 4 spaces, or a literal tab character — for any multi-line expansion.
  3. Set a maximum line length. Function calls, label matcher sets and low-precedence boolean operators (and, or, unless) wrap onto separate lines once the formatted line would exceed this width.
  4. Basculer Always break if you want every aggregation, function-call argument list and label matcher set on its own line regardless of length.
  5. Basculer Wrap as recording rule and supply a metric name (such as job:http_errors:rate5m) to emit the formatted query as a ready-to-paste Prometheus recording rule in YAML.
  6. Copy the formatted output or download it as a .promql fichier.

Caractéristiques

  • PromQL-aware spacing – Inserts a single space around arithmetic, comparison and boolean operators while keeping label matchers tight inside { } braces.
  • Smart multi-line layout – Breaks long queries at and / or / unless first, then at function argument boundaries, then at individual label matchers so the result remains easy to scan.
  • Aggregation and vector-matching support – Recognises sum, avg, topk, quantile and friends together with by, without, on, ignoring, group_left et group_right modifiers.
  • Duration and subquery tokeniser – Parses compound ranges like 1h30m and subqueries like [5m:1m] as single units so they are never split mid-token.
  • Validation de syntaxe – Detects unbalanced parentheses, brackets and braces, mismatched openers and closers, invalid label-matcher bodies, invalid subscript ranges and unterminated strings, each reported with a line number.
  • Recording rule export – Optionally wraps the formatted query as a Prometheus YAML recording rule block, using a YAML literal block scalar for multi-line expressions so indentation is preserved.

Cas d'utilisation courants

  • Cleaning up ad-hoc Prometheus queries copied from Grafana panel editors before committing them to dashboards or alert rules.
  • Preparing PromQL expressions for code review — long error-rate or saturation queries become readable diffs once each branch sits on its own line.
  • Catching subtle syntax mistakes (missing duration, stray comma, unclosed { after editing label matchers) without round-tripping through a live Prometheus instance.
  • Converting raw queries into Prometheus recording-rule YAML for pre-aggregation pipelines.
  • Teaching PromQL — the normalised output makes operator precedence and aggregation grouping immediately obvious to readers learning the language.

FAQ

  1. What is PromQL?

    PromQL (Prometheus Query Language) is the read-side query language used by the Prometheus monitoring system, and by compatible backends such as Thanos, Mimir, Cortex, VictoriaMetrics and Amazon Managed Service for Prometheus. It is purpose-built for time-series data: every expression evaluates to an instant vector, a range vector, a scalar or a string, and operators understand label-set matching, grouping and rate-over-time semantics that general-purpose SQL does not.

  2. What is the difference between an instant vector and a range vector?

    An instant vector is the set of time-series samples at a single point in time — for example, the latest value of every series matching http_requests_total. A range vector is the set of samples over a duration window, written with a bracketed duration like [5m]. Range vectors cannot be displayed directly; they are inputs to functions such as rate(), increase() and avg_over_time() that collapse the window back to an instant vector.

  3. How do `by` and `without` differ in aggregations?

    Both modify the grouping behaviour of aggregation operators like sum and avg. The by clause keeps only the listed labels in the output, so sum by (job) (rate(...)) collapses every label except job. The without clause keeps every label except the listed ones, so sum without (instance) (rate(...)) preserves every other dimension. Equivalent groupings can be written either way; teams usually pick one for consistency.

  4. What is a recording rule and why pre-compute one?

    A recording rule is a named PromQL expression that Prometheus evaluates on a schedule and writes back as a new metric. Pre-computing a complex expression — for instance, a 5-minute error rate by service — lets dashboards and alerts query the result directly instead of recomputing the whole expression on every refresh. The convention is to name recording rules with a level:metric:operation pattern such as job:http_requests_errors:rate5m so their meaning is obvious from the metric name alone.

  5. What do `on`, `ignoring`, `group_left` and `group_right` do?

    These keywords control how PromQL matches series across the two sides of a binary operation. By default Prometheus requires identical label sets on both sides; on(label, ...) and ignoring(label, ...) let you restrict or relax the join key. group_left and group_right turn the match into a one-to-many or many-to-one join, copying labels from the high-cardinality side onto the result. They are the equivalent of a SQL join hint for time-series data.

Envie d'une expérience sans pub ? Passez à la version sans pub

Installez nos extensions

Ajoutez des outils IO à votre navigateur préféré pour un accès instantané et une recherche plus rapide

Sur Extension Chrome Sur Extension de bord Sur Extension Firefox Sur Extension de l'opéra

Le Tableau de Bord Est Arrivé !

Tableau de Bord est une façon amusante de suivre vos jeux, toutes les données sont stockées dans votre navigateur. D'autres fonctionnalités arrivent bientôt !

ANNONCE · Supprimer ?
ANNONCE · Supprimer ?
ANNONCE · Supprimer ?

Coin des nouvelles avec points forts techniques

Impliquez-vous

Aidez-nous à continuer à fournir des outils gratuits et précieux

Offre-moi un café
ANNONCE · Supprimer ?