mirror of
https://github.com/grafana/grafana.git
synced 2025-07-28 10:22:17 +08:00
Docs: added documentation for the "prepare time series"-transformation. (#36761)
* added documentation for the prepare time series transformation. * Update docs/sources/developers/plugins/data-frames.md Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com> * Update docs/sources/panels/transformations/types-options.md Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com> * Update docs/sources/panels/transformations/types-options.md Co-authored-by: Marcus Olsson <marcus.olsson@hey.com> * Update docs/sources/panels/transformations/types-options.md Co-authored-by: Marcus Olsson <marcus.olsson@hey.com> * changed according to feedbcak. Co-authored-by: Jack Westbrook <jack.westbrook@gmail.com> Co-authored-by: Marcus Olsson <marcus.olsson@hey.com>
This commit is contained in:
@ -163,6 +163,8 @@ Dimensions: 5 fields by 2 rows
|
||||
+---------------------+------------------+------------------+------------------+------------------+
|
||||
```
|
||||
|
||||
> **Note:** Not all panels support the wide time series data frame format. To keep full backward compatibility we have introduced a transformation that can be used to convert from the wide to the long format. Read more about how to use it here: [Prepare time series-transformation]({{< relref "../../panels/transformations/types-options.md#prepare-time-series" >}}).
|
||||
|
||||
## Technical references
|
||||
|
||||
This section contains links to technical reference and implementations of data frames.
|
||||
|
@ -23,12 +23,13 @@ Grafana comes with the following transformations:
|
||||
- [Rows to fields]({{< relref "./rows-to-fields" >}})
|
||||
- [Series to rows]({{< relref "./types-options.md#series-to-rows" >}})
|
||||
- [Sort by]({{< relref "./types-options.md#sort-by" >}})
|
||||
- [Prepare-time-series]({{< relref "./types-options.md#prepare-time-series" >}})
|
||||
|
||||
Keep reading for detailed descriptions of each type of transformation and the options available for each, as well as suggestions on how to use them.
|
||||
|
||||
## Reduce
|
||||
|
||||
The _Reduce_ transformation will apply a calculation to each field in the frame and return a single value. Time fields are removed when applying
|
||||
The _Reduce_ transformation applies a calculation to each field in the frame and return a single value. Time fields are removed when applying
|
||||
this transformation.
|
||||
|
||||
Consider the input:
|
||||
@ -36,18 +37,19 @@ Consider the input:
|
||||
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.
|
||||
|
||||
@ -55,7 +57,7 @@ For example, if you used the **First** and **Last** calculation with a **Series
|
||||
the result would be:
|
||||
|
||||
| Field | First | Last |
|
||||
| ------- | ------- | ------- |
|
||||
| ------ | ------ | ------- |
|
||||
| Temp | 12.3 | 15.4 |
|
||||
| Uptime | 256122 | 1230233 |
|
||||
| AQI | 6.5 | 3.2 |
|
||||
@ -67,17 +69,15 @@ results in two frames, each with one row:
|
||||
Query A:
|
||||
|
||||
| Temp | Uptime |
|
||||
| ------- | ------- |
|
||||
| ---- | ------- |
|
||||
| 15.4 | 1230233 |
|
||||
|
||||
Query B:
|
||||
|
||||
| AQI | Errors |
|
||||
| ------- | ------ |
|
||||
| --- | ------ |
|
||||
| 3.2 | 5 |
|
||||
|
||||
|
||||
|
||||
## Merge
|
||||
|
||||
Use this transformation to combine the result from multiple queries into one single result. This is helpful when using the table panel visualization. Values that can be merged are combined into the same row. Values are mergeable if the shared fields contain the same data. For information, refer to [Table panel]({{< relref "../visualizations/table/_index.md" >}}).
|
||||
@ -195,8 +195,8 @@ This transformation changes time series results that include labels or tags into
|
||||
|
||||
Given a query result of two time series:
|
||||
|
||||
* Series 1: labels Server=Server A, Datacenter=EU
|
||||
* Series 2: labels Server=Server B, Datacenter=EU
|
||||
- Series 1: labels Server=Server A, Datacenter=EU
|
||||
- Series 2: labels Server=Server B, Datacenter=EU
|
||||
|
||||
This would result in a table like this:
|
||||
|
||||
@ -219,18 +219,18 @@ The labels to fields transformer is internally two separate transformations. The
|
||||
|
||||
To illustrate this, here is an example where you have two queries that return time series with no overlapping labels.
|
||||
|
||||
* Series 1: labels Server=ServerA
|
||||
* Series 2: labels Datacenter=EU
|
||||
- Series 1: labels Server=ServerA
|
||||
- Series 2: labels Datacenter=EU
|
||||
|
||||
This will first result in these two tables:
|
||||
|
||||
| Time | Server | Value |
|
||||
| ------------------- | ------- | ----- |
|
||||
| 2020-07-07 11:34:20 | ServerA | 10
|
||||
| 2020-07-07 11:34:20 | ServerA | 10 |
|
||||
|
||||
| Time | Datacenter | Value |
|
||||
| ------------------- | ---------- | ----- |
|
||||
| 2020-07-07 11:34:20 | EU | 20
|
||||
| 2020-07-07 11:34:20 | EU | 20 |
|
||||
|
||||
After merge:
|
||||
|
||||
@ -244,7 +244,6 @@ After merge:
|
||||
This transformation will sort each frame by the configured field, When `reverse` is checked, the values will return in
|
||||
the opposite order.
|
||||
|
||||
|
||||
## Group by
|
||||
|
||||
This transformation groups the data by a specified field (column) value and processes calculations on each group. Click to see a list of calculation choices. For information about available calculations, refer to the [List of calculations]({{< relref "../calculations-list.md" >}}).
|
||||
@ -310,20 +309,19 @@ This transformation combines all fields from all frames into one result. Consid
|
||||
Query A:
|
||||
|
||||
| Temp | Uptime |
|
||||
| ------- | ------- |
|
||||
| ---- | ------- |
|
||||
| 15.4 | 1230233 |
|
||||
|
||||
Query B:
|
||||
|
||||
| AQI | Errors |
|
||||
| ------- | ------ |
|
||||
| --- | ------ |
|
||||
| 3.2 | 5 |
|
||||
|
||||
|
||||
After you concatenate the fields, the data frame would be:
|
||||
|
||||
| Temp | Uptime | AQI | Errors |
|
||||
| ------- | ------- | ------- | ------ |
|
||||
| ---- | ------- | --- | ------ |
|
||||
| 15.4 | 1230233 | 3.2 | 5 |
|
||||
|
||||
## Series to rows
|
||||
@ -437,3 +435,15 @@ In the following example, we are stripping the prefix from event types. In the b
|
||||
With the transformation applied, you can see we are left with just the remainder of the string.
|
||||
|
||||
{{< figure src="/static/img/docs/transformations/rename-by-regex-after-7-3.png" class="docs-image--no-shadow" max-width= "1100px" >}}
|
||||
|
||||
## Prepare time series
|
||||
|
||||
> **Note:** This transformation is available in Grafana 7.5.10+ and Grafana 8.0.6+.
|
||||
|
||||
Prepare time series transformation is useful when a data source returns time series data in a format that isn't supported by the panel you want to use. [Read more about the different data frame formats here]({{< relref "../../developers/plugins/data-frames.md" >}}).
|
||||
|
||||
This transformation helps you resolve this issue by converting the time series data from either the wide format to the long format or the other way around.
|
||||
|
||||
Select the `Multi-frame time series` option to transform the time series data frame from the wide to the long format.
|
||||
|
||||
Select the `Wide time series` option to transform the time series data frame from the long to the wide format.
|
||||
|
Reference in New Issue
Block a user