How to define bucket's structure

I am new to InfluxDB v2.5 and I want to add data to it. I know that there is a concept of “buckets” where my data can be saved. The question is, how can I design the structure of the data inside this bucket? How can I create or define the fields in my bucket? I want to have 3 fields: type of measurement (for example, temperature), sensor_id (for example, S1) and the value of the sensor. My structure with more than one temperature sensor would be:

S1: 35, 36, 36, 36, 34, etc (with its timestamps)
S2: 23, 23, 23, 24, 24, etc (eith its timestamps)

P1: 4, 5, 5, 5, 5, etc…

So, how can i define this fields, this structure of the bucket? I guess I have to define it before just adding data.

Hi @DevElec If you plan on how you store your data (with fields and tags), then you can store billions and billions of data points that can be queried very fast. Here is a good tutorial that I used in the beginning that taught me about fields and tags and the importance of planning [Training] InfluxDB Performance Tuning and Schema Design - YouTube It is quite old and was made before Flux, but the concepts are still applicable and everything is explained well.

Re: buckets, are you planning to save all of these data points, or would some get discarded after a period of time? (e.g. all the S1 readings get saved for 1 year, but the S2 readings get saved for 10 years?). If you plan to retain them all for the same interval (including keep forever), then just create 1 bucket.

Tip: create a bucket called “junkbucket” that you can populate with your data, get everything worked out, etc. before populating the “real” / final bucket that will contain your data. You can then delete the junkbucket.

In the 1 bucket, create 1 measurement called SensorMeasurements. If you later have other measurements (for example, WeatherMeasurements or ElectricityData,) you can create more measurements then.

Here is how I would organize the tags and fields:

Bucket DevElecBucket
Measurement SensorMeasurements
Tags: standardized descriptions of the data Sensor_ID S1, P1, S2, P2, W1, H4
Fields: data to be measured temperature integer
pressure integer
humidity integer
windspeed integer

I obviously threw in more tags and fields than you mentioned. Also, can a given Sensor_ID (e.g. S1) transmit multiple fields of data, e.g. both temperature and pressure?

1 Like