Script to modify all queries of a panel

Hi :slight_smile:

I have a question about the duplicate function of a panel:
I monitor 24 ports of a switch (with Polystat), so I have 48 query like this:

When I want to monitor another switch, I duplicate the panel. But I have to modify each query one by one to change the switch and the port (witch is reset when I change the switch)
Is there a way to make a script to change only the name of the switch for all queries ?

Thx in advance :slight_smile:

Hi.
I do know two ways to resolve your question.

First and easy, use a varible to define the switch, then copy the dashboard and change the variable value in the dasboard, just one time.

Second. Duplicate the dashboard, access to the Grafana SQL Lite database, go to dashboards, extract the json file, replace the name of the switch and update the entry in the database. That is a bit more complex, I wouldn’t use that method.
Try to use a variable.

Thank you, variables should be a solution, but I am not familiar with it ^^,
I read the doc, but I don’t find how to assign a variable into a panel :frowning:

I suppose I have to create a constant variable with the name of the switch, but how to put the variable instead the name of the switch inside the panel ?

And another problem is that all my switchs are on the same dashboard :confused:

I tried to modify the json file, replacing the name of the switch by another one, but there is another value (call “value” in the json file) witch increment one by one, so I can’t only change the name, I have to increment this value :frowning: