Query for InfluxDb to select a range of tag keys

I am visualizing a data base in Grafana produced for InfluxDb. In one of my measurements I have like 1000 keys or tags or variables. I would like to select a range of them, kind of 200 of them to visualizing them. How can I do it without adding 200 news queries? I already try the query in metrics:

WHERE key > 1 AND key < 200

But nothing. I don’t know if I miss something within Grafana App or should I maybe to add a pattern or a variable?

In the picture I show you can see, the variable key is equal to 1 and in the query below equal to 2. I have 1000 values assigned to key. I would like to visualize a range for example from key=1 until key=200. How can I do that?

Nevertheless I can select the values from one single key in influxDb:

select value from leuko where “key” = ‘2’

But I can’t run this:

select * from where “key” > ‘1’ and “key” < 200

Please any thought

Grafana version = 5.2.2
Datasource = InfluxDb
Ubuntu 16.04
metric query

That is not supported by InfluxDB - https://docs.influxdata.com/influxdb/v1.6/query_language/data_exploration/#the-where-clause:

Supported operators: = equal to <> not equal to != not equal to
Other supported features: Regular Expressions

But you can still use OR conditions:

 "key" = '1' OR "key" = '2' ...

Or regexp equivalent of this OR syntax.

Probably the best option is to save “key” as a field (not as a tag) and then you will be able to use also operators ‘<’ and ‘>’.

1 Like

Thanks for your answer. Do you know any regex capable to achieve what I want? Select a range of tags to display them? I am trying

key =~ /[1-50]/

But I am not sure if that is correct

Nope. You have to use Golang regexp syntax:

key =~ /1|2|3/

Keep in mind: if you have long conditions, then you may hit URL limits (in the browser, reverse proxy, Influxdb, …)

Thanks! It was real helpful