How I setup my InfluxDB
InfluxDB enables efficient time-series data storage and retrieval. My use-case is storing home automation data like from sensors and actuators and to be able to analyse and report it with other tools. I run InfluxDB in a docker container.
Design of my configuration
Bucket is the concept used for organizing and storing time-series data. For my use-case Home Automation I created one bucket for this application with the retention set to infinite.
InfluxDB has functionality to downsample data. The idea behind downsampling is to improve query performance and reduce storage requirements while still preserving the essential information within the dataset. I assesed the amount of data to be collected far less than available storage and and set retention to infinite and did not configure any downsampling.
Measurements are a fundamental concept in InfluxDB, used for grouping data points with similar characteristics or attributes. In my approach, I align my Measurements with the Zigbee Standard for Clusters, organizing data based on functionalities rather than devices and using recognizable names.
Field is the concept to store the actual data.
Example: In the Measurement Electrical I store the related fields current, power, energy and voltage.
The last part is the use of Tags. Tags are metadata associated with each data point and represent characteristics or attributes of the data that you want to use for querying and grouping. Tags I use in general are the originating device, the communcation protocol, and the location of the measurement.
Back-up
For backing up the influxdb data that resides in the docker volume, see the former post:
Adding data
I use MQTT as the main messaging protocol and WiFi devices have native MQTT support. As Zigbee bridge I use Zigbee2MQTT and as Bluetooth bridge I use OpenMQTTGateway. Lastly I also periodically poll API’s to retrieve data on the use of utilities including gas, electricity, and water.
As main method to process MQTT messages towards InfluxDB I use Node-Red. The code pattern to create batch inserts is:
let msg2 = { payload: {} };
msg2.payload = [
{
measurement: "Illuminance",
fields: {
illuminance: msg.illuminance
},
tags: {
protocol: "tasmota",
topic: msg.topic,
sensor: "BH1750"
},
timestamp: new Date()
},
// add more
];
return msg2;