Use secondary variable as title in repeated panel

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

  • What are you trying to achieve?
    I have a Prometheus table range query that returns values identified by a port number (I1, I2, I3, etc.). I use a query variable called mx2_port to get a list of these port numbers, set it to “All”, and set the Grafana panel to repeat by that, so I get 8 panels, for example:
    I want to title each panel with both the port number and the port name. The port name is not available in this query, it’s part of a separate info metric.

  • How are you trying to achieve it?
    I added another query variable called mx2_port_name defined as label_values(mx2_info{source="$mx2_matrix_ip", port=~"$mx2_port"},port_name). I set this to “All” so when the first variable returns 8 numbers, this variable returns a list of 8 names. I tried to set the panel title to Port $mx2_port $mx2_port_name.

  • What happened?
    The second variable does not expand, so it says “All” on each panel.

  • What did you expect to happen?
    I was hoping the first panel would be labeled “Port I1 Apple TV”, and the second would be “Port I2 Coffee Table”, etc.

Alternatively, I tried searching for a way to use a label from the query results as a variable in the panel. I found a few threads asking for this but no answers, so I guess it’s not possible.