mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 23:35:15 +08:00
Transformations: Extended support for variables in filter by name (#75734)
* Extend support for variables in filter by name * Simlpify help and include variable support * Simplify regexp * Remove id that was left from an erlier implementation attempt * Update docs/sources/panels-visualizations/query-transform-data/transform-data/index.md Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com> * Improve variable name and fix react warning --------- Co-authored-by: Isabel <76437239+imatwawana@users.noreply.github.com>
This commit is contained in:
@ -281,28 +281,41 @@ You'll get the following output:
|
||||
|
||||
### Filter by name
|
||||
|
||||
Use this transformation to remove portions of the query results.
|
||||
Use this transformation to remove parts of the query results.
|
||||
|
||||
Grafana displays the **Identifier** field, followed by the fields returned by your query.
|
||||
You can filter field names in three different ways:
|
||||
|
||||
You can apply filters in one of two ways:
|
||||
- [Using a regular expression](#use-a-regular-expression)
|
||||
- [Manually selecting included fields](#manually-select-included-fields)
|
||||
- [Using a dashboard variable](#use-a-dashboard-variable)
|
||||
|
||||
- Enter a regex expression.
|
||||
- Click a field to toggle filtering on that field. Filtered fields are displayed with dark gray text, unfiltered fields have white text.
|
||||
#### Use a regular expression
|
||||
|
||||
In the example below, I removed the Min field from the results.
|
||||
When you filter using a regular expression, field names that match the regular expression are included.
|
||||
|
||||
Here is the original query table. (This is streaming data, so numbers change over time and between screenshots.)
|
||||
From the input data:
|
||||
|
||||
{{< figure src="/static/img/docs/transformations/filter-name-table-before-7-0.png" class="docs-image--no-shadow" max-width= "1100px" >}}
|
||||
| Time | dev-eu-west | dev-eu-north | prod-eu-west | prod-eu-north |
|
||||
| ------------------- | ----------- | ------------ | ------------ | ------------- |
|
||||
| 2023-03-04 23:56:23 | 23.5 | 24.5 | 22.2 | 20.2 |
|
||||
| 2023-03-04 23:56:23 | 23.6 | 24.4 | 22.1 | 20.1 |
|
||||
|
||||
Here is the table after I applied the transformation to remove the Min field.
|
||||
The result from using the regular expression `prod.*` would be:
|
||||
|
||||
{{< figure src="/static/img/docs/transformations/filter-name-table-after-7-0.png" class="docs-image--no-shadow" max-width= "1100px" >}}
|
||||
| Time | prod-eu-west | prod-eu-north |
|
||||
| ------------------- | ------------ | ------------- |
|
||||
| 2023-03-04 23:56:23 | 22.2 | 20.2 |
|
||||
| 2023-03-04 23:56:23 | 22.1 | 20.1 |
|
||||
|
||||
Here is the same query using a Stat visualization.
|
||||
The regular expression can include an interpolated dashboard variable by using the `${[variable name]}` syntax.
|
||||
|
||||
{{< figure src="/static/img/docs/transformations/filter-name-stat-after-7-0.png" class="docs-image--no-shadow" max-width= "1100px" >}}
|
||||
#### Manually select included fields
|
||||
|
||||
Click and uncheck the field names to remove them from the result. Fields that are matched by the regular expression are still included, even if they're unchecked.
|
||||
|
||||
#### Use a dashboard variable
|
||||
|
||||
Enable `From variable` to let you select a dashboard variable that's used to include fields. By setting up a [dashboard variable][] with multiple choices, the same fields can be displayed across multiple visualizations.
|
||||
|
||||
### Filter data by query
|
||||
|
||||
@ -1010,4 +1023,8 @@ Use this transformation to format the output of a time field. Output can be form
|
||||
|
||||
[feature toggle]: "/docs/grafana/ -> /docs/grafana/<GRAFANA VERSION>/setup-grafana/configure-grafana#feature_toggles"
|
||||
[feature toggle]: "/docs/grafana-cloud/ -> /docs/grafana/<GRAFANA VERSION>/setup-grafana/configure-grafana#feature_toggles"
|
||||
|
||||
[dashboard variable]: "/docs/grafana/ -> docs/grafana/<GRAFANA VERSION>/dashboards/variables"
|
||||
[dashboard variable]: "/docs/grafana-cloud/ -> docs/grafana/<GRAFANA VERSION>/dashboards/variables"
|
||||
|
||||
{{% /docs/reference %}}
|
||||
|
Reference in New Issue
Block a user