Pivoting and Reshaping
Use these to rotate or restructure your data when the shape itself needs to change.
Pivot — DF_PIVOT
Rotate your data so that unique values from one column become the column headers.
Use this when: you have a table with a "category" column and you want each category to become its own column — turning rows into columns.
Before
Code
After — pivoted on metric
Code
Code
Rows to Fields — DF_ROWS_TO_FIELDS
Convert key-value rows into columns — each unique key becomes a column name and its value populates the cell.
Use this when: your data comes back as a list of { "key": "...", "value": "..." } pairs but you want a flat row with named columns.
Before
Code
After
Code
Code
Labels to Fields — DF_LABELS_TO_FIELDS
Promote a column's label metadata into its own columns (or rows).
Use this when: your series carry labels — like host or region tags attached to a metric — and you want those labels to appear as ordinary columns you can group, filter, or display.
Before — a value series labelled with host and region
Code
After — labels lifted into columns
Code
Code
Omit labelKeys to promote every label. Set "mode": "rows" to lay the labels out as rows instead of columns.
Extract Labels — DF_EXTRACT_LABELS
Split a structured metric name into separate label columns.
Use this when: your metric names pack several pieces into one string — Prometheus-style (http_requests{host="node-1"}), Graphite-style (servers.node1.cpu.load), or a custom pattern — and you want each piece in its own column.
Before (Graphite-style names)
Code
After — name segments split out
Code
Code
Set pattern to "prometheus", "graphite", or "custom". For "custom", supply a named-group customRegex. Set "keepOriginal": true to keep the original metric column alongside the extracted ones.