Using Grafana v13.1.0, I am trying to find old images and image missmatches running in multiple kubernetes clusters.
Normally I would expect that all pods/containers across all cluster/namespace combinations run the same version, but there might be clusters (probably), or even different pods in a deployment (hopefully not) that might differ.
I have a PromQL query that will give me columns
cluster,
namespace,
image_name,
image_version,
count
which gives me enough information.
I am now looking to generate a table like:
image/cluster
Cluster 1
Cluster 2
Cluster 3
Change Count
image 1
v1.2.3
v1.2.3
v1.2.3
0
image 2
v42
v23
v42
1
image 3
v42-dev1
v42
v42, v42-dev1
1
My goal for the “Change Count” column is to color-code rows with different values and to hide it later.
I started with the query and added a transformation “Add field from calculation” which gives me the list of version for unique cluster/namespace/image_name combinations:
If a cluster runs the same image across multiple namespaces with different versions, “Grouping to matrix” keeps only one and silently drops the rest. Add field from calculation (Reduce row) won’t fix this → it reduces across fields in the same row, not across multiple rows. Use Group by first to merge those rows.
“Change Count” flags every column as changed
“All unique values” returns a JS array, not a string. Change Count compares with strict inequality (!==), and two arrays are never equal even with identical contents → so every column reads as “changed.” (Distinct Count has the same issue, since it uses a Set.) Fix: convert that field to a string before it reaches Change Count.
Before the fix, every row gets the same Change Count regardless of whether the versions actually differ:
Result: grafana/loki-canary → 0, oss/csi-node → 1, mirror/calico → 2 (with cluster-a correctly showing both v3.31.2, v3.31.5 from two namespaces on the same cluster).