Need help to create a container tracker version

Hello everyone,
I need some feedback and help to create into my Grafana a dashboard where I can check all image version of my containers into Kubernetes.

Actually I created a new Panel with a type TABLE, as Data source I use my PROMETHEUS.

In Metrics browser on A, I make the following request : kube_pod_container_info{image!=“”}

Here the result :

name container container_id endpoint image image_id instance job namespace pod service uid
kube_pod_container_info application-controller containerd://… http myregistry.local/argoproj/argocd:v2.5.4 myregistry.local/argoproj/argocd@sha256:91d377251 10.50.20.30:8080 kube-state-metrics argocd argocd-application-controller-0 argocd-application-controller-0 2fc

But at the end, my goal will be obtain this following table :

Registry Project Version Namespace Number image inside namespace
myregistry.local argoproj v2.5.4 argocd 1

Actually, I deleted succesfully all duplicate images by changing value in Metrics Browser by :
count(kube_pod_container_info{image_spec!=“”}) by (image_spec)
I guess I can kept the output result in futhure for my column “Number image inside namespace”.

I also succesfully hidden the “Time” by Adding “Overrides” > “Hide in table” and select “Time” Field.

I saw I can rename my column with other overide “Display name” so, no problem to get custom column like Registry, Project, Version.

Actually I’m stuck on cutting output… I guess I have to make regex on my output myregistry.local/argoproj/argocd:v2.5.4 but how can I do this ?

I see inside “Transform” some settings like “Etract Fields” and “Rename by Regex”, it is the good way ?

And I’m worried about the fact I want a count of all image per namespace.

For example :
If I got 4x images argocd:v2.5.4 in the namespace “argocd” and 2x images argocd:v2.5.4 inside the namespace “test”, I waiting something like that :

Registry Project Version Namespace Number image inside namespace
myregistry.local argoproj v2.5.4 argocd 4
myregistry.local argoproj v2.5.4 test 2

How can I get into it? Should I create specific variables to the dashboard ?

Many thanks in advance!

Hello everyone,

Here where I’m on my initial demand, I got 2 tables :

Registry Project Version Namespace Number image inside namespace
myregistry.local argoproj v2.5.4 argo 1

Finally I can provide it with label_replace() and regex :

label_replace(label_replace(label_replace(count(kube_pod_container_info{image_spec!=""}) by (image,namespace), 'image_source', '$1', 'image', '([^/]*)/.*'), 'version', '$1', 'image', '.*:([^:]*)'), 'image_name','$1', 'image', '.*/([^/]*):[^:]*')

I hide colomun I don’t want with Transform > Organize fields

My second table :

Chart Namespace
argo-workflows-0.41.11 argo
argo-workflows-0.41.11 argo

I can provide it with label_replace() + OR and regex :

label_replace(kube_pod_labels{label_helm_sh_chart!="" }, "Chart", "$1", "label_helm_sh_chart", "(.*)")
or
label_replace(kube_pod_labels{label_chart!="" }, "Chart", "$1", "label_chart", "(.*)")

Now I want the following table :

Registry Project Version Namespace Chart
myregistry.local argoproj V3.5.8 argo argo-workflows-0.41.11
myregistry.local argoproj V2.5.4 argo argo-cd-5.16.2

I already done it wchich following steps :

Query > A

(
  label_replace(
    label_replace(
      label_replace(
        kube_pod_container_info{image_spec!=""},
  'image_source', '$1', 'image', '([^/]*)/.*'), 
    'version', '$1', 'image', '.*:([^:]*)'),
      'image_name', '$1', 'image', '.*/([^/]*):[^:]*')
)

Query > B

label_replace(kube_pod_labels{label_helm_sh_chart!="" }, "Chart", "$1", "label_helm_sh_chart", "(.*)")
or
label_replace(kube_pod_labels{label_chart!="" }, "Chart", "$1", "label_chart", "(.*)")

Query A return theses following values :
kube_pod_container_info{container=“”, container_id=“”, endpoint=“”, image=“”, image_id=“”, image_spec=“”, instance=“”, job=“”, namespace=“”, pod=“”, service=“”, uid=“”}

Query B return theses following values :
kube_pod_labels{container=“”, endpoint=“”, instance=“”, job=“”, label_app=“”, label_helm_sh_chart=“”, label_pod_template_hash=“”, namespace=“”, pod=“”, service=“”, uid=“”}

As you can see, I got many values present in each Query, but I’m interested into “pod” value, so into Transform > Join by Field
I set join “OUTER” on the field “pod”.

But I got problem, some pod has more than 1 container and they got multiples image, actually I only got “main” container reported into my table… How to deal with it?

Thanks in advance !