I'm trying to visualize k8s pod lifetimes on their respective nodes as deployments occur. By following this answer, I've been able to get the layout I'm looking for:
However, all the pod lifetimes for one node (one entire row) are the same color, until one hovers the mouse cursor over the graph - I'd like these to be different colors, so that it's easier to see the delineations at-a-glance.
Usually this would be done with Value Mappings - but in this case, the value names are randomly generated, and I can't possibly add mappings for all of them beforehand. I'd like Grafana to hash the value (string) to dynamically map that to a color - is there any way to do something like that?
EDIT: In addition to the solution below for coloring, it can be useful to raise the Line width
attribute on the State Timeline
properties to show transition boundaries more clearly when successive elements are the same color, which can reduce the need for different coloring.
Turns out, it is possible to have Value Mappings that are regex-based - for this example, the random strings can be bucketed by a prefix, with a color assigned to each bucket. The random portion obeys the alphabet [a-z0-9]
, for a total of 36 characters. I created 18 regex-based Value mappings, each covering random strings that start with one of two characters (this is only slightly tedious):
This is the result:
side note: For this usecase, it was also helpful to create a Special
value mapping to match Empty
and color it Transparent
, to draw the gaps when there was no pod on a particular node.
To create a regex value mapping, click the Add a new mapping
button in the Value mappings
dialog:
and then pick Regex