Variable to group multiple values under one key

  • What Grafana version and what operating system are you using?
    Grafana Cloud

  • What are you trying to achieve?

Create repeating panels based on “Areas” grouped by energy sensors in a building.

  • How are you trying to achieve it?

The sensors have unique IDs and names but I am struggling to create groups like:

Mains: 1, 2, 3
Kitchen: 4, 5
Common: 6, 7, 8

Where I and the client can select Mains and/or Common and have that metric panel repeated without creating a separate panel for each area. I am doing this at the minute.

I understand that the values in a custom variable are comma separated so it is reading each one as a new option for the drop down list. I have also tried using variables to pull in the list but can’t get it to work.

The information is stored in a timeseries DB

  • What happened?

Custom Variable Key : value doesn’t seem to be able to store more than one value like a Python dictionary

  • What did you expect to happen?

Store multiple values under one key so it would pull those values into the query and display the results in a panel

Mains : Mains Incoming, Main 1 Hotel Feed, Mains 2,
Kitchen : SDB 6, MCC 6, SDB 55

Only Mains Incoming or SDB 6 metrics show when Mains or Kitchen is selected

  • Can you copy/paste the configuration(s) that you are having problems with?

  • Did you receive any errors in the Grafana UI or in related logs? If so, please tell us exactly what they were.
    No

  • Did you follow any online instructions? If so, what is the URL?
    Trying to follow the variable syntax Variable syntax | Grafana documentation

1 Like

welcome @ronanconnor

use the infinity data source csv. 2 variables, one shown the other hidden
This would be better done in a sql databasse so it can be set to be dynamic and you do not need to come into these variables when you have new rooms and sections etc.

  1. variable name rooms

infinity csv

room
Mains
Kitchen
Common
  1. variable name sections, set to Nothing which hides it
__value,__text
Mains,1
Mains,2
Mains,3
Kitchen,4
Kitchen,5
Common,6
Common, 7
Common, 8

you just created a parent child relationship.
you can then filter this second list based on a where clause for infinity csv and use something like where __value = $rooms
see doc: UQL

Then your repeat can happen on either ${sections:text} or ${secions:value}

Hey @yosiasz

Thanks for the speedy response I will give this a go

Ronan

looks like infinity is not the way to go, there seems to be an issue on the sections variable. best to go with a db route would be my recommendation.