'Telegraf cannot connect to RabbitMQ
I am trying to set up telegraf to collect sensor data from my RabbitMQ and forward it into two different InfluxDBs.
However, I am not able to get the connection between RabbitMQ and Telegraf working:
[inputs.rabbitmq] Error in plugin: Get "http://localhost:15672/api/exchanges": dial tcp 127.0.0.1:15672: connect: connection refused
Opening 127.0.0.1:15672 in my webbrowser works, after intial authentication. Doing a
curl -u test:test 'http://localhost:15672/api/queues/'
yields a proper looking output.
Telegraf config:
[[inputs.rabbitmq]]
## Management Plugin url. (default: http://localhost:15672)
url = "http://localhost:15672"
## Tag added to rabbitmq_overview series; deprecated: use tags
# name = "rabbitmq"
## Credentials
username = "test"
password = "test"
My RabbitMQ instance is set up with docker compose, here is the snippet:
version: '3.7'
services:
rabbitmq:
image: rabbitmq:3.9.7-management-alpine
restart: always
ports:
- '15672:15672'
- '5672:5672'
networks:
- testnet
Telegraf was set up with:
docker run -d --name=telegraf -v ${PWD}:/var/lib/influxdb --net=testnet telegraf:latest
The telegraf set up was based on an official guideline from the Influx team. I realize that my telegraf.conf file cannot be stored in ${PWD}, so I always copied my modified file into the docker container to /etc/telegraf/telegraf.conf. I know that the correct config file is used based on different log output from changes.
I have checked docker network inspect testnet and can verify that all containers run in the same network.
I have no more ideas left, why my connection is constantly refused....
Any help is appreciated!
Best regards
Solution 1:[1]
I can get the connection to work if you remove the network flag. Is there a reason you need to use a network? I am getting 401's unauthorized now but nonetheless it's accessible.
version: '3.7'
services:
rabbitmq:
image: rabbitmq:3.9.7-management-alpine
restart: always
ports:
- '15672:15672'
- '5672:5672'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Kevin |
