Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 204
Yuri Bushnev Avatar asked Feb 28 '19 18:02

Yuri Bushnev


1 Answers

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.

like image 140
Yuri Bushnev Avatar answered Sep 18 '22 20:09

Yuri Bushnev