I have 2 prometheus labels that I would like to show in my grafana legend, but depending on the values selected in the grafana templating variables 1 of the prometheus labels will or will not exist. I am wondering if there is a way to only show the labels that do exist.
Since my query is using an aggregation, there is nothing contained in the “__name __” label, therefore I am entering my own metric name in my legend, followed by the labels. For example: AVG {{ label1 }} {{ label2 }}
I would like {{ label2 }} to only be present if label2 exists. With my current implementation, when label2 doesn’t exist I end up with something like this in my legend: AVG value1 label2 <- Notice ‘label2’ wasn’t replaced with the string interpolation.
My other thought is to just display the default legend values with some custom text prepended to it, but I couldn’t figure out how to do that.
Thanks for any help