Search code examples
grafanainfluxdb

Query tags from InfluxDB with respect of timeFilter for Grafana variables templating


We use InfluxDB tags as variables in Grafana and we would like to limit tags by time range selected there.

Using $timeFrame is supported for select InfluxDB queries but tags are returned by "SHOW TAGS" which doesn't support $timeFrame: https://github.com/influxdata/influxdb/issues/5668

Select can return tags only in case you return value as well and as a result, you have an array which is not supported in Grafana: enter image description here

Does anyone know any workaround how to get tags based on time range?


Solution

  • Found workaround using select, subquery and distinct:

    select DISTINCT("name") from (select "name","value" from "http_req_duration" WHERE $timeFilter AND  "group" =~ /^$Group$/ AND "TestName" =~ /^$TestName$/)
    

    I'm sure will be useful for others.