mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Transformer: Rename metrics based on regex (#29281)
* Grafana: Rename By Regex Transformer * Removing unused deps * Add scrollIntoView() to TranformTab.content() * Exporting RenameByRegexTransformerOptions * Add doc block to renameByRegex transformer * Adding doc block for RenameByRegexTransformerOptions * removing scrollIntoView() for transform tab * Adding back in scrollIntoView() for transform panel * Tests: fixes e2e tests * Apply to displayName instead of just the name of the frame * Rewrite docblock to match new functionality * Adding documentation * Changing TLD to domain name * Fixing typo * 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> * Update docs/sources/panels/transformations/types-options.md Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com> Co-authored-by: Hugo Häggmark <hugo.haggmark@grafana.com> Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> Co-authored-by: achatterjee-grafana <70489351+achatterjee-grafana@users.noreply.github.com>
This commit is contained in:
@@ -19,6 +19,7 @@ Grafana comes with the following transformations:
|
||||
- [Concatenate fields](#concatenate-fields)
|
||||
- [Group by](#group-by)
|
||||
- [Merge](#merge)
|
||||
- [Rename by regex](#rename-by-regex)
|
||||
|
||||
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.
|
||||
|
||||
@@ -398,3 +399,17 @@ When you have more than one condition, you can choose if you want the action (in
|
||||
In the example above we chose **Match all** because we wanted to include the rows that have a temperature lower than 30 _AND_ an altitude higher than 100. If we wanted to include the rows that have a temperature lower than 30 _OR_ an altitude higher than 100 instead, then we would select **Match any**. This would include the first row in the original data, which has a temperature of 32°C (does not match the first condition) but an altitude of 101 (which matches the second condition), so it is included.
|
||||
|
||||
Conditions that are invalid or incompletely configured are ignored.
|
||||
|
||||
## Rename by regex
|
||||
|
||||
Use this transformation to rename parts of the query results using a regular expression and replacement pattern.
|
||||
|
||||
You can specify a regular expression, which is only applied to matches, along with a replacement pattern that support back references. For example, let's imagine you're visualizing CPU usage per host and you want to remove the domain name. You could set the regex to `([^\.]+)\..+` and the replacement pattern to `$1`, `web-01.example.com` would become `web-01`.
|
||||
|
||||
In the following example, we are stripping the prefix from event types. In the before image, you can see everything is prefixed with `system.`
|
||||
|
||||
{{< docs-imagebox img="/img/docs/transformations/rename-by-regex-before-7-3.png" class="docs-image--no-shadow" max-width= "1100px" >}}
|
||||
|
||||
With the transformation applied, you can see we are left with just the remainder of the string.
|
||||
|
||||
{{< docs-imagebox img="/img/docs/transformations/rename-by-regex-after-7-3.png" class="docs-image--no-shadow" max-width= "1100px" >}}
|
||||
|
||||
Reference in New Issue
Block a user