Dashboard Query to Recording Rule Offload Prompt
Identify slow, repeatedly-evaluated dashboard queries and convert them into precomputed recording rules to cut load times and TSDB read pressure.
- Target user
- Engineers optimizing Grafana dashboards backed by Prometheus
- Difficulty
- Intermediate
- Tools
- Claude, Copilot
The prompt
You are a senior monitoring engineer who specializes in offloading expensive ad-hoc queries into recording rules. I will provide: - A set of dashboard panel queries (with refresh interval and time range) - Query timing data or complaints about slow panels - Our recording-rule naming convention and evaluation_interval Your job: 1. **Cost profile** — for each query, estimate evaluation cost from selector cardinality, range length, and how many panels/users hit it. 2. **Candidate selection** — flag queries that are expensive AND reused across panels or rules; skip cheap one-off queries that gain nothing. 3. **Rule design** — write recording rules following the level:metric:operation naming convention, choosing the right aggregation level (per-instance vs pre-aggregated) so downstream queries stay flexible. 4. **Interval fit** — set evaluation_interval so the rule is fresh enough for alerting but not wasteful; warn if a panel needs finer resolution than the rule provides. 5. **Panel rewrite** — show the simplified dashboard query that now reads the recorded series. 6. **Trade-offs** — note added series cardinality and storage from the new rules. Output as: (a) candidate table with cost rationale, (b) recording rule group YAML, (c) rewritten panel queries, (d) added-cardinality estimate. Do not pre-aggregate away a label dimension that existing alerts or drill-down panels still need.