Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to access variable, passed through URL in grafana?

I am trying to make a detailed dashboard in grafana that opens on click. I do it by passing a variable to the dashboard debending on the clicked facility. When the dashboard opens it needs to display value using the passed url variable inst. I just cannot seem to get it working. Here is an example of my dashboard link.

enter image description here

How can i use the variable inst?

like image 932
gogibogi4 Avatar asked Dec 24 '22 03:12

gogibogi4


2 Answers

I will add gogibogi4's correct answer. The Grafana documentation is lacking on this.
In your drill-down dashboard, add a constant variable. To be retrieved in Grafana, you need the prefix var- then the name of the variable in the query string. Let's assume the variable is "region." The URL coming into the drilldown dashboard should look similar to the following:

/drilldowndashboard/?var-region=NorthWest

Drilldown Dashboard Settings: In the drilldown dashboard settings, create a variable. The Name in this example is "region" Make the type Constant. Under Hide, you can just leave that unselected. Under Constant options, you can write the word "blank" The preview of values will just show the word "blank" but go ahead and save it as it will be replaced in the query.

Query: You can refer to the variable using [[region]] in your data query.

Parent Dashboard: The parent dashboard merely needs to refer to the drilldown dashboard with var-region as a query parameter.

like image 200
D. Lockett Avatar answered Dec 25 '22 15:12

D. Lockett


I figured out the solution on my own. The variable that i wanted to pass was var-inst, the trick to use it is to create a custom template variable named inst and give it a dummy value. After that is done i can use the passed value by using $inst. Note that in order for the variable to be passed i had to go back to my primary dashboard and then i had to click my link again. After that the value got passed and is working perfectly.

like image 29
gogibogi4 Avatar answered Dec 25 '22 17:12

gogibogi4