Panel repeat based on chained variables

I have a dashboard. There are two variables both with all option:
1:interface, for example, with three values: A, B, C.
2.definition, which is queried from a postgresql database based on $interface. for example, A->1/1/1, B->1/2/1, C->1/3/1 ( each $interface has only one definition. both interface and definition columns are unique).
I want panels to repeat based on $interface. in each panel, the title is $interface, but use $definition in the influxdb query, for example, select Rx from m1 where def=$definination.
#1 panel: title ='A"; query = select Rx from m1 where def=‘1/1/1’,
#2 panel: title = 'B"; query = select Rx from m1 where def=‘1/2/1’,
#3 panel: title = ‘C’; query = select Rx from m1 where def=‘1/3/1’ .

I read this post:
but, is there any work around to do this?
Thanks in advance

I understand the post said that “This is not supported, as variable query execution only happens at the top level for the whole dashboard.”
but in my situation, the query only need execute at the top level for the whole dashboard.

Generally, you don’t need to chain variable. Use key/value variable, because Postgresql, e. g. variable interface:

  title AS __text,
  def AS __value 
FROM interfacestable

Then repeat panel by that variable and use ${interface:text} in panel title and ${interface:value} in the query.

1 Like

Your solution does solve the problem. Your help is greatly appreciated!
If there are more variables, and they are all one-to-one map. Just image now we also need ip with interface, definition.
any suggestion to that?
Thanks again in advance.

It depends on the use case. I guess IP should be used in the the panel legend: so you already have “metric” query, add aditional query just to query other metadata (e. g. IP, MAC,…) and then use join transformation to join “metric” and “metadata” query results into one result by common column (e. g. def).

1 Like