Influx 1.8 - Query across Databases

Hi all,

I am still running Influx 1.8, I was wondering if one could do a query across measurements in different databases e.g.

Database(s)
Sensor1
Sensor2
Sensor3

Each of those have a measurement:
Sensor1 - Total
Sensor2 - Total
Sensor3 - Total

I want to query all of these databases read the measurement “Total” and add them all up to get a total of the values across these measurements in different DB’s.

Looking at the documentation I see I can run multiple select statements by using the “;” between the select statements but that gives me individual values so it would just output
Total=1
Total=2
Total=3

What I am trying to get to is “something” like Sensor1 Total + Sensor2 Total + Sensor3 Total = <Sum_Value>

Would someone mind pointing me in the right direction?

Hello @meaningoflife,
I believe that if you enable flux, then you might be able to do that with flux. You can’t do that with influxQL. You would have to join the data with Flux.

Something like:

one = from(bucket:"Sensor1")
|> range(...)
|> filter(fn: (r) => r._measurement == "Sensor1 - Total")

two = from(bucket:"Sensor2")
|> range(...)
|> filter(fn: (r) => r._measurement == "Sensor2 - Total")

three = one = from(bucket:"Sensor3")
|> range(...)
|> filter(fn: (r) => r._measurement == "Sensor3 - Total")

union(tables: [one, two, three])
|> sum() 

Or you could use findRecord() instead and extract the single values and then add them together.

1 Like

Thank you @Anaisdg for taking the time to respond. I do have flux enabled on 1.8 never used it. I have been putting off upgrading to 2.x simply due to the volume of data and number of dashboards I have using IQL.

I guess it’s becoming that time to just get it done :slight_smile:

Thank you for the example above will use it once I get the upgrade going.