问题
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?
回答1:
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$/
来源:https://stackoverflow.com/questions/48175627/how-to-use-request-parameter-value-in-grafana-query-string