How to visualize different graphs according to a drop down variable?

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

  • What are you trying to achieve?
    The goal is to use a variable to control the panels being shown:
    3 rows
    3 choices on the drop down menu

When a user chooses one of the choices from the drop down menu, only the panels/visualizations related to that variable should be shown

Host | Row 1 = Host | Variable = Host
Database | Row 2 = Database | Variable = Database
Listener | Row 3 = Listener | Variable = Listener

  • How are you trying to achieve it?
    I am starting now, but couldn’t find any documentation on this topic, and figured it might be a good place to ask and see if anyone else has worked on such an issue and can provide any ideas, or if it is impossible

  • What happened?

  • What did you expect to happen?
    Same as (* What are you trying to achieve? *)

  • Can you copy/paste the configuration(s) that you are having problems with?
    N/A (no configuration setup with problems yet)

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

  • Did you follow any online instructions? If so, what is the URL?

Welcome @dominiclovell

What you want to do is completely possible, but the implementation details depend a bit on what your datasource is. Can you share some of your queries for the panels you currently have displayed?

The data is being consumed by custom Prometheus exporter working on a central host and collecting data from multiple hosts under the centralized host’s maintenance

About the queries, of course, providing 2 example queries below (1 for host and 1 for database) with some explanation

Memory{metric=“FreeMemPct”, target_name=~“$target_name”}
(optionally I tried adding the following: target_type=“host”)
The idea is to show according to the target name the free memory for that host

DB_service{metric=“DB_time”, target_name=~“$target_name”}
(optionally I tried adding the following: target_type=“host”)
The goal is to show the time each database has been up and running according to the target name chosen

The variable target_name is a variable implemented in Grafana

I had 2 ideas:

  1. Implement a way to “show” a row of panels when choosing a specific target_type as mentioned in the original question
  2. Create “dependent” variables target_name & target_type and depending on the target type you choose only specific target_names appear

The present question is for the first idea, but if someone believes the second is easier or more worthwhile implementing, I am open to discussion
I found a couple of Grafana docs about dependent variables (Two variables that are dependent on each other - #2 by mattabrams & Add and manage variables | Grafana documentation )
But they didn’t answer my question or help with 100% implementation on my side

Hi again @dominiclovell and sorry for the delay.

Just to be clear, what you are envisioning is that one would select a variable from a list at the top (Host, Database and Listener) and then have “only the panels/visualizations” related to that variable. So for Host, it might be:

and for Listener, it might be:

I originally thought you were just wanting to change a parameter in the query, but this would be the same for each panel/visualization, such as:
Net Generation:

and Total Interchange:

Hi @grant2

Thanks for the response
You are right with what you said

A quick update about my dashboard
I already managed to do dependent variables as below:

And now I would like to “open” the rows according to the choice of target_type:

Right now I have chosen listener
So I would like the Listener Row of panels to appear

It is quite a specific request, and the reason I asked in the forum because I can’t find any valuable information on this topic

@mikhailvolkov Does anything come to your mind regarding how to do this?

There are three possible options:

  1. Dynamic dashboards are supported in Grafana 10 with the new Scenes framework. It requires building an App and scripting the logic. It’s not plug-and-plug at the current stage of development.

  2. Another option is to create an Apache ECharts panel that displays charts depending on the selected variables.

  1. Create different dashboards for the Host and Listener. Depending on the selected variables, it will switch between them using Apache ECharts or any other panel that supports locationService. It’s almost transparent for end-users. We demonstrated that in the YouTube tutorial.

Hi @mikhailvolkov

Thank you for the recommendations

  1. Unfortunately we are working on Grafana 9.5 so we don’t have access to the Scenes framework, and our company hasn’t mentioned anything about moving to Grafana 10 in the near future

  2. Also we don’t have access to the Apache Echarts plugin, at our company we only have access to the Grafana plugins :frowning:

Do you think there is any way to do it?

I had one idea, but not sure if it is really solving the issue :smiley:

I did the following:

I created 6 dashboards
The 5 that have been starred and one more to create a Dashboard list on, but I couldn’t find a way to hide the stars from that view

I am open to any suggestion, but am very thankful for the possible solutions you have already provided

1 Like

You can install the plugin or ask your Grafana Administrator to do it so you can do it.
Apache Echarts is available in version Grafana 9.