0
votes

I am using template variable queries to assign a variable in Grafana.

SELECT * FROM jmeter WHERE application =~ /$tag_left/ ORDER BY time asc LIMIT 1

Result JSON of this query is

{"results":[{"series":[{"name":"jmeter","columns":["time","application","avg","count","countError","endedT","hit","max","maxAT","meanAT","min","minAT","pct90.0","pct95.0","pct99.0","rb","responseCode","responseMessage","sb","startedT","statut","transaction"],"values":[[1595241959625,"demo_scenario.jmx @ 1 @ Mon Jul 20 16:15:58 IST 2020",null,null,null,0,null,null,0,0,null,0,null,null,null,null,null,null,null,0,null,"internal"]]}]}]}

I need to get time from this query. Which is coming in version 5.0 of grafana but not coming in 7.0 version.

Is there any way in which I can select the respective column like time from the query result and assign it to variable ? something like ${var:index}

I am attaching the screenshot for more clarity on this.

Version 5.0

Version 7.0

As you can see, one is showing timestamp as variable value (e.g. 1595228080029), and another one is showing application value (e.g. demo_scenario.jmx @ 1 @ Mon Jul 20 16:15:58 IST 2020 ) under Preview of values section as a result of query

Underlining data source is InfluxDB. And in both the cases api query has same response.

1

1 Answers

0
votes

Used variable query returns time series and multiple "columns" (because SELECT *) - that's wrong. Doc https://grafana.com/docs/grafana/latest/datasources/influxdb/#templating contains how proper template query should looks like, e.g.

SHOW TAG VALUES WITH KEY = "hostname"

It doesn't return time series and only one "column" (hostname in this particular case) is returned. InfluxQL doesn't allow you to select only time column, so it isn't possible to implement it in the Grafana as you want.