Formatting state timeline legend with more than 1 label

  • What Grafana version and what operating system are you using?
    Grafana Cloud

  • What are you trying to achieve?
    I have a state timeline which uses instance as the legend next to each bar. Instead, I want to display 2 labels, concatenated like {{site}} ({{instance}}).

  • How are you trying to achieve it?
    First I made a Prometheus table query group by(site,instance,version) (panasonic_ue_info). This returns metrics looking like this: {instance="10.123.106.30", site="ABQ-ATP", version="V2.19"}.
    Then I use “grouping to matrix” transformation with column=instance, row=time, value=version. This makes a panel like this:

I’ve tried playing with a few other transformations but can’t find any way to do this. The closest I found is to join the labels in the query, but this doesn’t allow any “complex” formatting, like putting parentheses around the IP. label_join(group by(instance, version, site) (panasonic_ue_info), "legend", ",", "site","instance").