Think about all the people who need to interact with your custom dashboards to quickly access relevant data insights. To reduce any toil for your dashboard users, you’ll want to make your dashboards navigable, understandable, and adaptable to similar use cases. 

When visiting a new dashboard, it can be challenging for your stakeholders to understand how the data is structured or what each attribute or value conveys. Without that understanding, it’s difficult or inefficient for them to filter the dashboard for the data that’s relevant to them. On top of that, others in your organization trying to use your dashboard for different use cases find it time-consuming and tedious. They’d need to make multiple copies of the dashboard and configure each dashboard’s widgets to fit their respective use case. 

Introducing template variables for easy, precise dashboard filtering

In New Relic custom dashboards, template variables serve as placeholders in your NRQL queries that users can later assign a value. After the value is assigned, the relevant dashboard widgets automatically change to reflect that value. 

Instead of needing to hard-code a specific host or entity name, people in your organization now have the flexibility to switch between different values depending on their use cases. For example, let’s say you have a dashboard that monitors performance data for only a specific service. Repurposing the dashboard to monitor other services would require duplicating it and manually hard-coding changes. Now you can build a single dashboard that tracks any combination of services by easily swapping different values in and out of a template variable.

Because of the variables functionality, it's simple to migrate our dashboards from Grafana to New Relic, where we can also benefit from being connected to the rest of the New Relic platform, so we don't have to switch between multiple tools.

Ways to take advantage of template variables in your dashboards

Template variables unlock the possibility to have dynamic, highly interactive dashboards. Everyone who uses your dashboards can get data relevant with more precise and easy-to-digest filtering.

With template variables, you can:

  • Get all filtering controls in one place. The new variables filter bar better informs all dashboard users about the values that are important to filter by, which makes it easier to understand what changes are made with each filter selection. 
  • Get more precise results. Selecting a value for a template variable only applies to the widgets that include that specific variable placeholder. Data from other widgets that are irrelevant to the filter remain visible.
  • Turn your dashboards into templates. You can make your variables pull from a dynamic list of values generated from a query. This allows your dashboard to move from one account to another without inhibiting its functionality or requiring you to redo your widget queries every time.

Watch this video to see ways to use template variables:

Set up and get started with template variables

To create a template variable, go to your dashboard and select the +  button to add a variable.

1. Enter both a query name and a display name. The query name is how you’ll refer to the template variable when writing your NRQL query. The display name is how your template variable appears in the overhead filter bar. 

2. Next, choose the variable type. There are three types of template variables available for customizing your dashboard:

  • Text variable. Enable the dashboard users to input any text they want to filter for. 
  • List variable. Provide the dashboard users with a list of preselected options to choose from. 
  • Query variable. Give the dashboard users a list of options that are returned from another NRQL query.

3. Finally, depending on the variable type you selected, you might need to input the options that your dashboard users can select (for list variables) or the query (for query variables).