InfluxDB in docker-compose not able to allow connections

3k views Asked by At

I am trying to set up TICK-Stack together with RabbitMQ in docker-compose, but I fail on connecting anything to InfluxDB. Whatever I try I always get a connection refused error. Can someone explain to me how to set this stack up so it works?

What I also saw, is that when I create the container for the first time, that there is no new database created. Is there an issue with the official container?

docker-compose.yml

version: '3'
services:
  rabbitmq:
    build: .
    image: mqtt-rabbitmq
    environment:
      - RABBITMQ_ERLANG_COOKIE=${RABBITMQ_ERLANG_COOKIE}
      - RABBITMQ_DEFAULT_USER=${RABBITMQ_DEFAULT_USER}
      - RABBITMQ_DEFAULT_PASS=${RABBITMQ_DEFAULT_PASS}
      - RABBITMQ_DEFAULT_VHOST=${RABBITMQ_DEFAULT_VHOST}
    ports:
      - "15672:15672"
      - "5672:5672"
      - "1883:1883"
  influxdb:
    image: influxdb:1.7-alpine
    environment:
      - AUTH_ENABLED=false
      - INFLUXDB_HTTP_AUTH_ENABLED=false
      - INFLUXDB_ADMIN_USER=telegraf
      - INFLUXDB_ADMIN_PASSWORD=telegraf
      - INFLUXDB_DB=telegraf
    volumes:
      - ./influxdb/data:/var/lib/influxdb
      - ./influxdb/config/:/etc/influxdb/
    ports:
      - "8086:8086"
      - "8082:8082"
      - "8089:8089/udp"
  telegraf:
    image: telegraf:1.11-alpine
    environment:
      HOSTNAME: "telegraf-getting-started"
    links:
      - influxdb
    volumes:
      - ./telegraf.conf:/etc/telegraf/telegraf.conf:ro
      - /var/run/docker.sock:/var/run/docker.sock
    depends_on:
      - rabbitmq
      - influxdb
  kapacitor:
    image: kapacitor:1.5-alpine
    volumes:
      - ./kapacitor/data/:/var/lib/kapacitor
      - ./kapacitor/config/:/etc/kapacitor/
    links:
      - influxdb
    ports:
      - "9092:9092"
  chronograf:
    image: chronograf:1.7-alpine
    environment:
      RESOURCES_PATH: "/usr/share/chronograf/resources"
    volumes:
      - ./chronograf/data/:/var/lib/chronograf/
    links:
      - influxdb
      - kapacitor
    ports:
      - "8888:8888"
    depends_on:
      - kapacitor
      - influxdb
      - telegraf

telegraf.conf

[global_tags]
dc = "localhost"
[agent]
interval = "1s"
debug = true
# OUTPUTS
[[outputs.influxdb]]
url = "http://localhost:8086"
database = "telegraf"
precision = "ns"
# INPUTS
[[inputs.cpu]]
percpu = true
totalcpu = false
fielddrop = ["time_*"]
[[inputs.mqtt_consumer]]
name_prefix = "influx"
servers = ["tcp://rabbitmq:1883"]
qos = 0
connection_timeout = "30s"
topics = [
  "test",
]
persistent_session = false
client_id = ""
username = "rabbitmq"
password = "rabbitmq"
data_format = "json"
json_string_fields = ["symbol"]
1

There are 1 answers

0
Stephane Martin On

Try changing your influx image to the following one

  influxdb:
    image: quay.io/influxdb/influxdb:v2.0.3
    container_name: influxdb
    restart: always
    networks:
      - monitoring
    environment:
      - INFLUXDB_DB=telegraf
      - INFLUXDB_USER=telegraf
      - INFLUXDB_ADMIN_ENABLED=true
      - INFLUXDB_ADMIN_USER=admin
      - INFLUXDB_ADMIN_PASSWORD=admin
    volumes:
      - ./influxdb/data:/var/lib/influxdb
      - ./influxdb/config/:/etc/influxdb/
    ports:
      - "8086:8086"
      - "8082:8082"
      - "8089:8089/udp"