How to use request parameter value in Grafana query string
Asked Answered
C

1

5

I am using Grafana and my URL string is like:

http://servername:3000/dashboard/db/dashboard?refresh=10s&node=hanoi

How can i use the value of node i.e. "hanoi" in my Grafana Query string.

SELECT count("value") FROM "autogen"."sensor" WHERE "system_id" = 'hanoi' AND $timeFilter GROUP BY time(1m) fill(null)

Above 'hard coded' query for 'hanoi' is working fine, but i want to use node value passed as request parameter in my where clause of query string.

I can see that refresh value i.e. 10s is passed and used successfully by Grafana dashboard. How can i use/pick the node value in my query string?

Colum answered 9/1, 2018 at 19:45 Comment(0)
C
6

I am able to find answer:

First create template variable with name node and set type = constant

Use Url http://servername:3000/dashboard/db/dashboard?refresh=10s&var-node=hanoi

In Query: use where clause as shown below:

WHERE "system_id" =~ /^$node$/
Colum answered 10/1, 2018 at 0:40 Comment(1)
Thanks it helped me. I guess we need to catch the request parameter in constant template variable an only then we can use it. just $param_name worked.Venation

© 2022 - 2024 — McMap. All rights reserved.