InfluxQL -- MQTT Topic Data, and a needed calculation

Influx v 2.7.4, Grafana v.10.2.2

I have MQTT data being pushed into Influx. Building out a query to get two values (volts and current (amps)), looks like this so far…

SELECT "value" FROM "mqtt_consumer" WHERE ("topic"::tag = 'N/e8eb11e512f4/solarcharger/258/Dc/0/Voltage' OR "topic"::tag = 'N/e8eb11e512f4/solarcharger/258/Dc/0/Current') AND time >= now() - 6h and time <= now()

However, I really need a third value, but that value is computed. I need to show “Watts”, which would be volts * amps. I have ZERO idea how to even start on this, to get a computed field out. I see, too, that I can create separate queries in this InfluxQL query builder. I’ve set up the query above with the OR, but also two separate queries. Works about the same either way.

Can someone assist me in an example of how to create the calculated value? If this were regular SQL (like MSSQL) and these were fields, I would know how to do it. SELECT voltage, current, voltage*current AS 'watts'

But the “structure” of InfluxDB seems different and I don’t have a grasp of what looks like what… Is a topic a table? Seems like a bucket is a database…

Appreciate any help…

1 Like

Here’s a visual of what I’ve described:

While you await the influx guru @grant2 you might also post here

As your question is more influx than grafana

Influx guru reporting for duty…

How about using a Grafana transformation?

But those tags, why are they so wild

Hey, hadn’t seen that feature. That’s pretty good. I ended up routing everything through Influx after all, for the historical aspects. So, now that the suns down I’m still able to see the data! I’ll added it into the same graph, but the values are so different in scale, I’ll likely have to break it out like you did. (Unless there’s some…adjustment to apply that has disparate graph lines make sense.)

Thanks for that awesome suggestion.

Are you asking about that crazy paths? Just the way the MQTT data is provided from the Victron systems: dbus · victronenergy/venus Wiki · GitHub

1 Like

Those cant be diluted into individual tags?

Tags are indexed fields are not.

I’m no MQTT expert, nor (obviously) am I a Grafana or Influx expert. That’s just how they are published from the hardware manufacturer.

Now, if you’re suggesting there’s some alternative thing I shoujld be doing, please elucidate, or maybe send me a link to something.

How are you pushing data from mq to influxdb ?

Telegraf?

Yes, Telegraf.

Playing now with node-red, reading some data, massaging it and putting it back in a shorter path, but mostly just playing around.

1 Like

Might want to also pile on influxdb data structure best practices. Depends on your requirements