Authentication differs by generation and edition, and the first thing to check is whether it is on. 2.x uses API tokens with scopes, created against an organisation, and supports an all-access token which is the one to avoid. 3.x Core and Enterprise use tokens created by the CLI or API, with admin and database-scoped kinds. In every case a token is a bearer credential in a header, so it leaks like any other, and the controls are scoping, rotation and transport security.
Token scoping is where least privilege lives. In 2.x a token can be limited to read or write on specific buckets, which is genuinely useful: a device writes to the raw bucket and cannot read anything; a dashboard reads the rollup buckets and cannot write; a rollup task reads raw and writes rollups. Build that set and test every denial. The anti-pattern is one all-access token in every device's firmware, which is both the easiest thing to do and an unrecoverable position - because rotating it means reflashing the fleet.
The practical design for a device fleet is worth stating because it is a real problem: a per-device token is ideal and is operationally heavy; a per-site or per-fleet write-only token scoped to one bucket is the usual compromise; and a token that can only write, to one bucket, limits a compromised device to writing nonsense into a bucket you can identify - which is a very different incident from one that can read your whole history.
TLS terminates at InfluxDB or at a proxy. The point that matters for telemetry: devices on untrusted networks sending credentials in a header need transport security, and a fleet that cannot do TLS needs a gateway that can.
Monitoring. The InfluxDB-specific set: series cardinality, which is the number that predicts failure and which must be tracked over time rather than checked once; write throughput and the write error rate, separating rejections from failures, because a field type conflict is a client bug and a timeout is a capacity problem; the points-beyond-lateness-window counter from Module 3; rollup drift, from the detection query; query latency and the rate of queries without a time range, which is a leading indicator of a dashboard problem; storage growth against retention, so you can see expiry working; and for 2.x the in-memory index size, which is the resource cardinality consumes.
Retention is the dominant cost and this is the module's most practical content. Storage cost is roughly: points per second, times bytes per point after compression, times the retention period, summed over every retention level. The arithmetic is simple and the consequence is not: raw data at full resolution for a long retention is almost always the largest line in the bill, and a cascade that keeps raw for a week instead of a year can reduce storage by a factor of fifty while preserving every query a dashboard actually runs. So the retention policy is the cost model, and arguing about instance sizes before settling the retention cascade is arguing about the wrong thing.
Upgrades and compatibility. Within 2.x, minor upgrades are routine. Between 2.x and 3.x there is no in-place upgrade: the storage engines and query languages differ, and the migration is an export and reload plus a rewrite of every Flux query and task. That is a project, not an upgrade - so the generation choice made in Module 1 is a long-lived commitment, and the honest way to plan a 2.x deployment is to know what the eventual move costs.
Laboratory exercise 6 - make it defensible.
Enable authentication and TLS. Then demonstrate what an unauthenticated instance costs: start one without authentication, write to it and read from it with no credentials from another container, in an isolated lab network.
Implement least privilege with scoped tokens: a device token that can write to the raw bucket only; a dashboard token that can read the rollup buckets only; a rollup token that reads raw and writes rollups; and a monitoring token with no data access. Test every denial.
Demonstrate the all-access anti-pattern: show that one such token can read every bucket, delete a measurement and create tokens, and then write the rotation procedure for a fleet that has it embedded - which is the uncomfortable part.
Configure monitoring with every metric above, including a cardinality trend, the lateness counter and the rollup drift check.
Then produce the retention cost model: measure bytes per point after compression at each rollup level, and compute the storage for four retention cascades - including a deliberately naive one keeping raw data for a year. State the ratio between the cheapest and the most expensive.
Finally, produce the upgrade plan: within your generation, and the cross-generation migration as a costed design exercise including the Flux rewrite if you are on 2.x.
Deliverable: the security configuration, the unauthenticated demonstration, the scoped token set with every denial tested, the all-access demonstration with the fleet rotation procedure, the alert definitions including cardinality and drift, the retention cost model with four cascades and the ratio, and both upgrade plans.
# ==================================================================
# AUTHENTICATION: check whether it is ON first.
# ==================================================================
# 2.x - API TOKENS with scopes, against an organisation:
# influx auth create --org acme \
# --description "press-07 writer" \
# --write-bucket $RAW_BUCKET_ID
# influx auth list --org acme
#
# 3.x Core/Enterprise:
# influxdb3 create token --admin
# influxdb3 create token --name dashboard --permission "db:telemetry_1h:read"
#
# In every case *** A TOKEN IS A BEARER CREDENTIAL IN A HEADER ***,
# so it LEAKS LIKE ANY OTHER. The controls are SCOPING, ROTATION and
# TRANSPORT SECURITY - there is nothing else.
#
# Authorization: Token <token> (2.x)
# Authorization: Bearer <token> (3.x)
# *** DEMONSTRATE WHAT AN UNAUTHENTICATED INSTANCE COSTS. *** In an
# ISOLATED LAB NETWORK, start one with auth disabled and, from
# another container with no credentials:
# write points, read every measurement, DROP a measurement.
# Then enable it and show the same refused:
# {"code":"unauthorized","message":"unauthorized access"}
# ==================================================================
# *** TOKEN SCOPING IS WHERE LEAST PRIVILEGE LIVES. ***
# ==================================================================
# A DEVICE - WRITE ONLY, to ONE bucket, and NO READ:
# influx auth create --org acme \
# --description "fleet-plant-a writer" \
# --write-bucket $RAW_BUCKET_ID
#
# A DASHBOARD - READ ONLY, on the ROLLUP buckets:
# influx auth create --org acme --description "grafana" \
# --read-bucket $ROLLUP_1M_ID \
# --read-bucket $ROLLUP_1H_ID \
# --read-bucket $ROLLUP_1D_ID
# -> it cannot read RAW data, and cannot write anything.
#
# THE ROLLUP TASK - read raw, write rollups:
# influx auth create --org acme --description "downsampler" \
# --read-bucket $RAW_BUCKET_ID \
# --write-bucket $ROLLUP_1M_ID --write-bucket $ROLLUP_1H_ID
#
# MONITORING - no data access:
# influx auth create --org acme --description "monitor" \
# --read-telegrafs --read-buckets # metadata only, per version
#
# VERIFY THE DENIALS - every one must fail:
# device token reading any bucket -> unauthorized
# device token writing to a rollup -> unauthorized
# dashboard token writing anything -> unauthorized
# dashboard token reading the RAW bucket -> unauthorized
# rollup token creating a token -> unauthorized
# any of them deleting a bucket -> unauthorized
# *** THE ALL-ACCESS ANTI-PATTERN. *** Demonstrate it, because the
# demonstration is what makes the scoping worth the effort:
# influx auth create --org acme --all-access
# -> ONE token that can read every bucket, DELETE A MEASUREMENT,
# create more tokens, and change retention.
#
# *** AND IT IS THE EASIEST THING TO DO: one token in every device's
# *** firmware. WHICH IS AN UNRECOVERABLE POSITION, BECAUSE ROTATING
# *** IT MEANS REFLASHING THE FLEET. *** Write that rotation
# procedure out; the uncomfortable part is the point.
# *** THE PRACTICAL DESIGN FOR A DEVICE FLEET: ***
# PER-DEVICE token ideal; operationally heavy (provisioning,
# revocation, a registry)
# PER-SITE or PER-FLEET the usual compromise: write-only, one
# write-only token bucket, revocable per site
# ALL-ACCESS everywhere *** never ***
#
# *** A TOKEN THAT CAN ONLY WRITE, TO ONE BUCKET, LIMITS A
# *** COMPROMISED DEVICE TO WRITING NONSENSE INTO A BUCKET YOU CAN
# *** IDENTIFY *** - a very different incident from one that can read
# your whole history. That sentence is the security review.
# ==================================================================
# TLS
# ==================================================================
# influxd --tls-cert=/etc/ssl/influx.crt --tls-key=/etc/ssl/influx.key
# or terminate at a proxy.
#
# *** THE POINT FOR TELEMETRY: devices on untrusted networks sending
# *** CREDENTIALS IN A HEADER need transport security, and a FLEET
# *** THAT CANNOT DO TLS NEEDS A GATEWAY THAT CAN. *** That gateway
# is then the thing holding the token, which is often a better place
# for it anyway.
# ==================================================================
# MONITORING: the InfluxDB-specific set.
# ==================================================================
# *** SERIES CARDINALITY, TRACKED OVER TIME. *** The number that
# PREDICTS FAILURE, and it must be a TREND rather than a
# one-off check - it grows quietly, and the day it matters you
# want the graph:
# 2.x: SHOW SERIES CARDINALITY ON telemetry (on a schedule)
# 3.x: SELECT COUNT(*) FROM (SELECT DISTINCT <tags> FROM ...)
#
# write throughput (points/s)
# *** WRITE ERRORS, SEPARATING REJECTIONS FROM FAILURES: ***
# a FIELD TYPE CONFLICT -> a CLIENT BUG. Fix the writer.
# a 429 / timeout -> a CAPACITY problem. Different fix.
# Conflating them sends you to the wrong place.
#
# *** POINTS BEYOND THE LATENESS WINDOW *** (Module 3) - the only
# signal that your lateness policy is wrong.
# *** ROLLUP DRIFT *** (Module 3's detection query, scheduled) -
# the only signal that a rollup disagrees with its source.
#
# query latency p95/p99
# *** THE RATE OF QUERIES WITHOUT A TIME RANGE *** - a LEADING
# INDICATOR of a dashboard problem, before it becomes a timeout.
# storage growth vs retention - *** so you can see expiry WORKING. ***
# A storage graph that only rises means retention is not applying.
# 2.x: *** THE IN-MEMORY INDEX SIZE *** - the resource cardinality
# consumes, and the one that ends the deployment.
# compaction backlog / queue depth
# replication queue depth (Module 5) - your RPO
# ==================================================================
# *** RETENTION IS THE DOMINANT COST. This is the module's most
# *** practical content. ***
# ==================================================================
# storage ~= points/s x bytes/point (COMPRESSED) x retention
# summed over EVERY retention level
#
# measured: 2.1 bytes/point compressed at raw resolution
# (from Module 4 - use YOUR number, not this one)
#
# CASCADE A - naive. Raw for a year:
# raw 900,000/s x 2.1 B x 365 d = 51.6 TB
# TOTAL 51.6 TB
#
# CASCADE B - raw 7 days, then rollups:
# raw 900,000/s x 2.1 B x 7 d = 1.0 TB
# 1m 15,000/s x 2.4 B x 90 d = 0.28 TB
# 1h 250/s x 2.6 B x 730 d = 0.04 TB
# 1d 10.4/s x 2.8 B x 3650 d = 0.01 TB
# TOTAL 1.33 TB
#
# *** A FACTOR OF 39, AND EVERY QUERY A DASHBOARD ACTUALLY RUNS
# *** STILL WORKS. ***
#
# CASCADE C - raw 1 day: 0.15 + 0.33 TB = 0.48 TB
# CASCADE D - raw 30 days: 4.4 + 0.33 TB = 4.73 TB
#
# *** SO THE RETENTION POLICY IS THE COST MODEL, AND ARGUING ABOUT
# *** INSTANCE SIZES BEFORE SETTLING THE RETENTION CASCADE IS
# *** ARGUING ABOUT THE WRONG THING. ***
#
# And state the two numbers that follow from it:
# "raw data is available for 7 days at 1-second resolution;
# beyond that, 1-minute resolution for 90 days, 1-hour for 2
# years, 1-day for 10 years."
# "a question that needs 1-second resolution from 3 months ago
# cannot be answered. That is a deliberate choice and it saves
# 50 TB."
# The second sentence is the one stakeholders need to agree to, and
# the one they are never shown.
# ==================================================================
# UPGRADES AND COMPATIBILITY
# ==================================================================
# WITHIN 2.x: minor upgrades are routine. Back up first; read the
# notes; restart.
#
# *** BETWEEN 2.x AND 3.x THERE IS NO IN-PLACE UPGRADE. *** The
# storage engines and query languages differ. The migration is:
# 1. export the data (line protocol, or a bulk path)
# 2. load it into 3.x
# 3. *** REWRITE EVERY FLUX QUERY AS SQL ***
# 4. *** REWRITE EVERY FLUX TASK as a scheduled SQL job ***
# 5. re-point every dashboard and every writer
# 6. re-verify the rollups against the raw data
#
# *** THAT IS A PROJECT, NOT AN UPGRADE. *** So the generation choice
# in Module 1 is a LONG-LIVED COMMITMENT, and the honest way to plan
# a 2.x deployment is to KNOW WHAT THE EVENTUAL MOVE COSTS - count
# your Flux queries and tasks now, because that count is the
# estimate.
Discussion
No questions on this topic yet. Sign in to ask the first one.