From 27b284b371b4ea7939d11340653dbcbbe7ac1dd2 Mon Sep 17 00:00:00 2001 From: Isabel Matwawana <76437239+imatwawana@users.noreply.github.com> Date: Mon, 22 Apr 2024 15:02:22 -0400 Subject: [PATCH] [v10.3.x] Docs: Update example docs for (#86722) 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 (cherry picked from commit ad679c62c60efb51ab58829b7ff55e0fd4de3f59) Co-authored-by: Jev Forsberg <46619047+baldm0mma@users.noreply.github.com> --- .../transform-data/index.md | 10 +++--- .../app/features/transformers/docs/content.ts | 32 ++++++++++--------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/docs/sources/panels-visualizations/query-transform-data/transform-data/index.md b/docs/sources/panels-visualizations/query-transform-data/transform-data/index.md index e23162e2777..8ed2a3ca47c 100644 --- a/docs/sources/panels-visualizations/query-transform-data/transform-data/index.md +++ b/docs/sources/panels-visualizations/query-transform-data/transform-data/index.md @@ -1116,15 +1116,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 '//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. diff --git a/public/app/features/transformers/docs/content.ts b/public/app/features/transformers/docs/content.ts index 138bf005a02..291c12b5724 100644 --- a/public/app/features/transformers/docs/content.ts +++ b/public/app/features/transformers/docs/content.ts @@ -1182,25 +1182,27 @@ export const transformationDocsContent: TransformationDocsContentType = { 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'. - - In the following example, we are stripping the prefix from event types. In the before image, you can see everything is prefixed with 'system.' +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'. - ${buildImageContent( - '/static/img/docs/transformations/rename-by-regex-before-7-3.png', - imageRenderType, - 'A bar chart with long series names' - )} +> **Note:** The Rename by regex transformation was improved in Grafana v9.0.0 to allow global patterns of the form '//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 '/(.*)/'. - With the transformation applied, you can see we are left with just the remainder of the string. +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-after-7-3.png', - imageRenderType, - 'A bar chart with shortened series names' - )} +${buildImageContent( + '/media/docs/grafana/panels-visualizations/screenshot-rename-by-regex-before-v11.0.png', + imageRenderType, + 'A time series with full series names' +)} - This transformation lets you to tailor your data to meet your visualization needs, making your dashboards more informative and user-friendly. +With the transformation applied, you can see we are left with just the remainder of the string. + +${buildImageContent( + '/media/docs/grafana/panels-visualizations/screenshot-rename-by-regex-after-v11.0.png', + imageRenderType, + '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. `; }, },