How to Create a Grafana Dashboard to Present individual Device Analysis using Individual Panels
Earlier in this post, we have seen how to select a device and see analysis in a dashboard panel.
How to Create a New Drop-Down Menu/Filter (Query Variable) in Grafana Based on PostgreSQL Table Column
Now, how about we want to show individual panel for each device in the same dashboard?
One way of doing it is manually creating panels and select device ID to show analysis in corresponding panel. But, how about having 500 devices?
It is waste of time to create 500 panels for 500 devices. Rather, we will create one panel and repeat it for selected devices.
Create a new Query Variable
the solution is create a new query variable. We can do the following to create a query variable.
- Create a query variable you created.
- In the “Query Options” section, set the “Query” field to
SELECT DISTINCT(<device_id>) FROM <table_name> ORDER BY <device_id> ASC.
- In the “General” section, set the “Name” field to something descriptive like “Device”.
- In the “Options” section, set the “Multi-value” option to “On”.
- In the “Options” section, set the “Include All option” option to “On”.
- In the “Options” section, set the “All format” field to
Save the variable.
- Edit the query you want to use to show sensor data. Replace the hard-coded device ID with the variable name in your WHERE clause. For example, replace
"device_id" = 'your_device_id'with
Enable Repeat Option
We can enable repeating options from the panel edit view. Let’s do the following:
Click on the Panel Title to open the Edit Panel view.
In the Panel Edit view, click on the Repeat tab.
Under the Repeat tab, set the following values:
- Variable name:
- Max values: set the maximum number of panels you want to display
- Variable name:
Save the panel and go back to the dashboard view. You should see the drop-down manu. From there, select all devices or select the ones you want to check. New panels will show up as you select more devices.
So, that’s all for today! Cheers!!!
Leave a comment