cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Is there a way to define dashboards variables with human-readable keys?

strudeau
Participant

Looking at the latest dashboards, I can see we can define dashboard variables, however I haven't found how to define variables as map where the key is a human readable string and the value is the actual value we want to use as the variable value.

For example, we want to have a variable in the dashboard that displays host name (human readable) but actually references the host.id which is the value we want to use.

Having a bunch of id's in a variable usually don't mean anything to people using dashboards since they they only know they host by their friendly name.

Is there a way to do that? Thanks.

3 REPLIES 3

marco_irmer
Helper

I am not sure if this would meet your needs, but one method we use to accomplish this is to write DQL queries that incorporate the human readable entity name into the results, and then filter based on that. There's a handy function, entityName(), that can be used to add a field containing the human readable entity name.

Example (using a variable named 'hostVar')

timeseries avg(dt.host.cpu.usage), by: { dt.entity.host }
| fieldsAdd dt.entity.host.name = entityName(dt.entity.host)
| filter dt.entity.host.name == $hostVar // filter here based on variable value

 

strudeau
Participant

Ok, so what you are proposing is to actually define 2 variables, one shown (with friendly name) and one hidden with the values. The one with the values uses the friendly name to make a lookup. I will try it out. Thanks.

Not quite. You could have one variable that just deals with human readable values, but then handle the translation between human readable and internal ID within the DQL of your tiles. I have attached a sample dashboard that you can import (you'll have to change the extension to .json before importing). In this dashboard, we have a variable that is defined by the following query:

fetch dt.entity.host
| fields hostName=entityName(id, type:"dt.entity.host")
| limit 20 // limit for demo purposes only

The variable only holds human-readable elements, the host name in this case. When a user selects a host name from the dropdown, the variable works together with the query I shared in the original reply to display the CPU utilization just for specified server.

Featured Posts