Search code examples
pythontime-seriesinfluxdb

Correctly organize time series data on InfluxDB


I'm super new to time series database and I've just approached the use of InfluxDB with Python.

I'm trying to understand what's the best way to organize data.

The system I need to monitor is basically a cluster of sensors. The data acquisition will be in real-time but not 24/7. The user will be able to start/stop the acquisition and every acquisition must be grouped.

Having read the documentation and the examples with Python my idea of gerarchy organization is something like

- Measurement: My Cluster Sensor
-- Tag: My Acquisition #1
--- Field: My Sensor #1
--- Field: My Sensor #2
...... etc

A similar python code would be

point = (
    Point("MyClusterSensor")
    .tag("Acquisition", var_acquisitionNumber)
    .field("Sensor1", var_sensor1,"Sensor2",var_sensor2)
  )
write_api.write(bucket=MyBucket, org="[email protected]", record=point)

Does it make sense and it is in line with the idea of InfluxDB and how it should be used?

Is there a better way to store the data?


Solution

  • It turned out to be the right choice but field is used as

    point = (
        Point("MyClusterSensor")
        .tag("Acquisition", var_acquisitionNumber)
        .field("Sensor1", var_sensor1)
        .field("Sensor2",var_sensor2)
      )
    write_api.write(bucket=MyBucket, org="[email protected]", record=point)