1

Using Prometheus as datasource, in Grafana, I have a Table visualization that lists kubernetes containers and their versions using this query:

kube_pod_container_info{namespace="$namespace", pod=~"pod-.*"}

Example table looks like this:

| pod          | Version |
| -------------| ------- |
| pod-firstapp | 123     |
| pod-secondapp| 456     |

This only lists unique versions of any given pod if there are multiple instances of it, so in case of a container being upgraded, or stuck during an upgrade, two rows for the same pod will appear, with different versions, like so:

| pod          | Version |
| -------------| ------- |
| pod-firstapp | 123     |
| pod-firstapp | 124     |
| pod-secondapp| 456     |

How could I highlight that 2nd row if and when it appears? The only way I can think of is via Value mappings but I don't know if it's possible to set those to compare two values. Thanks in advance.

oaaya
  • 133

1 Answers1

1

You cannot compare values of different columns in Table panel, but value mapping still can help you.

You can use query:

count by (container, image) (
 kube_pod_container_info{namespace="$namespace", pod=~"pod-.*"}
) * 0
+ on(container) group_left()
count by (container) (
 count by (container, image) (
  kube_pod_container_info{namespace="$namespace", pod=~"pod-.*"}
 )
)

After this you can add value mapping for column value, and replace 1 with all actual, and range 2-999 with something like some are outdated in red font.

Since version are stored in labels there is no way to find which one is outdated automatically, and you'll need to figure this yourself.

This wouldn't color whole row (AFAIK it is impossible for new version of Table panel), but I believe should be good enough for your cause.


If you want to be a bit more proactive, you can create alert with expression

count by (container) (
 count by (container, image) (
  kube_pod_container_info{namespace="$namespace", pod=~"pod-.*"}
 )
) > 1

It'll return containers that have more than 1 image version running on them.

markalex
  • 363
  • 2
  • 13