I’m using Grafana 11.2
The issue I’m facing is that my queries return values under the label called VALUE, which results in multiple columns. I want to replace this label with a unique label name so that all values align in the same row instead of appearing as separate columns under the value label.
Using Promql replace_label
I’m not sure how syntax works
Giving unique label names to VALUE label by using replace_label
Query1 :sum by (cluster_name,namespace_name,pod_name,container_name,project_id,location)((kubernetes_io:anthos_container_cpu_core_usage_time{monitored_resource=“k8s_container”,pod_name=“test1”}))
Query2: sum by (cluster_name,namespace_name,pod_name,container_name,project_id,location)((kubernetes_io:anthos_container_uptime{monitored_resource=“k8s_container”,pod_name=“test1”}))
Which Give 2 different vales for under one single label called VALUE. I want to replace this VALUE label to VALUE1 VALUE2
Hi,
Value
does not really come from PromQL - it’s not a label it’s the actual value of the returned metric. Could you share an image (Excel, drawing) of what you’d like to achieve (preferably with the same data as the screenshot above)?
Also - did you use any transformations already?
Thanks for you replay
Yes, I used transforms 1. Series to rows and 2. Extract fields (Source as Metric) .
What I’m trying to achieve is lets say I have 2 metrics related to pod health. One metric returns the age of the pod and other metric returns the CPU usage value under same label called value. When I group_by pod and value it is splitting up into 2 different rows. But I need them in one row.
Current: 
Trying to Achieve:

So, what you could do (and worked for me):
-
Rename the query refs with CPU and Age (the one I have with Accepted
, by defualt it should be A
or B
):
-
Switch format to Table
:
-
Use Join by field
transformation (the ones you’ve used aren’t really necessary by now). For Mode I like to use inner but I don’t think it should matter here, for field use pod
/ pod name
/ whatever your label with pod is.
Worked for me (some renaming will be needed but Organize fields by name
transformation should help.
I do not have option to classic promql query builder. I have limitations, where I can use only Promql query
Ok,
so just to confirm, when you do not use any transformations, in table view do you have two columns: Time
and the “json” with series? If so, what you could do is to use:
Label to fields
transformation with Mode set to Columns
, which will parse your column with json fields to actual columns
Join by field
transformation in which you’ll join the two queries by the pod.
Notice that I used it on Instant queries - they both returned only one point. Is that your case? Will it work for you? I guess that’s to be seen 
1 Like
Without Transforms
With suggested Transforms
But they didn’t returned Value
In labels to fields transformation set mode Columns, not Rows
1 Like
I’m using 3 metrics and I have 2 pod. Instead of having 3 columns, its splitting up into multiple. I need 3 Value columns and 2 rows. Can you help here
Can you share the data without any transformations? In regular promql you cannot have (I think) multiple values returned, so I won’t be able to reproduce it with promql.
Unfortunatelly, I don’t have any idea. I tried multiple transformations, even some expressions but with no luck 
No worries. Thank you for efforts and time
