Skip to content

InfluxDB for Mere Mortals

Most databases are built for facts that change: a customer's address, the price of a book. Some data is not like that. It is measurements: the temperature every ten minutes, the load on a server every five seconds, the water level every hour. Measurements are never edited and rarely read one at a time — they are written in a steady stream and read back as questions about time: what was the average last night, when did it peak, how fast is it rising. InfluxDB is a database shaped for exactly that. It stores points — a value, its labels, and the moment it was true — and answers questions in a language built around time ranges and windows.

This guide installs InfluxDB 2.9.1 from the project's official binaries, sets it up from the command line, and feeds it an invented weather station: two sensors reporting temperature and humidity every ten minutes. Against that small, honest dataset the lab writes points in line protocol, reads them back with Flux queries, averages them into windows, keeps a second bucket that forgets after a day, mints a read-only token and proves what it cannot do, drives everything a second time through the raw HTTP API, runs a scheduled task that keeps summaries fresh, and then does the thing guides too often skip: it backs the database up and restores the backup into an empty server, traps and all, and counts the data to prove it came back.

One warning belongs on the first page, because everything else depends on it: InfluxDB is guarded by tokens, and a token is a bearer secret — whoever holds one holds exactly the permissions it carries, no questions asked. The token from the first setup can do everything. Chapter 7 is about handling tokens with the care passwords get. The lab's own tokens belonged to a throwaway instance on a loopback port and were destroyed with it; yours deserve a password manager, not a sticky note.

What the lab could not do, it did not fake. The pretty web interface was served by the lab's server and answered its health checks, but clicking through it is taught from the documentation and labelled as such. Data expiring quietly as it ages past a bucket's retention is likewise documented behaviour — a lab cannot wait a day to watch it — while the write-side of retention, which refuses too-old points on the spot, was run and is quoted word for word. criteria.md keeps the full ledger.

What this guide covers

  • What InfluxDB is — the mental model: points, measurements and time, and why a stream of readings wants a different database
  • The moving parts — the server, the organisations and buckets that hold data, tags and fields, the CLI, and the API — and which part holds what
  • Installing and first setup — the official binaries, a server bound to your chosen port, and the non-interactive setup that creates the first user, organisation and bucket
  • Writing data — line protocol — the one-line-per-point format read field by field, precision, the four field types, and the write that looks hung but is only listening to stdin
  • Querying with Flux — ranges and filters, tables and series, windowed averages with aggregateWindow, and summaries with mean and max
  • Buckets and retention — a bucket per purpose, a retention rule per bucket, and the 422 error that refuses a point older than its bucket allows
  • Tokens and permissions — the all-powerful operator token, the scoped token that can read one bucket and nothing else, and the three status codes that prove it
  • The HTTP API — the same writes and queries with nothing but curl: 204, CSV answers, and error messages that quote your own line back at you
  • Tasks — keeping summaries fresh — a Flux script the server runs on a schedule, writing ten-minute means into their own bucket forever
  • Backup and restore — the built-in backup, and a full restore into an empty server — including the halfway restore the lab caused and how it was finished
  • Recipes — a second station joins, correcting a wrong reading by overwriting it, deleting by predicate, and a daily summary bucket
  • The neighbours — Prometheus, the SQL databases, the other time-series stores, and InfluxDB 3, the successor generation
  • Limits — one node in the open-source build, retention as the only forgetting, cardinality, the Flux learning curve, and v2's place now that v3 exists
  • Troubleshooting — the write that waits for stdin, the token that stops halfway through a restore, 401 versus 403 versus 404, and the error that is a compliment
  • Glossary — the terms, collected in one place

What it doesn't cover

InfluxDB 3 — the current generation, rewritten around SQL and InfluxQL — is a different tool wearing the same name; chapter 12 explains the relationship, and this guide's tool is v2 throughout. The web interface's dashboards, alerts and notebooks are described from the documentation, not clicked through. Telegraf, the collecting agent that often feeds InfluxDB, gets a mention where it belongs and no more: this guide writes its own points, so you can see every byte that goes in. Clustered, commercial InfluxDB is out of scope — the open-source server is one node, and chapter 13 is plain about what that means.

How to use this guide

Read chapter 1 for the model and chapter 2 before installing anything — knowing which part holds what turns later surprises into named problems. Chapters 3 to 5 give you a running server with data in it and questions answered. Chapters 6 to 8 are the operating discipline: retention, tokens, and the API underneath the CLI. The lab's transcripts live in influxdb-lab/transcripts/; its fixture generator is influxdb-lab/gen-weather.py and its task script is influxdb-lab/task.flux.


Part of the series

This guide is one of the For Mere Mortals guides: plain-language guides to the tools programmers and makers use.

Related guides:

License

The writing in this guide is licensed under CC BY 4.0. Code examples and lab scripts are licensed under the MIT License.