PromQL Builder & Validator
Compose Prometheus queries and alert rules entirely in your browser
About
Compose PromQL locally with rate, irate, increase, histogram_quantile, by/without grouping, offsets, and range selectors. Generate deterministic Prometheus alert rule YAML and catch unbalanced parentheses, unknown functions, and common rate mistakes without uploading data.
Examples
p95 latency from buckets
buildPromQL({ metric: "http_request_duration_seconds_bucket", fn: "rate", range: "5m", grouping: "by", groupLabels: ["le"], histogramQuantile: 0.95 })histogram_quantile(0.95, sum by (le) (rate(http_request_duration_seconds_bucket[5m])))Rate over 5m, summed by le, then histogram_quantile extracts the 95th percentile.
Offset comparison query
buildPromQL({ metric: "http_requests_total", fn: "rate", range: "5m", offset: "1h" })rate(http_requests_total[5m] offset 1h)The offset modifier compares current throughput against the same range one hour ago.
About this tool
PromQL Builder & Validator composes queries with buildPromQL(config): labels attach as {k="v"} with backslash/quote escaping, fn wraps the metric with an optional [range] and offset modifier, grouping wraps it as sum by/without (labels) (...), and histogramQuantile wraps the whole expression — the canonical histogram_quantile(0.95, sum by (le) (rate(metric[5m]))) falls out of one call.
Validation with validatePromQL(source) is a deterministic local lint: empty input fails, unbalanced opening/closing parens report as errors, unknown function names (anything outside rate/irate/increase/histogram_quantile/sum/avg/min/max/count/quantile/topk/bottomk) report Unknown function, range-less rate/irate/increase calls error, and counter-shaped rate calls add a warning. generateAlertRuleYaml then emits a sorted, single-quoted groups/rules document.
Grouping modifiers differ semantically — sum by (job) keeps only job while sum without (job) drops only job — and offset shifts the evaluation instant (e.g. offset 1h). Duration helpers accept ms/s/m/h/d/w/y compounds via isPromQLDuration; nothing is sent anywhere, so queries stay in the browser.
How to use this tool
Pick the metric and range function
Enter the metric name, add label matchers, then wrap with rate/irate/increase plus a range like 5m — offsets like 1h shift the instant.
Aggregate and quantize
Choose sum by or sum without with group labels, and set histogramQuantile 0.95 on _bucket metrics for latency percentiles.
Validate, then export the alert
Run the validator to catch parens, unknown functions, and missing ranges, then generate the alert-rule YAML for Prometheus.
Use cases
Building latency SLO queries
Compose histogram_quantile percentiles over bucket metrics for p50/p95/p99 dashboards and alerts.
Linting pasted PromQL
Catch unbalanced parens, misspelled functions, and range-less rate calls before saving rules.
Scaffolding alert rules
Turn validated expressions into quoted Prometheus group YAML with for/labels/annotations intact.
Common mistakes
Mistake:Calling rate without a range vector.
Fix:rate(up) errors with rate, irate, and increase need a range vector — write rate(up[5m]) instead.
Mistake:Confusing by with without.
Fix:sum by (job) keeps only job; sum without (job) keeps everything except job — swapping them inverts the aggregation.
Mistake:Assuming unknown functions warn only.
Fix:frobnicate(up) is an error-severity Unknown function finding that flips valid to false — fix the name before deploying.
Frequently asked questions
What does this tool do?
It composes PromQL with buildPromQL (labels, range function, offset, by/without aggregation, histogram_quantile), lints with validatePromQL (empty, parens, unknown functions, missing ranges), and exports alert YAML with generateAlertRuleYaml.
What is the canonical histogram query, and how do by/without differ?
histogram_quantile(0.95, sum by (le) (rate(http_request_duration_seconds_bucket[5m]))). sum by (job) keeps only job; sum without (job) keeps everything except job — swapping them inverts the aggregation.
Is my query uploaded or stored?
No. Building, validation, and YAML export are 100% client-side — metrics and expressions never leave your browser.
What fails validation?
Empty queries, unbalanced parens, unknown functions like frobnicate (error severity), and range-less rate/irate/increase calls such as rate(up). Counter-shaped rate calls add a warning to verify the metric type.
Related guides
References & standards
Related tools
.env Secret Safety Linter
Validate .env syntax and spot likely leaked credentials or placeholder secrets.
.htaccess Generator
Build an Apache .htaccess — HTTPS redirects, rewrites, error pages, security headers, and basic auth
2D Fluid Dynamics & Particle Physics Sandbox
A physics playground with two engines sharing one canvas. The fluid mode runs a real Eulerian Navier-Stokes solver — semi-Lagrangian advection, explicit diffusion, Jacobi pressure projection and vorticity confinement — that you paint with dye and velocity using mouse or touch. The particle mode is a damped Verlet N-body engine with gravity wells, Coulomb attractors and repulsors, spring links, wall restitution and elastic circle collisions. Particle counts adapt to the device (100k target on WebGL2 desktop, 2k-5k on CPU fallback), and every configuration exports as runnable code: a Matter.js world, a PixiJS ticker setup, or a standalone vanilla Canvas engine.
AI Function Calling Schema Generator
Generate function calling JSON schemas from TypeScript interfaces
Algorithm Arena & Data Structure Visualizer
Interactive arena for algorithms and data structures: eight sorting algorithms racing on one seeded input, six pathfinding algorithms walking generated mazes, and BST, AVL, Red-Black, B-tree, heap and trie operations replayed step by step with rotations highlighted. Every run shows the Big-O table and the phase-highlighted reference implementation in four languages, and compared values can be played as pitch (sonification) through the shared audio engine. Everything runs client-side; inputs never leave the browser.
Ansible Playbook Generator
Build an Ansible playbook — hosts, vars, and tasks with modules — as YAML