As I work through this will offer a bit of a cheat sheet for those who might stumble across this thread.
The InfluxDB database output is well documented, but if you are not familiar with it (say, as me, coming from more traditional databases) it may be confusing. There’s also a confusing terminology on the webs server setup screen. Finally, I have two Iotawatts, and it took a bit of trial and error to find what worked in terms of setup so I could combine their output downstream easily.
I built a cheat sheet that has the Iotawatt setup on the top, and a command line interface output at the bottom.
The first thing to know is that InfluxDB has some serious limitations that will not come naturally to traditional database users: (1) it will not allow math (etc) across “measurements”, only within a measurement (it does allow it between fields and differently tagged data with some caveats), and (2) you will see it easily does rollup aggregation on a automated basis, BUT you cannot create new data with new tags.
This last one is a bit obscure; I have an ACCompressor (outside circuit) and AirHandlerHeat (inside). Each is identified by a tag (whose value are those names). I wanted to create a similar measurement with a tag of simply “AC”. You cannot do that in InfluxDB – you can add them together in a query, but not save the data with the new tag (you can save it untagged, even as a new measurement, but if you are using tags to identify circuits (and the like) this breaks your model.
Using measurements instead of tag actually makes it worse – then you are even more restricted.
You can output it from Iotawatt of course, added together, provided both items are on the same device. However, there is a bit downside from doing that, or put another way, there is a convenience if you send a given data item only once – if you then do SUM() against them collectively, you are not double counting them.
So here’s what my setup looks like:
It’s useful to follow the colored arrows.
RED is what the measurement name becomes in Influxdb – that is from the text box at the top – do not be confused by the “measurements” section which is subtly different (I wonder if something like “outputs” might be mess confusing – these produce measurements, but nothing in that section is specifically a Measurement per Influxdb). What ever you put in the Red box becomes the thing on the left if you say “Show Series”. In my case I make it the $Units, which in turn produces two measurements – Watts and Volts (as those are the only units I send). Notice on the left side in the CLI – that “Watts” is from the input box.
Now look at the BLUE arrows. I have defined those as $name, and these map to the “measurements” section names (think “InfluxDB Outputs” not “Measurements”) like “ACCompressor”. Notice they are referred to in the Tag section, which in turn produces a tag on the series beside the actual Measurement name (red). So in the output of Show Series they are of the form “Watts” (from red above) and “ct=ACCompressor” as a tag and can be used in the where clause in queries.
Now look to the Green line. The Field-Key becomes the Field Name in the data. In my case (magenta bracket) I have units that are both Volts and Watts, and if you follow them up to the Field-Key where $units is used again, it flows into the data as shown in the two select statements. This does not need to match the Units, it could simply be “Value” if you like – but it seemed to make sense to show the name as the units.
I used $units in both the measurement and field-key, so I get the same name in both places, but they are very different. Measurement is a grouping, and strongly isolates data. If for example I had used the IotaWatt’s device name there for Measurement (e.g. putting in $device in place of $Units in the Measurement input box), I would get two separate groups (red arrow), both of which would have field names of Watts – but I would have great difficulty combining them together properly. Influxdb will do nothing much at all between Measurements, so pick that name most carefully.
What I wanted was to make this look, as much as possible, like it all came from one IotaWatt; that makes reporting on it easiest. I can always tell by “ct” tag which device it came from if debugging.
The result of all this is that my database now has per-minute data (the 60 at the top), updated every minute (same times bulk send number = 1).
Now I’m working on aggregation and presentation. More later.