Use variable to disable (CSV) data sources

  • What Grafana version and what operating system are you using?
    9.3.2 on CentOs 7

  • What are you trying to achieve?
    I am having several data (CSV) sources that bring in different files from separate projects. I want to be able to compare any of these projects with each other, i.e. display any of them alone or with any others in parallel.

  • How are you trying to achieve it?
    So I am trying to use a dashboard variable to toggle the data sources on or off, ideally with a selection.

  • What happened?
    I just cannot figure out how I could set this up.

Could anybody please help me out ?

Thanks !

Hi @lulasmaster,

Welcome to the :grafana: community support forums !!

We are excited that you joined our OSS community. Please read about some of the FAQs in the community :slight_smile:

For CSV data I would recommend to use the JSON Infinity plugin as it has features of handling various data types e.g. JSON, CSV, XML etc.

It has a very good documentation as how to use it and how to use variables. Please check this link and read its documentation.

I hope this helps.

thanks a lot for you welcome and your answer !
One of my requirements is that I need to use locally stored csv files, so instead of the inifinity plugin (which does not support the “file” protocol) I went for using the CSV plugin maintained by Grafana Labs (CSV plugin for Grafana | Grafana Labs).
Apart from that, I think that my question is kind of more generic.
I would like to drive the disable/enable status of a query with a variable in the dashboard, kind of like clicking on the corresponding button:
Is that possible ?

It does support data stored locally on the file. I attached a screencast (open it in a new window as will be easier to zoom in and view more clearly)


Not sure, how to control the query editor option to enable/disable from a custom-defined variable. As the query you will make is from JSON datasource and the query-editor enable/disable is the Grafana UI (totally 2 different things).

Nice, but that will ‘disconnect’ from the actual source file, i.e. when it’s updated reloading those dashboards will not reflect the change if the data is not re-imported manually. Again, an additional requirement that I did not feel worth mentioning, sorry for that.

I understand what you are saying about UI vs data source.
Do you have any other idea how to selectively activate queries ?

I found this post which has 3 answers to this.

A bit more explanation:

Yes, you will need to create a custom variable to define it like a toggle button from the menu. This way if the user does not have permission to edit the query, they can still select the state (enable/disable) from the variable listed on top of the panel

Thank you for that pointer!
I will verify the concept and then see if I can bring this one step further:
Because, what would be actually desirable is a single variable with multi values where the user can just select what he wants to see.