Grafana Transformations Design Prompt
Use Grafana transformations — join queries, calculate fields, filter, rename, group by, organize columns; combine data without changing queries.
- Target user
- Engineers building complex Grafana dashboards
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior SRE who has used Grafana transformations to build dashboards combining data from multiple queries — joins, calculations, filters. I will provide: - The data flow goal - Current transformations - Symptom (transformation not applying, wrong result, slow) Your job: 1. **Common transformations**: - **Reduce** — collapse rows to single value - **Merge** — combine multiple query results - **Outer Join** — join on field - **Add field from calculation** — math between fields - **Filter by name** — keep/exclude columns - **Filter by value** — row-level filter - **Organize fields** — rename, reorder - **Group by** — aggregate rows - **Sort by** — order results - **Convert field type** — string ↔ number 2. **For joining multiple queries**: - Each query as "A", "B", "C" - Outer join by common field - Useful for comparing related metrics 3. **For calculated fields**: - Math: A / B * 100 - Useful for ratios, percentages - Reduce data before transformation 4. **For renaming**: - Series → friendlier names - For consistent legend appearance 5. **For filtering rows**: - Numerical or string match - Keep top-N 6. **For grouping**: - Aggregate by label - Reduce row count 7. **For pipeline thinking**: - Order matters - Reduce data early - Computational vs visual transforms 8. **For "transformation not working"**: - Check input fields exist - Step debugging - "Show data" reveals what each step sees Mark DESTRUCTIVE: heavy transformations on huge data sets, transformations changing label semantics for alerts, joining on missing fields. --- Data flow goal: [DESCRIBE] Current transformations: [DESCRIBE] Symptom: [DESCRIBE]
Why this prompt works
Transformations are powerful but underexplained. This prompt walks them.
How to use it
- Plan order.
- Reduce early.
- Test with “Show data”.
- Document intent.
Patterns
Join two queries (e.g., requests + errors → error rate)
Query A: sum by (job)(rate(http_requests_total[5m]))
Query B: sum by (job)(rate(http_requests_total{code=~"5.."}[5m]))
Transformations:
1. Outer join on field: "job"
2. Add field from calculation: "Error %" = (B / A) * 100
3. Organize fields: Hide A, B; show "Error %"
Top errors across multiple services
Query A: sum by (service)(rate(errors_total[5m]))
Transformations:
1. Reduce → "Reducer: Last"
2. Filter rows by value: Value > 0.01
3. Sort by Value descending
4. Limit: 10
Calculate field example
Add field from calculation:
- Operation: Binary operation
- Left: Total RPS
- Operator: /
- Right: Worker count
- Alias: "RPS per worker"
Filter / rename example
transformations:
- id: organize
options:
excludeByName:
__name__: true
job: true
renameByName:
Value: "Latency (ms)"
instance: "Host"
indexByName:
Host: 0
"Latency (ms)": 1
Common findings this catches
- Transformation result empty → join field doesn’t match.
- Calculation showing NaN → input field is string.
- Order of transformations → reduce before join changes result.
- Hidden fields still computed → reduce cost via filter.
- Renamed field breaks threshold → update threshold mapping.
- “Show data” reveals input vs expected → diagnostic.
- Slow dashboard → heavy transformation; consider query-level.
When to escalate
- Complex multi-DS dashboard — design review.
- Transformations affecting alert behavior — coordinate.
- Performance issues — query optimization first.
Related prompts
-
Grafana Dashboard Performance Prompt
Optimize Grafana dashboards — query parallelism, refresh rates, variable design, panel count, data source pressure.
-
Grafana Templating & Variables Design Prompt
Design Grafana variables — query variables, custom, interval, chained, multi-value, regex; debug missing values, slow load.
-
PromQL Query Optimization Prompt
Diagnose slow PromQL queries — cardinality explosion, range vector traps, sum vs avg pitfalls, query timeout, recording rules opportunity.