4

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?

Ammad
  • 4,031
  • 12
  • 39
  • 62

1 Answers1

5

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$/
Ammad
  • 4,031
  • 12
  • 39
  • 62
  • 2
    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. – Mohd Waseem Dec 08 '18 at 06:31