Most Grafana users treat panels as passive viewers for raw database responses. Yet Grafana ships with a powerful in-memory ETL pipeline: the Transformations tab. It allows you to join disparate data sources, compute cross-query SLA ratios, and reshape columns without writing backend glue code.
1. Understanding Grafana's Internal Data Model: Data Frames
Regardless of the queried backend (Prometheus PromQL, Elasticsearch, PostgreSQL, or a REST API), Grafana normalizes every response into typed tabular structures called Data Frames (Time, Number, String columns). Transformations operate sequentially on these Data Frames right before rendering.
2. The 4 Essential Production Transformations
- Join by field (Outer Join): Query live CPU saturation per host from Prometheus (Query A) and fetch team ownership or monthly cloud cost per host from PostgreSQL (Query B). Apply Join by field on
hostnameto merge both worlds into a single interactive table! - Add field from calculation (Binary Operation / Reduce): Compute an error ratio or remaining error budget across two separate queries (
Errors / Total * 100) on the fly. - Prepare time series & Partition by values: Convert multi-column SQL or Elasticsearch tables into distinct time-series frames ready for multi-line charting.
- Organize fields by name & Filter data by values: Hide intermediate join keys, rename technical columns for business stakeholders, and dynamically filter rows exceeding critical thresholds (e.g., show only disks above 80% usage).
3. Step-by-Step Recipe: Multi-Source Executive Table (Prometheus + SQL)
To build a unified operations table blending live telemetry with business metadata:
Select the
-- Mixed -- data source in your panel. Configure Query A against Prometheus (Format: Table, Type: Instant) and Query B against PostgreSQL.
Add the Join by field (MODE: Outer) transformation keyed on your shared
service_id label.
Add Organize fields to reorder and rename columns, then apply a Field Override to render the SLA percentage column as a color-coded Gauge cell.
When to Compute in the Data Source vs Grafana Transformations?
Heavy data reduction (aggregating millions of raw samples into an average) should always happen inside the data source (via PromQL sum/avg or Elasticsearch STATS). Use Grafana Transformations on already-aggregated results to join heterogeneous backends, compute cross-source ratios, and format executive views.