Commit e270a2de by Torkel Ödegaard Committed by GitHub

Docs: Update labels to fields transform (#30086)

* Docs: Update labels to fields transform

* Update docs/sources/panels/transformations/types-options.md

Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>

* Update docs/sources/panels/transformations/types-options.md

Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>

* Moved merge info to before examples

* Update docs/sources/panels/transformations/types-options.md

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>

* More review updates

* Update docs/sources/panels/transformations/types-options.md

Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>

Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
parent 7aa6926e
...@@ -188,14 +188,12 @@ In the example below, I added two fields together and named them Sum. ...@@ -188,14 +188,12 @@ In the example below, I added two fields together and named them Sum.
## Labels to fields ## Labels to fields
> **Note:** In order to apply this transformation, your query needs to return labeled fields. This transformation changes time series results that include labels or tags into to a table structure where each label becomes its own field.
When you select this transformation, Grafana automatically transforms all labeled data into fields. Given a query result of two time series:
Example: Given a query result of two time series * Series 1: labels Server=Server A, Datacenter=EU
* Series 2: labels Server=Server B, Datacenter=EU
1: labels Server=Server A, Datacenter=EU
2: labels Server=Server B, Datacenter=EU
This would result in a table like this: This would result in a table like this:
...@@ -204,7 +202,7 @@ This would result in a table like this: ...@@ -204,7 +202,7 @@ This would result in a table like this:
| 2020-07-07 11:34:20 | Server A | EU | 1 | | 2020-07-07 11:34:20 | Server A | EU | 1 |
| 2020-07-07 11:34:20 | Server B | EU | 2 | | 2020-07-07 11:34:20 | Server B | EU | 2 |
**Value field name** ### Value field name
If you selected Server as the **Value field name**, then you would get one field for every value of the Server label. If you selected Server as the **Value field name**, then you would get one field for every value of the Server label.
...@@ -212,13 +210,31 @@ If you selected Server as the **Value field name**, then you would get one field ...@@ -212,13 +210,31 @@ If you selected Server as the **Value field name**, then you would get one field
| ------------------- | ---------- | -------- | -------- | | ------------------- | ---------- | -------- | -------- |
| 2020-07-07 11:34:20 | EU | 1 | 2 | | 2020-07-07 11:34:20 | EU | 1 | 2 |
For this example, I manually defined labels in the Random Walk visualization of TestData DB. ### Merging behavior
The labels to fields transformer is internally two separate transformations. The first acts on single series and extracts labels to fields. The second is the [merge](#merge) transformation that joins all the results into a single table. The merge transformation tries to join on all matching fields. This merge step is required and cannot be turned off.
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
This will first result in these two tables:
| Time | Server | Value |
| ------------------- | ------- | ----- |
| 2020-07-07 11:34:20 | ServerA | 10
{{< docs-imagebox img="/img/docs/transformations/labels-to-fields-before-7-0.png" class="docs-image--no-shadow" max-width= "1100px" >}} | Time | Datacenter | Value |
| ------------------- | ---------- | ----- |
| 2020-07-07 11:34:20 | EU | 20
After I apply the transformation, my labels appear in the table as fields. After merge:
{{< docs-imagebox img="/img/docs/transformations/labels-to-fields-after-7-0.png" class="docs-image--no-shadow" max-width= "1100px" >}} | Time | Server | Value | Datacenter |
| ------------------- | ------- | ----- | ---------- |
| 2020-07-07 11:34:20 | ServerA | 10 | |
| 2020-07-07 11:34:20 | | 20 | EU |
## Group by ## Group by
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment