Repeating Rows and Panels with Chained Variables

I’m using the ping plugin with Telegraf and InfluxDB to collect network statistics on my LAN and some external sites. I am currently pinging 7 internal sites, and 1 external site.

I have set up the InfluxDB database, called ‘ping’ to have a ‘realm’ tag for each host, either ‘internal’ for my LAN or ‘external’ for internet sites. Telegraf and InfluxDB are working properly.

I have created a dashboard with 2 variables, realm and targeturl, both have All and multi-value enabled. The query for realm is:
SHOW TAG VALUES FROM "ping" WITH KEY = "realm"
The query for targeturl is:
SHOW TAG VALUES FROM "ping" WITH KEY = "url" WHERE "realm" =~ /^$realm$/

I was able to create a dashboard using the Singlestat visualization that had all entries sorted by url with no difficulty. However, when I wanted to separate the two realms I ran into a minor problem.

The panel query I am using is:
SELECT mean("average_response_ms") FROM "ping" WHERE ("realm" =~ /^$realm$/ AND "url" =~ /^$targeturl$/) AND $timeFilter GROUP BY time($interval) fill(null)
I have the panel set to repeat horizontally, and to use targeturl, which is (mostly) working. For the internal and external rows, I have the row repeat set to use realm and it works. I have 2 rows, but Grafana is doing something strange. Both rows have 8 entries. The internal row has proper values for my 7 internal sites, plus ‘N/A’ for google.com. The external row is the opposite, I have 7 ‘N/A’ values for the internal LAN, and the value for google.com is correct.

Any ideas how I can resolve this?

@str8edgedave I just came across your post as I was revisiting this same question. Unfortunately I don’t believe that that (nested) template variable evaluation happens on a row-by-row basis currently, and that’s what causes the issue you observe. There is a broader discussion of this at Having trouble getting nested variables to work together.

In your case, my take is the following:

  • Your $targeturl template variable has the same 8 URL values on both rows (7 internal + 1 external). Note that the query SHOW TAG VALUES FROM "ping" WITH KEY = "url" WHERE "realm" =~ /^$realm$/ is evaluated on a dashboard level, and not on a row level. This explains why you see the 8 entries on each row.
  • When you query for realm AND url, you will get data for the 7 URLs in the internal realm shown on the internal row, and for the 1 URL in the external realm on the external row. By this token, for example you won’t get any data for realm='internal' AND url='google.com' - because your database has no entires there. This will probably be apparent if you look at the queries being executed (via the inspector).

I’m conscious that a response ~1 year after your post may not be particularly helpful, but figured I’d share for the benefit of anyone else just stumbling upon this.