Influx - Help to choose in between Tag and Field
-
07-02-2021 - |
Question
I have the following columns:
'datetime', - which gives the time when the sensor values are recorded.
'machineID', - which gives the machine ID of the machine from where the sensor values are recorded.
'volt', 'rotate', 'pressure', 'vibration' - 4 different sensor values measured for a particular Machine at a time.
Please let me know if I need to name datetime and MachineID coulumns under tag or fields.
Thank you in advance.
Solution
You can take a call considering below two scenarios.
If you need to run a GROUPBY clause on a particular column/field, then you need to create it as Tag, otherwise you won't be able to use GROUPBY clause.
Indexing: Fields cannot be indexed in influxdb. Tag are automatically indexed.
Also, influx by default creates a 'time' tag, so it's better while inserting you pass the value to 'time' instead of adding an extra column called 'datetime'