Purpose-built for time series data.
Installation¶
docker run -d -p 8086:8086 \
-e DOCKER_INFLUXDB_INIT_MODE=setup \
-e DOCKER_INFLUXDB_INIT_USERNAME=admin \
-e DOCKER_INFLUXDB_INIT_PASSWORD=password123 \
-e DOCKER_INFLUXDB_INIT_ORG=myorg \
-e DOCKER_INFLUXDB_INIT_BUCKET=metrics \
influxdb:2.7
Writing¶
curl -X POST 'http://localhost:8086/api/v2/write?bucket=metrics' \
-H 'Authorization: Token TOKEN' \
-d 'cpu,host=server01 usage=85.5'
Flux Queries¶
from(bucket:"metrics")
|> range(start:-1h)
|> filter(fn:(r)=>r._measurement=="cpu")
|> aggregateWindow(every:5m,fn:mean)
When to Use InfluxDB¶
InfluxDB is optimized for scenarios where you write large volumes of timestamped data — server monitoring, IoT sensors, application metrics, or financial tick data. Unlike PostgreSQL, InfluxDB automatically compresses older data and allows you to set retention policies for automatic deletion after a certain period.
Flux is a functional query language that lets you chain data transformations using the pipe operator |>. You can easily create aggregations over time windows, detect anomalies, or calculate moving averages. For visualization, InfluxDB integrates seamlessly with Grafana. In production environments, we recommend setting up retention policies and continuous queries for automatic downsampling of older data.
InfluxDB for Time Series¶
More efficient than PostgreSQL for metrics and IoT.