The data model has four parts and one derived concept that matters most.
A measurement is the name of what you are recording - machine_telemetry, http_requests. It is loosely analogous to a table.
Tags are indexed string key-value pairs that identify which thing the measurement is about: site=plant-a, machine=press-07, sensor=bearing_temp. Tags are always strings, they are indexed, and you filter and group by tags.
Fields are the measured values: value=74.3, rpm=1180i, fault=false. Fields may be float, integer, unsigned integer, string or boolean. Fields are not indexed, so filtering on a field value means reading the data rather than consulting an index.
A timestamp is on every point, with a precision you choose - nanoseconds down to seconds.
And the derived concept: a series is one measurement name plus one specific combination of tag values. machine_telemetry,site=plant-a,machine=press-07,sensor=bearing_temp is one series. The total number of distinct series is the number that decides whether your deployment works, and Module 2 is about controlling it.
The tag-against-field decision follows directly: if you will filter or group by it, it is a tag; if it is a measurement you will aggregate, it is a field; and if it has unbounded distinct values, it must not be a tag. A request id as a tag is unbounded cardinality; as a field it is stored, retrievable and not indexed, which is usually what you actually wanted.
The two generations, stated plainly, because this is the thing that wastes people's time:
InfluxDB 2.x - the TSM storage engine, organised into buckets with a retention period. Queried with Flux, a dataflow scripting language, or InfluxQL for compatibility. Background work is done by tasks written in Flux. Cardinality limits are real and hard: the index is in memory, and too many series exhausts it.
InfluxDB 3.x - a rewrite on Apache Arrow, DataFusion and Parquet, with data in object storage. Queried with SQL and InfluxQL. Flux is not supported. Cardinality is handled far better because the index is not held in memory the same way. Editions differ substantially - Core, Enterprise, Cloud Serverless, Cloud Dedicated and Clustered have different features, limits and retention behaviour.
The guidance: choose 3.x for new work - standard SQL, better cardinality, Parquet storage - and expect 2.x in anything existing. Whichever you choose, check which generation any documentation or answer you find refers to before following it.
Line protocol is the write format and it is worth learning as text: measurement,tag=value,tag=value field=value,field=value timestamp. The details that bite: integers need an i suffix or they are floats; strings are double-quoted; tag keys and values are never quoted; commas, spaces and equals signs must be escaped; and the timestamp precision must match what you declare, because a millisecond timestamp sent as nanoseconds lands in 1970.
Laboratory exercise 1 - provision, generate and verify.
Stand up InfluxDB 3 Core in Docker, and - if you have the time - 2.7 OSS alongside. Record the version, the storage configuration, the object store setting for 3.x, and the authentication setup.
Write the telemetry generator that the rest of the course depends on: several sites, machines per site, sensors per machine, a configurable rate, configurable tag cardinality, and the ability to emit points with timestamps in the past. Generate at least 20 million points.
Then demonstrate the model, each with evidence: write a point with an integer field without the i suffix and show it stored as a float; write a millisecond timestamp declared as nanoseconds and show it land in 1970; filter on a tag and on a field and compare the query time; and count your series.
Then demonstrate the generation difference: run the same conceptual query - the mean of a sensor over an hour, grouped by machine - in SQL on 3.x and in Flux on 2.x, and keep both. That pair of queries is the clearest statement of what the version choice costs you.
Deliverable: a reproducible Docker setup for your chosen generation, the telemetry generator as reusable code, a README recording the version and configuration, the four model demonstrations, the series count, and the same query in both generations' languages.
# ==================================================================
# *** PICK A GENERATION AND COMMIT. They are different databases
# *** wearing one name. ***
# ==================================================================
# InfluxDB 3 Core - *** THE RIGHT CHOICE FOR NEW WORK ***
# docker run -d --name influx3 -p 8181:8181 \
# -v $PWD/data:/var/lib/influxdb3 \
# quay.io/influxdb/influxdb3-core:latest \
# serve --node-id node0 --object-store file \
# --data-dir /var/lib/influxdb3
#
# influxdb3 create database telemetry
# influxdb3 create token --admin
#
# InfluxDB 2.7 OSS - *** WHAT THE INSTALLED BASE RUNS ***
# docker run -d --name influx2 -p 8086:8086 \
# -v $PWD/data2:/var/lib/influxdb2 influxdb:2.7
# influx setup --org acme --bucket telemetry --retention 30d
#
# *** CHECK WHICH GENERATION ANY DOCUMENTATION OR ANSWER YOU FIND
# *** REFERS TO BEFORE FOLLOWING IT. *** This is the single most
# common source of wasted time with InfluxDB.
# ==================================================================
# LINE PROTOCOL. Learn it as text; the clients just build this.
# ==================================================================
# measurement,tag=value,tag=value field=value,field=value timestamp
#
machine_telemetry,site=plant-a,machine=press-07,sensor=bearing_temp value=74.3,rpm=1180i,fault=false 1764500460000000000
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^
# TAGS: indexed strings. Filter and group by these. FIELDS: the values. NOT indexed. nanoseconds
# *** THE DETAILS THAT BITE: ***
#
# 1. AN INTEGER NEEDS AN `i` SUFFIX OR IT IS A FLOAT:
machine_telemetry,machine=press-07 rpm=1180 1764500460000000000
machine_telemetry,machine=press-07 rpm=1180i 1764500460000000000
# The first stores a FLOAT. And once a field has a type in a
# measurement, *** WRITING THE OTHER TYPE IS REJECTED ***:
# "field type conflict: input field rpm is type float, already
# exists as type integer"
# So the first write decides the type forever. Get it right.
#
# 2. STRINGS ARE DOUBLE-QUOTED; TAGS ARE NEVER QUOTED:
machine_telemetry,machine=press-07 status="degraded",code=3i 1764500460000000000
#
# 3. COMMAS, SPACES AND EQUALS SIGNS MUST BE ESCAPED:
machine_telemetry,site=plant\ a,machine=press-07 value=74.3 1764500460000000000
#
# 4. *** THE TIMESTAMP PRECISION MUST MATCH WHAT YOU DECLARE. ***
# declared ns, sent ms: 1764500460000 -> 1970-01-21T...
# Your data silently lands in JANUARY 1970 and every time-range
# query returns nothing. Demonstrate it once; you will
# recognise it forever.
#
# curl -X POST "http://localhost:8181/api/v3/write_lp?db=telemetry&precision=nanosecond" \
# -H "Authorization: Bearer $TOKEN" --data-binary @points.lp
#
# 2.x:
# curl -X POST "http://localhost:8086/api/v2/write?org=acme&bucket=telemetry&precision=ns" \
# -H "Authorization: Token $TOKEN" --data-binary @points.lp
# ==================================================================
# *** A SERIES = ONE MEASUREMENT + ONE SPECIFIC SET OF TAG VALUES. ***
# The number that decides whether your deployment works.
# ==================================================================
# machine_telemetry,site=plant-a,machine=press-07,sensor=bearing_temp
# machine_telemetry,site=plant-a,machine=press-07,sensor=motor_temp
# machine_telemetry,site=plant-a,machine=press-08,sensor=bearing_temp
# -> THREE series. The field values are not part of the identity.
#
# series count = product of the distinct values of every tag
# (for the combinations that actually occur)
#
# 3 sites x 40 machines x 12 sensors = 1,440 fine
# 3 sites x 40 machines x 12 sensors x 1 batch = 1,440 fine
# ... plus a `job_id` tag with 50,000 values = 72,000,000 DEAD
#
# *** COUNT IT, BEFORE AND AFTER EVERY MODELLING CHANGE. ***
# 3.x (SQL):
# SELECT COUNT(*) FROM (
# SELECT DISTINCT site, machine, sensor FROM machine_telemetry);
# 2.x:
# influx bucket list
# SHOW SERIES CARDINALITY ON telemetry -- InfluxQL
# influx_inspect report-tsi -bucket-id <id> -- the real view
# ==================================================================
# TAG OR FIELD? The decision follows directly.
# ==================================================================
# WILL YOU FILTER OR GROUP BY IT? -> TAG
# IS IT A VALUE YOU WILL AGGREGATE? -> FIELD
# *** DOES IT HAVE UNBOUNDED DISTINCT VALUES? -> IT MUST NOT BE A
# *** TAG. ***
#
# site, machine, sensor, region, unit -> TAGS (bounded)
# temperature, rpm, pressure, fault -> FIELDS (measured)
# request_id, trace_id, user_id, job_id -> *** FIELDS, NOT TAGS ***
#
# A request id as a FIELD is stored, retrievable and not indexed -
# which is almost always what you actually wanted. As a TAG it is
# unbounded cardinality and it ends the deployment.
#
# Demonstrate the cost of the choice:
# filter on a TAG (indexed) ___ ms
# filter on a FIELD (not indexed) ___ ms <- reads the data
# Both are legitimate; know which you are doing.
# ==================================================================
# *** THE TWO GENERATIONS, STATED PLAINLY. ***
# ==================================================================
# 2.x 3.x
# storage TSM (own engine) Parquet + object store
# query FLUX, InfluxQL *** SQL ***, InfluxQL
# Flux yes *** NOT SUPPORTED ***
# organisation org + BUCKET DATABASE (+ table)
# background work TASKS, written in Flux version/edition-specific
# cardinality *** HARD LIMITS *** - *** FAR BETTER ***, and
# the index is IN MEMORY still a design concern
# editions OSS, Cloud Core, Enterprise, Cloud
# Serverless / Dedicated /
# Clustered - with
# DIFFERENT features,
# limits AND retention
# behaviour
#
# *** THE GUIDANCE: 3.x FOR NEW WORK; EXPECT 2.x IN ANYTHING
# *** EXISTING. ***
# THE SAME CONCEPTUAL QUERY IN BOTH - keep this pair. It is the
# clearest statement of what the version choice costs you:
#
# 3.x, SQL:
# SELECT machine,
# date_bin(INTERVAL '5 minutes', time) AS bucket,
# AVG(value) AS mean_temp
# FROM machine_telemetry
# WHERE sensor = 'bearing_temp'
# AND time >= now() - INTERVAL '1 hour'
# GROUP BY machine, bucket
# ORDER BY bucket;
#
# 2.x, Flux:
# from(bucket: "telemetry")
# |> range(start: -1h)
# |> filter(fn: (r) => r._measurement == "machine_telemetry")
# |> filter(fn: (r) => r.sensor == "bearing_temp")
# |> filter(fn: (r) => r._field == "value")
# |> aggregateWindow(every: 5m, fn: mean, createEmpty: false)
# |> group(columns: ["machine"])
#
# 2.x, InfluxQL (the compatibility path):
# SELECT MEAN("value") FROM "machine_telemetry"
# WHERE "sensor" = 'bearing_temp' AND time > now() - 1h
# GROUP BY time(5m), "machine"
# ==================================================================
# The limits to record.
# ==================================================================
# * *** SERIES CARDINALITY *** - the one that matters. 2.x has a
# hard ceiling set by memory; 3.x is far higher and not infinite.
# * a FIELD'S TYPE IS FIXED by its first write in a measurement.
# * tag and field key and value length limits.
# * the WRITE BATCH SIZE - find yours empirically (Module 4).
# * *** RETENTION IS PER BUCKET (2.x) OR PER DATABASE/TABLE (3.x),
# *** AND IT IS NOT A DELETE *** - Module 3.
# * there is NO UPDATE. A write to the same series and timestamp
# OVERWRITES the fields it names, which is the only update
# mechanism and is why idempotent replay works (Module 5).
Discussion
No questions on this topic yet. Sign in to ask the first one.