influxdb 2

Retour

install with docker

influxdb:
        image: influxdb
        container_name: influxdb
        restart: always
        volumes:
            - ./influxdb/data:/var/lib/influxdb2
            - ./influxdb/config:/etc/influxdb2
        labels:
            - traefik.enable=true
            - traefik.http.routers.influxdb.rule=Host(`influxdb.${DOMAIN}`)
            - traefik.http.routers.influxdb.tls.certresolver=le
            - traefik.http.routers.influxdb.entrypoints=websecure
            - traefik.http.routers.influxdb.middlewares=securityheaders

create an organisation

docker exec -it influxdb influx setup

to create another bucket

docker exec -ti influxdb  influx bucket create --name mydb --org x --retention 360d
docker exec -ti influxdb  influx bucket list
docker exec -ti influxdb  influx bucket delete --name mydb --org x

to get a powerful token

docker exec -ti influxdb influx auth create -o x  --read-buckets --read-checks --read-dashboards --read-dbrps --read-notificationEndpoints --read-notificationRules --read-orgs --read-tasks --read-telegrafs --read-user --write-buckets --write-checks --write-dashboards --write-dbrps --write-notificationEndpoints --write-notificationRules --write-orgs --write-tasks --write-telegrafs --write-user

insert data :

curl -X POST "http://localhost:8086/api/v2/write?org=x&bucket=bucket&precision=s" --header "Authorization: Token xxxxxxxxxx" --data-raw "mem,host=host1 used_percent=23.43234543 1556896326"

explore data

goto https://influxdb.${DOMAIN}

delete data

docker exec -ti influxdb influx delete --org x --bucket bucket --start 1970-01-01T00:00:00Z --stop $(date +"%Y-%m-%dT%H:%M:%SZ") --predicate '_measurement="dockerupdate"'