Write PromQL without remembering PromQL.
PromQL is not difficult, it is just impossible to remember the exact shape of a rate over a histogram at the moment you need it.
The specific problem
Most PromQL is one of about six patterns: a rate over a counter, a quantile from a histogram, an aggregation with a label selector, a comparison against a threshold. Everyone knows what they want and almost nobody remembers whether rate goes inside or outside the sum, which is the kind of thing you look up every single time.
It knows your metric names
A general model writes plausible PromQL against metrics that do not exist. With the repository open the agent can see the instrumentation and use the metric and label names you actually emit, which is the difference between a query you run and a query you correct first.
Then look at the code
Once a query shows something interesting, the same session can open the code that emits the metric. Whether an increase means more traffic or a slower path is not answerable from the metric alone, and answering it usually means reading the instrumentation.
Patterns worth having generated
| What you want | The shape |
|---|---|
| Request rate | rate over a counter, summed by label |
| Error ratio | rate of errors divided by rate of total |
| p99 latency | histogram_quantile over a rate of buckets |
| Saturation | current value against a limit |
| Change over time | increase over a window |
| Alert condition | a comparison with a for duration |
| Error budget burn | ratio over a window against an SLO target |
Ask for it
Questions
Does it know my metric names?
It can read them from your instrumentation code, and from Prometheus itself when connected. That is what stops it inventing plausible names.
Does it write LogQL too?
Yes. The Loki path matters more in practice, since LogQL's parser expressions are harder to remember than PromQL's aggregations.
Can it write alert rules?
It drafts them, including the for duration, which is the part most often left out and most often the reason an alert is noisy.
Related
- Loki Log Analysis with AIFinding the log line is half the job. The other half is working out what emitted it and why.
- AI Design Mode for Web PagesDescribe a page and Design mode returns working HTML you can look at, click through and edit, then implement in the repo you already have open.
- App Wireframe GeneratorLow fidelity on purpose. A wireframe that looks finished gets reviewed as a design instead of as a structure.
- User Flow Diagram GeneratorThe value is in the branches you had not thought about, which is exactly what drawing the flow forces you to name.
Last updated