InfluxDB

InfluxDB is the most-deployed open-source time-series database. Designed by InfluxData (founded 2013), it is purpose-built for high-cardinality timestamped data — metrics, IoT telemetry, application traces, financial ticks, sensor readings — that arrives in heavy write streams and is queried mostly by time range plus tag filters.

1. Key Features:

2. InfluxDB vs. Other Time-Series DBs:

3. Use Cases:

4. Data model

One InfluxDB point measurement cpu tags (indexed) host=web1, region=us fields (values) usage=63.2, idle=36.8 timestamp ns precision series = measurement + tag set unit of storage and indexing

InfluxDB stores points. Each point has a measurement name (similar to a table), a set of tags (string key-value pairs that are indexed and identify the source), one or more fields (the actual measured values: floats, integers, strings or booleans, not indexed), and a timestamp. All points sharing a measurement and an identical tag set form a series. Queries filter and group on tags and aggregate fields over time windows.

The key design rule follows from this: put things you filter or group by in tags, and put things you measure in fields. The number of distinct series, called cardinality, is what drives memory and index size, so tags must have bounded value sets.

5. Write and query path

From agent to dashboard Telegraf / clientline protocol Write APIHTTP /write Storage engineWAL, compressed columns QuerySQL / InfluxQL / Flux Grafanadashboards

Data arrives as line protocol, a compact text format, usually from Telegraf (InfluxData's collection agent with several hundred input plugins) or from client libraries. Writes go to a write-ahead log and an in-memory buffer, then are persisted in compressed columnar form; timestamps compress extremely well with delta encoding, and repeated values with run-length encoding. Retention policies (or bucket retention periods) drop data older than a configured age automatically, and downsampling jobs roll raw data up into coarser aggregates for long-term storage.

The product has gone through three storage generations. 1.x used the TSM engine with InfluxQL. 2.x kept TSM and introduced buckets, tokens and the Flux language. 3.x is a rewrite in Rust on Apache Arrow, DataFusion and Parquet, uses SQL and InfluxQL as query languages, and largely removes the cardinality limits of the earlier engine; Flux is not supported there. Check which version a tutorial targets before copying queries.

6. Worked example: write and query

# line protocol: measurement,tag=..,tag=.. field=..,field=.. timestamp
cpu,host=web1,region=us-west usage=63.2,idle=36.8 1727740800000000000
cpu,host=web2,region=us-west usage=21.7,idle=78.3 1727740800000000000
from influxdb_client import InfluxDBClient, Point
from influxdb_client.client.write_api import SYNCHRONOUS

with InfluxDBClient(url="http://localhost:8086", token="TOKEN", org="acme") as c:
    w = c.write_api(write_options=SYNCHRONOUS)
    w.write(bucket="metrics",
            record=Point("cpu").tag("host", "web1").field("usage", 63.2))
-- InfluxQL (1.x, also 3.x): 5-minute average per host over the last hour
SELECT MEAN("usage") FROM "cpu"
WHERE time > now() - 1h
GROUP BY time(5m), "host";

-- SQL (3.x)
SELECT date_bin(INTERVAL '5 minutes', time) AS bucket, host, AVG(usage)
FROM cpu
WHERE time > now() - INTERVAL '1 hour'
GROUP BY bucket, host
ORDER BY bucket;

7. When to use InfluxDB versus alternatives

SystemChoose when
InfluxDBPush-based metrics and IoT/sensor data, built-in retention, Telegraf ecosystem
PrometheusPull-based Kubernetes and service monitoring with alerting rules
TimescaleDBTime series that must join with relational data in PostgreSQL
Elasticsearch / OpenSearchLogs and full-text search over events rather than numeric metrics
ClickHouseGeneral analytical SQL over very large event tables

8. Pitfalls