METRICS / Grafana Labs
PromQL query patterns
PromQL skill that puts rate before aggregation, keeps the le label inside histogram_quantile, and guards a zero denominator.
“Write, validate, and optimize PromQL for Prometheus / Grafana Mimir / Grafana Cloud Metrics. Covers rate vs irate vs increase, label matchers and regex, sum / avg / topk / by / without aggregation, classic + native histogram_quantile, ratios with divide-by-zero guards, absent / changes for staleness, time offsets and predict_linear, recording-rule naming, SLO + burn-rate math, and a cardinality-hunting playbook. …”
01 / THE REASONING
Why this made the selection.
- The primary file shows rate before sum, histogram_quantile with by (le, service), a comparison that drops zero denominators, and a recording-rule replacement checked against the Prometheus query API.
- references/patterns.md at this commit was read: irate is limited to spike detection, recording-rule names use aggregation level, metric, and operation, and the burn-rate snippet divides by (1 - 0.999) as a placeholder target.
02 / THE REVIEW RECORD
What we actually inspected.
Source review has boundaries.
A clear record is more useful than a “safe” badge.
Material inspected
- skills/grafana-core/promql/SKILL.md
- skills/grafana-core/promql/references/patterns.md
- LICENSE at the same commit
- vercel-labs/skills@48dc9e8eb8aa19040e91cb90ba0b642c9cbad57e:README.md
- LICENSE
Our findings
- The Apache appendix at this commit says Copyright 2026 Grafana Labs.
- The common failure modes, including a dropped le label and aggregation before rate, are written in the primary file and repeated with examples in patterns.md.
- The definition separately checks API status, result count, metric existence and magnitude, then requires a recording rule to match the source expression.
- The error-rate ratio divides only by a sum that has been compared with greater-than zero.
- The query validation workflow goes beyond successful parsing and nonempty results by comparing magnitude with a known ground truth such as a load run or log count.
Not established by this review
- No PromQL query was sent to a Prometheus or Grafana Cloud endpoint.
- The Alloy labeldrop example was not applied to a scrape config.
- Not executed: it was not installed or run.
The review applies to the material and revision named here. A newer upstream release can change its behavior.
03 / PUT IT TO WORK
Add a skill to your workflow.
DOCUMENTED COMMAND
npx skills add grafana/skills/skills/grafana-core/promql Run in your terminal to choose your AI tools, project or global scope, and installation method. This short command follows the current upstream version; the review covers the revision shown above.
Optional: install the reviewed revision
Keeps the original source and installer version where recorded, while leaving your AI tools and installation scope for you to choose.
npx skills add https://github.com/grafana/skills/tree/1ccacf29049fde66637fe01ab93a83a772da323b/skills/grafana-core/promql - The command pins only the PromQL skill at the reviewed commit. The installer was not executed.
- Do not point the installer at a parent directory if you only want this skill.
Before you start
- Node.js and npm
- A Prometheus, Mimir, or Grafana Cloud metrics endpoint you are allowed to query
04 / FOLLOW THE EVIDENCE
The source trail.
Our notes are separate from the original resource.
Check upstream before adopting a new version.
- Skill definition ↗Checked
https://github.com/grafana/skills/blob/1ccacf29049fde66637fe01ab93a83a772da323b/skills/grafana-core/promql/SKILL.md
Supports: summary, whySelected
- Pattern library ↗Checked
https://github.com/grafana/skills/blob/1ccacf29049fde66637fe01ab93a83a772da323b/skills/grafana-core/promql/references/patterns.md
Supports: irate scope, recording-rule names, burn-rate placeholder
- Apache-2.0 licence ↗Checked
https://github.com/grafana/skills/blob/1ccacf29049fde66637fe01ab93a83a772da323b/LICENSE
Supports: Redistribution terms, Copyright 2026 Grafana Labs
https://raw.githubusercontent.com/grafana/skills/1ccacf29049fde66637fe01ab93a83a772da323b/skills/grafana-core/promql/SKILL.md
Supports: review.findings, bestFor