Dynamic Dashboards

Rather than hard-coding specific information (such as node names or resource IDs) in a panel, the OpenNMS Plugin for Grafana offers several ways to create more dynamic and interactive dashboards.

Template variables

Template variables can be used in metric queries and panel titles. They are also displayed as a drop-down list at the top of each dashboard. You can select variables from the list to filter the data that your dashboard displays:

OpenNMS Plugin for Grafana dashboard displaying the template variable drop-down list.

Each datasource can accept different template variable queries. For example, the Performance datasource has two available template queries:

  • Specific nodes: nodeFilter(NODEFILTERSTRING)

  • Specific resources on a node: nodeResources(NODEID[, id|label|name[, resource-type-name|*]])

For more information on template queries, see the Entities and Flow datasource pages.

Use template variables in a query

Follow these steps to use template variables in a query for a category of nodes (switches):

  1. Select or create a panel. For this example, we created a panel that displays active TCP connections:

    Example configuration settings for an OpenNMS Plugin for Grafana dashboard panel.
  2. Click the Dashboard Settings symbol at the top-right of the panel.

  3. Select Variables  Add Variable.

  4. Configure your desired settings. A preview of the returned values is displayed at the bottom of the page:

    Example configuration settings for a new variable. The Preview of Values section is outlined in red.
    • Supported queries are in the form nodeFilter($filter) or nodeResource(FS:FID), where $filter is any filter expression. In this case, we used the nodeFilter variable to specify the nodes in the "switches" category.

  5. Click Add, then click Save.

For more examples of template variables in queries, import the OpenNMS Network Interfaces Report sample dashboard.

Specify a node variable in the panel

After you create a template variable, you must update your panel to make sure that data is available from all monitored nodes, rather than one specific node:

  1. In the panel, type $node in the Node box.

  2. Type nodeToLabel($node) in the Label box to make it unique. Note that a label must be unique to display data in the panel.

    Example panel configuration settings.
  3. Click Save.

  4. Select the nodes whose data you want to display from the Node list:

    OpenNMS Plugin for Grafana panel displaying a node selection list.

Create a filter panel

Filter panels let you configure a series of variables by which to filter data on a dashboard. While template variables work with the Performance datasource, the filter panel coordinates with any panels on the dashboard that use an Entities datasource to automatically apply filters that match those variables.

Before you create a filter panel, make sure that you have a panel on your dashboard that uses an Entities datasource (see Create a panel). This example creates a panel that lets you filter on alarm type and alarms that are either acknowledged or in a situation.

To create a filter panel, follow these steps:

  1. On your dashboard, click the Add Panel symbol.

  2. Click Choose Visualization and choose a Filter Panel.

  3. Under Filter Columns, choose an Entities datasource:

    OpenNMS Plugin for Grafana Choose Visualization page. The filter panel type is selected, and the OpenNMS Entities datasource is highlighted.
  4. Choose Alarms or Nodes, as appropriate.

  5. Click the plus symbol (+) and choose an attribute to filter on from the list (for example, Alarm Type, "Is Acknowledged"):

    Filter panel configuration page displaying the Data Source Entity list. Alarm Type is highlighted.
  6. Specify information about the appearance of your filter field, including whether it is a drop-down list or a text field, and a custom label, as desired:

    Filter panel configuration page. The plus symbol beside the Data Source Entity list is highlighted.
  7. Repeat steps 4-7 to add additional filters, as desired.

  8. In the left navigation menu, click the General symbol to change the name of the filter panel and specify additional information.

  9. Click the Save Dashboard symbol at the top-right of the panel.

The filter panel is displayed on your dashboard:

Example filter panel on an OpenNMS Plugin for Grafana dashboard.

All panels on the dashboard that use an Entities datasource will be updated as you modify the values in the filter panel. You can drag the panel to appear anywhere on your dashboard.