-
What Grafana version and what operating system are you using?
11.4.0-79146 -
What are you trying to achieve?
Group the results by removing the k8s names -
How are you trying to achieve it?
First step is transform the results by removing the extra information in pod_names. For e.g. if the name is home-cart-75657f7676-54t2v, I would like to extract home-cart. To achieve this I am using transformations [1]+.[a-z]+.[a-z]+.*$ -
What happened?
It is replacing the column name instead of the actual data -
What did you expect to happen?
-
Can you copy/paste the configuration(s) that you are having problems with?
[2]+.[a-z]+.[a-z]+.*$ -
Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
No -
Did you follow any online instructions? If so, what is the URL?
-
No
try a value mapping rather:
I was able to do the Value mapping using below
\b(?<!-)(?<role_name>[a-z0-9]+(?:-[a-z0-9]+)*?)(?:-([a-f0-9]{8,10}))?-([a-z0-9]+)\b(?!-)
but now not sure how can I group and average as the transformations doesn’t work.
Hi,
As far as I know Value Mappings are the last step that are applied, so the transformations will be applied first. Would Format string
transformation with substring
mode work? If not, what datasource are you using? Maybe you’ll be able to do so on the datasource side?
Here’s the query avg by(pod_name) (kubernetes_io:container_memory_request_utilization{ and pod_name is field that I would like to regex before doing the average.
The format string with substring will not work because of the variable size of fields
home-cart-werewrgwe-ewergu
home-cart-api-egerreg-egewr
home-orderview-erggwer-ergwer
home-orderview-api-ergerww-eerwgwer
I was able to get the results using below query
avg(label_replace(kubernetes_io:container_memory_request_utilization{…}, “app_name”, “$1”, “pod_name”, “(?<role_name>[a-z0-9]+(?:-[a-z0-9]+)*?)(?:-([a-f0-9]{8,10}))?-([a-z0-9]+)”)) by (app_name) * 100
Thanks to all who helped me in figuring this out.