CCCAs I worked to finalize this today, I added the ability to override the defaults using variables. It’s possible that this will accommodate all of the schemes that have been advanced. I’ve defined three variables:
- $device = the “Device name” in the setup/device section.
- $name = the name of the current output.
- $units = the units associated with the current output.
I’ve added two new specifications to the influxDB configuration:
- measurement = The name to be used for each measurement. Default is ‘$name’
- field-key = the string to be used as the key in the field set. Default is ‘value’
The new variables can be used in the following specifications:
- measurement
- tag value
- field-key
So now, using the defaults, we get the following line protocol measurements:
<output name>[,tag-key1=tag-value1[,tag-key2=...]] value=<output value> <time>
If we specify measurement=$units and add a tag name=$name we get:
<output units>,name=<output-name> value=<output value> <time>
Watts,iota=test,name=input1 value=156.38 1523648480
Watts,iota=test,name=input2 value=467.56 1523648480
Watts,iota=test,name=input3 value=155.14 1523648480
Volts,iota=test,name=voltage value=118.96 1523648480
That should look familiar to @fredrike .
I think @matt case has measurement=iotawatt, a tag name=$name, and field-key set to $units:
iotawatt,name=<output name> Watts=<output value> <time>
iotawatt,iota=test,name=input1 Watts=155.46 1523648580
iotawatt,iota=test,name=input2 Watts=468.35 1523648580
iotawatt,iota=test,name=input3 Watts=154.72 1523648580
iotawatt,iota=test,name=voltage Volts=118.93 1523648580
In both examples there is an extra tag ‘iota’ which could be removed, just trying to make it easier to clean up after posting these examples to my database.
The rules are:
-
The variable names are case sensitive.
-
Variable names are replaced as they are encountered in a string, left to right. So if you have a tag-value of ‘$name.$units’, for output mains with units Watts the tag value would be ‘mains.Watts’ if the tag-value were ‘circuit.$name.02’ you would get ‘circuit.mains.02’.
-
All of the values that influx defines as strings can be specified in these fields with any characters except: white-space, " (double quote), ’ (single quote). They will be inserted into the relevant influx expressions unquoted.
-
If the $ is used outside of one of the variable names, it will be treated like any other character.
I’m thinking that this will allow complete flexibility in uploading data without injecting a lot of complexity. I’ll build dashboards around the default case, and it could end up that down the road contributed dashboards will require a specific data view. That’s something for anyone to consider before deviating from the defaults.
Here’s what I hope will be the final configuration page: