@@ -16,6 +16,7 @@ Grafana comes with the following transformations:
...
@@ -16,6 +16,7 @@ Grafana comes with the following transformations:
-[Series to rows](#series-to-rows)
-[Series to rows](#series-to-rows)
-[Add field from calculation](#add-field-from-calculation)
-[Add field from calculation](#add-field-from-calculation)
-[Labels to fields](#labels-to-fields)
-[Labels to fields](#labels-to-fields)
-[Concatenate fields](#concatenate-fields)
-[Group by](#group-by)
-[Group by](#group-by)
-[Merge](#merge)
-[Merge](#merge)
...
@@ -23,19 +24,55 @@ Keep reading for detailed descriptions of each type of transformation and the op
...
@@ -23,19 +24,55 @@ Keep reading for detailed descriptions of each type of transformation and the op
## Reduce
## Reduce
Apply a _Reduce_ transformation when you want to simplify your results down to one value. Reduce removes the time component. If visualized as a table, it reduces a column down to one row (value).
The _Reduce_ transformation will apply a calculation to each field in the frame and return a single value. Time fields are removed when applying
this transformation.
In the **Calculations** field, enter one or more calculation types. Click to see a list of calculation choices. For information about available calculations, refer to the [Calculation list]({{<relref"../calculations-list.md">}}).
Consider the input:
Once you select at least one calculation, Grafana reduces the results down to one value using the calculation you select. If you select more than one calculation, then more than one value is displayed.
Query A:
| Time | Temp | Uptime |
| ------------------- | ------- | ------- |
| 2020-07-07 11:34:20 | 12.3 | 256122 |
| 2020-07-07 11:24:20 | 15.4 | 1230233 |
Query B:
| Time | AQI | Errors |
| ------------------- | ------- | ------ |
| 2020-07-07 11:34:20 | 6.5 | 15 |
| 2020-07-07 11:24:20 | 3.2 | 5 |
The reduce transformer has two modes:
-**Series to rows -** Creates a row for each field and a column for each calculation.
-**Reduce fields -** Keeps the existing frame structure, but collapses each field into a single value.
For example, if you used the **First** and **Last** calculation with a **Series to rows** transformation, then
the result would be:
| Field | First | Last |
| ------- | ------- | ------- |
| Temp | 12.3 | 15.4 |
| Uptime | 256122 | 1230233 |
| AQI | 6.5 | 3.2 |
| Errors | 15 | 5 |
The **Reduce fields** with the **Last** calculation,
results in two frames, each with one row:
Query A:
| Temp | Uptime |
| ------- | ------- |
| 15.4 | 1230233 |
Here's an example of a table with time series data. Before I apply the transformation, you can see all the data organized by time.
After I apply the transformation, there is no time value and each column has been reduced to one row showing the results of the calculations that I chose.