INFLUXDB CHEAT SHEET

Time Series Database
v1.0
Installation
  • brew install influxdbmacOS
  • apt install influxdb2Ubuntu/Debian
  • docker run influxdbDocker
  • Default: :8086HTTP API port
CLI Commands
  • influx setupInitial setup
  • influx configManage configs
  • influx bucket listList buckets
  • influx org listList organizations
  • influx queryExecute Flux query
  • influx writeWrite data
Concepts
  • BucketData container
  • MeasurementTable equivalent
  • TagIndexed metadata
  • FieldActual values
  • PointSingle data record
Line Protocol
# Format: # measurement,tags fields timestamp cpu,host=server01,region=us-west usage=64.5 1609459200000000000 temp,location=room1 value=23.5,humidity=45 http,method=GET,status=200 latency=0.234
Flux Query Basics
// Basic query structure from(bucket: "my-bucket") |> range(start: -1h) |> filter(fn: (r) => r._measurement == "cpu") |> filter(fn: (r) => r._field == "usage") |> filter(fn: (r) => r.host == "server01") |> mean()
Flux Aggregations
// Aggregate every 5 minutes from(bucket: "metrics") |> range(start: -24h) |> filter(fn: (r) => r._measurement == "http_requests") |> aggregateWindow(every: 5m, fn: mean) // Group by tag |> group(columns: ["host", "region"]) |> sum()
Flux Functions
  • mean()Average
  • sum()Total
  • count()Count records
  • min() / max()Min/max value
  • first() / last()First/last record
  • derivative()Rate of change
  • movingAverage()Moving average
Time Ranges
  • -1hLast hour
  • -7dLast 7 days
  • -30dLast 30 days
  • 2023-01-01T00:00:00ZAbsolute time
  • start: -1h, stop: now()Time window
HTTP API Examples
# Write data curl -X POST "http://localhost:8086/api/v2/write?org=myorg&bucket=mybucket" \ -H "Authorization: Token $TOKEN" \ -d 'cpu,host=server01 usage=64.5' # Query data curl -X POST "http://localhost:8086/api/v2/query?org=myorg" \ -H "Authorization: Token $TOKEN" \ -H "Content-Type: application/vnd.flux" \ -d 'from(bucket:"mybucket") |> range(start:-1h)'
InfluxQL (v1.x)
-- Select with time range SELECT mean("value") FROM "cpu" WHERE time > now() - 1h GROUP BY time(5m)
Retention Policies
  • 0 (infinite)Never delete
  • 24hKeep 24 hours
  • 7dKeep 7 days
  • 30dKeep 30 days

Read a results file — free, in your browser

Open a JMeter .jtl, k6 JSON or Gatling simulation.log and get the report.

All 51 cheat sheets

Free to read and free to print — no signup. Want them as A4 PDFs you can print? Get all 51 as a PDF bundle for £14.99.
A Martkos IT reference sheet · Blog · Free tools