Tables and comparisons often need data shaped differently than the data source returns it.
Transformations (the Transform tab of the panel editor) process query results after they return and before visualization. They are applied in order, and you can inspect each step's output with the debug view.
Frequently used ones:
- Merge: combine several queries into one table, matching on common fields such as time and labels. The usual way to build a table with one column per query.
- Join by field: join frames on a field, such as
instanceorTime, like a SQL join. - Reduce: turn each series into a row with calculations (last, mean, max) across the time range; perfect for "per instance summary" tables.
- Organize fields by name: rename, reorder and hide columns.
- Filter data by values, Filter fields by name: drop rows or columns.
- Add field from calculation: compute a new column, for example a ratio of two columns or a row total.
- Group by, Sort by, Labels to fields and Convert field type.
Transformations run in the browser on already-fetched data, so they can't reduce how much data the query returns. When a calculation can be done in the query itself (PromQL division, aggregation), do it there: it's faster and works the same in alerting. Use transformations for presentation and for combining data from different data sources.
Example
{
"type": "table",
"title": "Instances",
"targets": [
{"refId": "A", "instant": true, "format": "table",
"expr": "sum by (instance) (rate(http_requests_total[5m]))"},
{"refId": "B", "instant": true, "format": "table",
"expr": "max by (instance) (process_resident_memory_bytes)"}
],
"transformations": [
{"id": "merge", "options": {}},
{"id": "organize", "options": {
"excludeByName": {"Time": true},
"renameByName": {"Value #A": "req/s", "Value #B": "memory"}}},
{"id": "sortBy", "options": {"sort": [{"field": "req/s", "desc": true}]}}
]
}Remember
- Transformations reshape results in the browser, in order
- Merge, Join by field, Reduce and Organize fields cover most tables
- Prefer doing maths in the query when possible
Watch out for
- Fetching huge raw data and filtering with transformations instead of filtering in the query.