mirror of
https://github.com/grafana/grafana.git
synced 2024-11-29 12:14:08 -06:00
Docs: Update example docs for rename by regex
(#86627)
* baldm0mma/update_regex/ update example docs * baldm0mma/ push ts * baldm0mma/update_regex with new exmaples * baldm0mma/update_regex/ update images * baldm0mma/regex_update/ update text
This commit is contained in:
parent
6ea97e41fb
commit
ad679c62c6
@ -1165,15 +1165,17 @@ This flexible transformation simplifies the process of consolidating and summari
|
||||
|
||||
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'.
|
||||
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.'
|
||||
> **Note:** The Rename by regex transformation was improved in Grafana v9.0.0 to allow global patterns of the form '/<stringToReplace>/g'. Depending on the regex match used, this may cause some transformations to behave slightly differently. You can guarantee the same behavior as before by wrapping the match string in forward slashes '(/)', e.g. '(._)' would become '/(._)/'.
|
||||
|
||||
{{< figure src="/static/img/docs/transformations/rename-by-regex-before-7-3.png" class="docs-image--no-shadow" max-width= "1100px" alt="A bar chart with long series names" >}}
|
||||
In the following example, we are stripping the 'A-' prefix from field names. In the before image, you can see everything is prefixed with 'A-':
|
||||
|
||||
{{< figure src="/media/docs/grafana/panels-visualizations/screenshot-rename-by-regex-before-v11.0.png" class="docs-image--no-shadow" max-width= "1100px" alt="A time series with full series names" >}}
|
||||
|
||||
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" alt="A bar chart with shortened series names" >}}
|
||||
{{< figure src="/media/docs/grafana/panels-visualizations/screenshot-rename-by-regex-after-v11.0.png" class="docs-image--no-shadow" max-width= "1100px" alt="A time series with shortened series names" >}}
|
||||
|
||||
This transformation lets you to tailor your data to meet your visualization needs, making your dashboards more informative and user-friendly.
|
||||
|
||||
|
@ -1249,22 +1249,24 @@ This flexible transformation simplifies the process of consolidating and summari
|
||||
return `
|
||||
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'.
|
||||
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.'
|
||||
> **Note:** The Rename by regex transformation was improved in Grafana v9.0.0 to allow global patterns of the form '/<stringToReplace>/g'. Depending on the regex match used, this may cause some transformations to behave slightly differently. You can guarantee the same behavior as before by wrapping the match string in forward slashes '(/)', e.g. '(.*)' would become '/(.*)/'.
|
||||
|
||||
In the following example, we are stripping the 'A-' prefix from field names. In the before image, you can see everything is prefixed with 'A-':
|
||||
|
||||
${buildImageContent(
|
||||
'/static/img/docs/transformations/rename-by-regex-before-7-3.png',
|
||||
'/media/docs/grafana/panels-visualizations/screenshot-rename-by-regex-before-v11.0.png',
|
||||
imageRenderType,
|
||||
'A bar chart with long series names'
|
||||
'A time series with full series names'
|
||||
)}
|
||||
|
||||
With the transformation applied, you can see we are left with just the remainder of the string.
|
||||
|
||||
${buildImageContent(
|
||||
'/static/img/docs/transformations/rename-by-regex-after-7-3.png',
|
||||
'/media/docs/grafana/panels-visualizations/screenshot-rename-by-regex-after-v11.0.png',
|
||||
imageRenderType,
|
||||
'A bar chart with shortened series names'
|
||||
'A time series with shortened series names'
|
||||
)}
|
||||
|
||||
This transformation lets you to tailor your data to meet your visualization needs, making your dashboards more informative and user-friendly.
|
||||
|
Loading…
Reference in New Issue
Block a user