Create a variable in Prometheus/Grafana with all values selected by default - grafana

I'm using Grafana with Prometheus as a Datasource.
I'm trying to create a variable with a filtered list of servers and I want to use this list to fix list of servers to display in my Dashboard.
My variable, named servers_front, is a query (label_values(info_fqdn)) with a regex to choose my servers /.*_front/
I want to use this full list of servers by default without displaying a combobox to choose which one I want to display.
Another requirement : If a new server that matches /.*_front/ is created, I want the list is automatically updated

Edit the variable
Variables > Edit > Selection Options >enable Include All option >Custom all value>.*

When saving dashboard you have an option to "save current variables", which means that currently selected value will be stored as a default when dashboard is loaded.
So if you have a templating variable with enabled "All" option you can save your dashboard ensuring "All" is selected (with option mentioned above enabled) and it should work.
Note that what is stored in dashboard is real "all" option and not an expanded list of all currently present values, so it should be dynamically expanded.
If you want that variable hidden then either you can hide the variable and save again after changing and saving its value or (if you have variable hidden from the start you can open url for dashboard with "&var-servers_front=All" appended (which will force variable to have "All" value and save dashboard with "save current variables".

Related

Grafana Geomap: How to use variables in a "Data link" external URL

I have a working geomap in Grafana, but I cannot set up a Data link that utilizes variables in the given entry.
The variables are NOT expanded at all, even if pressing "$" show a list of possible variables indeed.

create dynamic dashboard of singlestat panel based on template variable

I would like to create a dynamic dashboard of my cluster nodes. this dashboard will be composed of multiple single state panels. each one shows the status and name of a node
So this what I have done:
create a template variable list_of_vm = label_values(up{job="node_exporter"},instance) by checking multi-value combo
the result of this is something like ip1:port, ip2:port, ... , ip7:port
create un single state panel with repeat panel set to list_of_vm. And in metrics I set up{instance="$list_of_vm",job="node_exporter"}
After checking all instances in the template variable, the panels are correctly duplicated, but their value is wrong because in metric the query is evaluated as : up{instance="$list_of_vm",job="node_exporter"}
when list_of_vm = "ip1:port+ip2:port+..+ip7:port"
And I am expecting to have ip1:port for the first panel, ip2:port for the second one...
Do you have any idea to fix this problem

How to hide panel by specific condition in grafana

I want to hide some panel by specific condition in graphana.
For instance, I have some variable in my dashboard and I want to change visibility of some graph if my variable is equal to some specific value.
Is there any way to do this?
UPD: Using repeat panel option is not solution in my case, because this option just dynamically creates new panels. But I want to hide some panel by specific value of my variable, if variable is not equal to this value then the panel should not be hidden.
I dont see an option to hide/show a panel with template variable, but instead you can create two dashboards and use dashboard links.
For example:
First Dashboard (Type A)
Second Dashboard (Type B)
Create a Dashboard link "Type B" in First Dashboard pointing to second Dashboard.
Similarly Create a Dashboard link "Type A" in Second Dashboard and point it to First dashboard.
Settings -> Link -> New Link -> Choose "Include time range" & "Include template variable value"
I have actually used this option because mine was just two variables so it was duplicating the dashboard to two and linking eachother.
If it is multiple values to show/hide, i recommend to achieve it via repeat options some how linking that variable in your query.

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.
How can i use the variable inst?
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.
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.
just referred above answer by gogibogi4 and it worked for me but when I tried to see variable information then I saw I have selected constant as a type but automatically it got converted into datasource and type is selected grafana. when I try to select them manually it didn't worked. this is some kind of bug of grafana I guess.

Remove "empty" selection from dropdown list box

When creating a form in Orbeon Form Builder, you can define a list of values for a dropdown list box.
When running the form in form runner, is it possible to remove the "[Select...]" value from this dropdown list box?
I would like to restrict the possible values only to the given ones and restricting the user from selecting an "[Select...]" value when filling in the form. I hope you understand what I mean :)
Here is a screenshot
It's not possible without changes to Orbeon Forms to remove the empty option.
The best way to achieve what you want is to make the field required. When that's the case, the user will have to select a value or validation won't pass.
(The rationale for adding/keeping an empty option at the top is to force the user to make a selection. Otherwise it is possible that users might not even look at the option selected by default, and involuntarily select an incorrect option.)