I’m trying to reduce the size of one of my variable router_IP to create a playlist of dashboard (the first 14 ones in one and the rest in another).
Working with influxDB, my variable looks like this:
SHOW TAG VALUES ON supervision FROM snmp WITH KEY = agent_host WHERE network =~ /^$network$/
which returns a lot of IP address:
I’m a very bad user of REGEX, but using:
/^(10\.211\.0\.[2-9])$/
I’ve been able to only get the IP from 2 to 9!
But if I set it from 2 to 10 ( [2-10] ) :
So I’m actually struggling…
Using this syntax:
/^(10\.211\.0\.(10|11|12))$/
I’ve been able to collect one by one every address, but since I have a lot, it’s not a durable solution…
I would use different approach:
that SHOW TAG VALUES supports LIMIT and OFFSET, so I would use them to create 2 sets (e.g. LIMIT 14/LIMIT 1000 OFFSET 14) → you don’t need any regexp at all
That’s a great idea but, I don’t know why, my address are not sorted correctly. I do know why, but I don’t know how to change that on the query, ORDER BY agent_host ASC does not work.
e.g. :
SHOW TAG VALUES ON supervision FROM snmp WITH KEY = agent_host WHERE network =~ /^$network$/
10.211.0.10
10.211.0.11
10.211.0.12
10.211.0.13
10.211.0.14
10.211.0.15
10.211.0.16
10.211.0.17
10.211.0.18
10.211.0.19
10.211.0.2
10.211.0.20
10.211.0.21
10.211.0.22
10.211.0.23
10.211.0.3
10.211.0.4
10.211.0.5
10.211.0.6
10.211.0.7
10.211.0.8
10.211.0.9
then if I add option to the query, I cannot use the sort option from Grafana since the output would already be changed:
SHOW TAG VALUES ON supervision FROM snmp WITH KEY = agent_host WHERE network =~ /^$network$/ limit 14
10.211.0.10
10.211.0.11
10.211.0.12
10.211.0.13
10.211.0.14
10.211.0.15
10.211.0.16
10.211.0.17
10.211.0.18
10.211.0.19
10.211.0.2
10.211.0.20
10.211.0.21
10.211.0.22
And of course, I have to display my router ordered but IP address haha
I gave you link to the doc, which is your good friend. Doc doesn’t mention support for ORDER in SHOW TAG VALUES so it is expected that ORDER won’t be working (BTW values are sorted alphabetically anyway, but you expect IP numeric sort).
You didn’t mention that you want to have sorted list - just 2 sets (“the first 14 ones in one and the rest in another”). So this is not a solution for you in this case and you have to write proper regexp for it.
Yeah it’s my bad, I missed that I was ordering my values with Grafana option, sorry.
And yeah, I have to write the REGEX, that’s why I’m here because I’m struggling haha. If it’s not the right place for it, let me know.