0

i don't know how to approach my problem because i don`t find similar cases to have an example.

I want to setup influx with 2 buckets to save telegraf data but only setups with init bucket.

These are the two influxdb services in my docker composer file:

influxdb:

image: influxdb:latest

volumes:

 - ./influxdbv2:/root/.influxdbv2

environment:

# Use these same configurations parameters in your telegraf configuration, mytelegraf.conf.

 - DOCKER_INFLUXDB_INIT_MODE=setup

 - DOCKER_INFLUXDB_INIT_USERNAME=User

 - DOCKER_INFLUXDB_INIT_PASSWORD=****

 - DOCKER_INFLUXDB_INIT_ORG=org

 - DOCKER_INFLUXDB_INIT_BUCKET=data

 - DOCKER_INFLUXDB_INIT_ADMIN_TOKEN=****

ports:

  - "8086:8086"

influxdb_cli:

image: influxdb:latest

links:

 - influxdb

volumes:

# Mount for influxdb data directory and configuration

  - ./influxdbv2:/root/.influxdbv2

entrypoint: ["./entrypoint.sh"]
restart: on-failure:10

depends_on:

 - influxdb

when inits runs influxdb setup correctly but doesn`t run the script and telegraf returns 404 when trying to write to buckets.

Misil
  • 15
  • 5

1 Answers1

4

I ran into the same issue today and as far as I am aware you cannot currently initialize two buckets with the DOCKER_INFLUXDB_INIT_BUCKET environment variable.

So I created a shellscript called createSecondBucket.sh that I found in another answer for this question. It uses the influx cli to create a new bucket. The script looks like this:

#!/bin/sh

set -e
influx bucket create -n YOUR_BUCKET_NAME -o YOUR_ORG_NAME -r 0

Note that I had to change the line endings to unix (LF) to run the script without errors.

Inside my Dockerfile I added the following lines:

COPY ./createSecondBucket.sh /docker-entrypoint-initdb.d
RUN chmod +x /docker-entrypoint-initdb.d/createSecondBucket.sh

which have the effect that the script is executed after the container starts for the first time. I found this information on the MongoDB dockerhub page which you can find here under the "Initializing a fresh instance" headline.