Hi there,
I want to connect Telegraf and Mosquitto on Docker.
I think there’s a problem with the servers setting of mqtt_consumer, but I don’t know what it is.
- This error is set to servers=[“tcp://mosquitto:1883”]
2021-12-14T06:21:46Z I! Starting Telegraf 1.20.4
2021-12-14T06:21:46Z I! Using config file: /etc/telegraf/telegraf.conf
2021-12-14T06:21:46Z I! Loaded inputs: mqtt_consumer
2021-12-14T06:21:46Z I! Loaded aggregators:
2021-12-14T06:21:46Z I! Loaded processors:
2021-12-14T06:21:46Z I! Loaded outputs: file influxdb_v2
2021-12-14T06:21:46Z I! Tags enabled: host=3140e3d0a6a8
2021-12-14T06:21:46Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"3140e3d0a6a8", Flush Interval:10s
2021-12-14T06:21:46Z E! [telegraf] Error running agent: starting input inputs.mqtt_consumer: network Error : dial tcp 172.28.0.3:1883: connect: connection refused
- This error is set to servers=[“tcp://docker.for.mac.localhost:1883”]
2021-12-14T07:19:26Z I! Starting Telegraf 1.20.4
2021-12-14T07:19:26Z I! Using config file: /etc/telegraf/telegraf.conf
2021-12-14T07:19:26Z I! Loaded inputs: mqtt_consumer
2021-12-14T07:19:26Z I! Loaded aggregators:
2021-12-14T07:19:26Z I! Loaded processors:
2021-12-14T07:19:26Z I! Loaded outputs: file influxdb_v2
2021-12-14T07:19:26Z I! Tags enabled: host=3140e3d0a6a8
2021-12-14T07:19:26Z I! [agent] Config: Interval:10s, Quiet:false, Hostname:"3140e3d0a6a8", Flush Interval:10s
2021-12-14T07:19:26Z E! [telegraf] Error running agent: starting input inputs.mqtt_consumer: network Error : EOF
Anyone will be of help to me. Thank you.
docker-compose.yml
version: "3.8"
services:
telegraf:
container_name: telegraf0
image: telegraf
restart: always
ports:
- "5050:5050"
depends_on:
- mosquitto
- influxdb
mosquitto:
container_name: mosquitto
image: eclipse-mosquitto:latest
restart: always
ports:
- "1883:1883"
- "9001:9001"
depends_on:
- influxdb
volumes:
- mosquitto-data:/mosquitto/data
influxdb:
container_name: influx
image: influxdb
restart: always
ports:
- "8086:8086"
volumes:
- influxdb-data:/var/lib/influxdb
- ./influxdb-backup:/backup
grafana:
container_name: grafana
image: grafana/grafana
links:
- influxdb
hostname: grafana
restart: always
ports:
- "3000:3000"
volumes:
- grafana-data:/var/lib/grafana
depends_on:
- influxdb
volumes:
mosquitto-data:
influxdb-data:
grafana-data:
telegraf.conf
[agent]
interval = "10s"
round_interval = true
metric_batch_size = 1000
metric_buffer_limit = 10000
collection_jitter = "0s"
flush_interval = "10s"
flush_jitter = "0s"
precision = ""
hostname = ""
[[outputs.influxdb_v2]]
urls = ["http://influx:8086"]
token = "******************"
organization = "admin"
namepass = ["test_bucket"]
bucket = "test_bucket"
[[outputs.file]]
files = ["stdout", "/tmp/metrics.out"]
[[inputs.mqtt_consumer]]
#servers = ["tcp://docker.for.mac.localhost:1883"]
servers = ["tcp://mosquitto:1883"]
topics = [
"#",
]
qos = 0
#connection_timeout = "30s"
client_id = "telegraf"
#persistent_session = false
data_format = "influx