Possible to use query builder for other InfluxDB schemas?


There are several InfluxDBs connected to Grafana, all have multiple schemas.
I know how all these schemas can be accessed, but so far I have managed to use only the text editor for those schemas that are not defined in data source configuration.

For example:
Data souce: Influx DB 1, database: os
Other databases in this InfluxDB are: os2, os3 etc

Now I want to build dashboards. When I use the query builder, it works only for database “os”.

Via the text editor I can access the other databases as well.
“SELECT mean(“value”) FROM “os2”…“cpu” WHERE $timeFilter GROUP BY time($__interval) fill(null)”

But this is a bit inconvenient in some cases or for some people.

I tried using a variable and adding it there but in that case the measurements/fields etc are not loaded. Although the syntax works like this if you fill in the fields manually.

So is there any way I can access other databases via the graphical editor?


@kasnakant what you should probably do is set up multiple datasources, one for each Influx database. That way you can select the one you want from the drop-down where you’ve selected “InfluxDB 1”.

That may not be an great solution for you (especially if you have a lot of databases), but I’d say it’s pretty uncommon for a single dataset to be stored in the way that you have it - i.e. across multiple Influx databases. Was there a reason for that? If you had your data in different measurements within the same database (or even different tags within the same measurement), that would make querying easier.

Yes, it used to be like this. But if there are 60+ InfluxDBs and each have 10+ schemas in it, plus some InfluxDBs are shared by let say locations it would mean there would be close to 800 entries in the data sources configuration. And it is growing. So, it is hard to maintain those.

And one InfluxDB is shared by different departments. Each have their own schema to use. People sometimes mess up. Then they won’t affect others.

I would love if there would be possibility to define the required database somewhere, for example under query options.

Ok, so you basically have multiple tenants, each writing into their own database (I think you call it “schema” but Influx has no schemas, just databases - or buckets in Influx 2.0). Your situation makes sense - but indeed makes it hard when it comes to querying data.

Unless I’m missing something, I think your options are roughly as follows:

  • Open a feature request on Github for the database name to be configurable in the dashboard
  • Accept that you’ll just need to use the raw query editor, and find a way to make that workable
  • Consolidate your data into a single database (Influx has some decent tools for data replication, like continuous queries)

Thank you for you thoughts!
(yeah sometimes we call it schema among ourselves)

Opened request in Github. Possible to define database name in query options · Discussion #38527 · grafana/grafana · GitHub