Dashboard>Datasource>'Include All' - not working to query multiple DBs

  • What Grafana version and what operating system are you using?
    Grafana 9.3.16, in EKS. Datasources are external to EKS cluster.

  • What are you trying to achieve?
    Query single OR multiple MySQL datasources from one panel, based on variable drop-down.
    User will enter a ‘customer number’ in a text box, and select a region to query – OR ‘All’.
    The query will then be run against any one region DB (this works with each singly), or against ‘All’ (this does NOT work with ‘all’ or any combination)

note: customer number is regionally unique, so there will always be ONE result returned for all 4 regions, not multiple rows. I do not want or need a join across the DBs (datasources)

  • How are you trying to achieve it?
    One Dashboard with one panel. Two variables in dashboard
    1 - text box to the entered value
    2 - datasource variable with regex that gathers the 4 datasources that represent the regions

The panel has ONE query with datasource being {$region}

  • What happened?
    Queries to any one DB singly work fine.
    Trying to use ‘all’ or any selected combination (from the drop-down) give no result

  • What did you expect to happen?
    Each use case should work, that is query a single selected DB, or if ‘all’ is selected then the query should be executed against all (multiple) DBs.

  • 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.

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

is the Environment drop down used in the query itself?

no the environment/region value is NOT used in the query. Only the CID (customer id) from the text box is used in the query.

I want to submit the same query to one, or all DB, and get back the one valid row/result.

The query is above in the screen shot … (only non-variable tablenames are redacted)

oh gotcha, it is used for data source $region? so are these actual separate mysql server or separate different databases?

yes, as in the screen shot … DataSource={$region}

these are totally different database instances in seperate AWS accounts, regions, zones and everything.

each datasource works fine (and is in use in other dashboards)

You cant do All. Because it will be comma delimited list, unless maybe you do repeated dashboards

ooookaaay …

any way to accomplish this?

that seems like a bug, or at least a missing feature … because why allow ‘all’ option with panel datasouce come from variable that is a list of datasources…

1 Like

Let me spin up a few mysql server containers and see what can be done

Yes, it is missing feature from your point of view. All/multiselect is there only because it is a dashboard variable. But all/multiselect of datasource doesn’t fit into current Grafana implementation. Each query has reference e. g. A, which then can be used in expression, transformation. But how will you deal if you have multiple A references, because all/multiselect is used for datasource? So I would say this is not good feature.

I would define 3 queries - one per datasource and then play with where condition and datasource variable. That condition must return false/true based on checked variables. So if datasource is not checked, then where condition will be false and that query return nothings.