How to use request parameter value in Grafana query string

允我心安 提交于 2020-04-10 06:47:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!