One or multiple data sources for multiple influx db databases?

I’m running one influxdb server but have multiple databases.

Is it best practice to setup multiple data sources in Grafana (i.e. one data source for each influxdb database) or only one data source?

When adding a data source to Grafana, it shows the following:

Database Access

Setting the database for this datasource does not deny access to other databases. The InfluxDB query syntax allows switching the database in the query. For example: SHOW MEASUREMENTS ON _internal or SELECT * FROM “_internal”…“database” LIMIT 10

…but when I try to use the Explore in Grafana to see my other databases I can’t seem to figure it out?

I use one datasource for each database, and I use around 20 of them. Although you can manually set the database on a query’s FROM, you then need to switch to the manual query editor and skip the builder. I prefer to just set the the datasource to define the database, and to create queries using the builder as much as possible, to keep them more editable and readable.

In fact, I don’t think you can define an InfluxDB datasource without setting a database?

Hi,

I had same issue/concern. Current solution works if you don’t have many data sources. But if there are hundreds, it is hard to manage all of them, if you configure each database as a separate data source.

Now yes, I can add each InfluxDB as the data source and access other databases in it. But the query builder works only for the database that was configured in settings. Would like to use the builder in all cases.

Opened/requested this: Need possibility to define database name in query options · Issue #43845 · grafana/grafana · GitHub

I’m quite new to Grafana and was struggling with the same question.
There is a seriously ugly work-around that lets you use the graphical query builder and specify a database different from the one configured for the source. I’m merely mentioning this for completeness, not suggesting it as a solution. I used it as a quick hack for testing.
image
There seems to be no checking on the quotes in the query builder, so you can close the quote the builder adds, then reopen after the double-dot that selects the database

1 Like

Hi @furui ,

Thanks for sharing this workaround. Can you please tell which InfluxDB ver you are using?