InfluxDB - A time series database
Summary
InfluxDB is a time series databse mostly used for sensor data. It supports APIs for data storing, querying and processing.
Installation
The easiest way to initialize influxdb is by running a docker run command with environment variables to initialize the folder structure. Don't forget to create the folder for the volumes first.
docker run -p 8086:8086 \
-v /PATH/TO/FOLDER/influxdb/data:/var/lib/influxdb2 \
-v /PATH/TO/FOLDER/config:/etc/influxdb2 \
-e DOCKER_INFLUXDB_INIT_MODE=setup \
-e DOCKER_INFLUXDB_INIT_USERNAME=USERNAME \
-e DOCKER_INFLUXDB_INIT_PASSWORD=PASSWORD \
-e DOCKER_INFLUXDB_INIT_ORG=ORGANISATION \
-e DOCKER_INFLUXDB_INIT_BUCKET=BUCKET \
influxdb:2.0
After the initialization you need to delete the docker container again. Then you can start the normal container via docker-compose.
version: "2"
services:
influxdb:
image: influxdb:2.0
ports:
- "8086:8086"
restart: always
volumes:
- /PATH/TO/FOLDER/data:/var/lib/influxdb2
- /PATH/TO/FOLDER/config:/etc/influxdb2
Data deletion
If you inserted some data wrongfully or want to delete data for any other reason, you need to execute a command in the influxdb container. Eighter run it via docker exec or just connect into the container shell via portainer. Then you can delete measurements with the following command:
influx delete --org ORGANIZATION --bucket BUCKET --start 1970-01-01T00:00:00Z --stop $(date +"%Y-%m-%dT%H:%M:%SZ") --predicate '_measurement="MEASUREMENT"'
No Comments