InfluxDB
InfluxDB is a time series database written in Go. This page contains notes relating to InfluxDB 2.x. My older notes on InfluxDB 1.x has been moved.
Introduction
InfluxDB 2.x integrates the TICK stack (Telegraf, InfluxDB, Chronograf, Kapacitor) into one binary.
Installation and migration from InfluxDB 1.x
I had an existing InfluxDB 1.x dataset which I want to migrate to InfluxDB 2.x. The upgrade is automatically triggered by the official docker image if it detects 1.x data but no 2.x data. You must also mount /var/lib/influxdb2 as that will be where the migrated data as well as any new data will be written to.
I used the following docker-compose when I first did the migration.
services:
influxdb:
image: influxdb:2.0.7
hostname: influxdb
networks:
- influxnet
- traefik
expose:
- "8086"
restart: always
volumes:
- /var/volumes/influx/influxdb:/var/lib/influxdb
- /var/volumes/influx/influxdb2:/var/lib/influxdb2
- /var/volumes/influx/config/influxdb.conf:/etc/influxdb/influxdb.conf
- /var/volumes/influx/types.db:/usr/share/collectd/types.db
environment:
DOCKER_INFLUXDB_INIT_USERNAME: admin
DOCKER_INFLUXDB_INIT_PASSWORD: AdminPassword1
DOCKER_INFLUXDB_INIT_ORG: home
DOCKER_INFLUXDB_INIT_BUCKET: initial
DOCKER_INFLUXDB_INIT_MODE: upgrade
Once the migration is complete, you can remove the INIT environment variables and the old influxdb volume.
Tasks
Importing data from one bucket to another
I had Telegraf data written to a Telegraf databse. However, InfluxDB 2.x uses the collectd bucket. To import old Telegraf data to the new bucket, you can use the following flux query.
from(bucket: "telegraf/autogen")