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

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.

Related

Use list in Grafana Variables

I have different Grafana dashboards build on Graphite datasources.
And add variable with such values:
grp1,grp2,grp3,grp4
Now I can choose any group in dropdown menu and it works perfectly
Also I can write in the query body something like:
{grp2,grp4} to get sum of this two groups.
My question - how to make variable value that combine several possible values?
I mean I want to add to dropdown menu more options like some combinations
I tried the same way in Variables menu:
grp1,grp2,grp3,grp4,{grp2,grp4}
but this doesnt works - it create values like {grp2 and grp4}
Also I tried to use Alloption here in the menu, but without success.
You need to escape comma with \, e.g.:
grp1,grp2,grp3,grp4,{grp2\,grp4}
so {grp2,grp4} will be one item in this case.

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

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".

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.

Setting Date as a prop in Adobe DTM

I'm trying to use Adobe DTM to pass the date to a prop variable but haven't had much success. The final output should be a prop report in Adobe that'll provide me traffic data for specific dates (5/11/16, 6/15/15 etc). The ultimate goal for setting the dates as a prop is to be able to classify a range of dates based on various business needs.
Could anyone point me in the right direction for getting this done? I am assuming I'll have to add a line of code in the s.code file that'll define s.prop5 = ...
Thanks
Based on your comments, it sounds like you are just looking to pop something with the current date stamp with "MM-DD-YYYY" format.
As Gigazelle mentioned, you can create a Data Element to return the value, and then reference it for setting your prop. However, throwing a data layer into the mix may be overkill for you, depending on your needs/limitations.
Data layers are meant for exposing data that DTM can't feasibly/reliably automate on its own via built-in features or hosting an autonomous js snippet.
The only reason you might want to consider having your site push it to a data layer, is if you want to generate the date via server-side coding to ensure the date is generated within the same timezone setting for all visitors. If you generate it client-side, it will be generated according to the visitor's browser/system settings. Since visitors are from all over the world in different timezones, the data may not be as consistent (even if you add additional code to change the timezone offset, it still may not be 100% based on browser version/security settings, or visitors who alter their browser/system date/timezone settings).
So, if you want to ensure the best accuracy, then I suggest you output the value via server-side code, and put into a data layer. How you do that depends on your server and what language you have at your disposal for your web pages being served up. Here is a very basic example using PHP:
<script>
var dataLayer = {
currentDate : '<?php echo date('m-d-Y'); ?>'
}
</script>
This will have the server generate the date stamp and output a js object called dataLayer with a property currentDate you can reference. You can create a Data Element as Type "JS Object" and for Path, put dataLayer.currentDate, and then reference your Data Element elsewhere (see below).
If that's too much trouble for you or if you want to keep it pure client-side/DTM and are okay with the potentially lower consistency...
Within DTM, go to Rules > Data Elements, and click Create New Data Element.
Name it "currentDate" (no quotes).
For Type, choose "Custom Script", and click Open Editor, and add the following:
var t=new Date(),d,m,y;
d=t.getDate();
d=d<10?'0'+d:d;
m=t.getMonth()+1;
m=m<10?'0'+m:m;
y=t.getFullYear();
return m+'-'+d+'-'+y;
Click Save and Close and Save Data Element.
Now you can reference the data element to pop prop5. How you do it depends on how you've setup Adobe Analytics within DTM. For example, if you set it up as a tool and only want it to pop on initial page view, you can open your AA tool config, go to the Global Variables dropdown, and set prop5 there. You reference it as %currentDate%
You can do the same %currentDate% syntax in a Page Load Rule or other rule or any other place that uses DTM's built-in fields.
Alternatively, if you need to reference it within javascript code (e.g. if you are setting prop5 within s.doPlugins or some other Custom Script box, you can reference the data element like this:
s.prop5 = _satellite.getVar('currentDate');
Set a JS variable on your site (such as within a data layer) that outputs the date in the format you wish to collect it in. Something like var d = Date();
In DTM, go to Rules > Data Elements and create a data element that maps to the JS variable you created on your site
If you want prop5 to be defined on every page, click the gear icon and map prop5 to your data element name by using %DataElementName% (whatever you named your data element in step 2, wrapped in percent signs). If you don't want it defined on every page, go to Rules and create a page load rule, event based rule or direct call rule depending on when you want the variable to trigger. Under the Adobe Analytics section of the rule, map prop5 to %DataElementName% .
This will allow you to collect dates as values, which can then be used in classifications.