Hello.
I am running InfluxDB 2 and Telegraf using Docker Compose and it seems Telegraf fails to work with InfluxDB 2.
telegraf_1 | 2021-03-16T00:00:00Z E! [outputs.influxdb_v2] when writing to [http://influxdb:8086]: Post "http://influxdb:8086/api/v2/write?bucket=test-bucket&org=test-org": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
telegraf_1 | 2021-03-16T00:00:00Z E! [agent] Error writing to outputs.influxdb_v2: Post "http://influxdb:8086/api/v2/write?bucket=test-bucket&org=test-org": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
The configuration files for InfluxDB 2 and Telegraf are loaded succesfully. DOCKER_INFLUXDB_INIT_*
works as expected. When I visit ${IP}:8086
, InfluxDB 2 has been setup correctly. Token is active with full access permissions and it has been set in telegraf.conf
.
I have no idea why is that. Can anyone give me some hints?
Thanks.
docker-compose.yml:
version: '3'
services:
postgres:
container_name: test_postgres
image: postgres:alpine
restart: always
environment:
POSTGRES_USER: ${POSTGRES_USER}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
volumes:
- postgres:/var/lib/postgresql
ports:
- 5432:5432
influxdb:
container_name: test_influxdb
image: influxdb:2.0-alpine
restart: always
environment:
INFLUXDB_ADMIN_USER: ${INFLUXDB_ADMIN_USER}
INFLUXDB_ADMIN_PASSWORD: ${INFLUXDB_ADMIN_PASSWORD}
DOCKER_INFLUXDB_INIT_MODE: setup
DOCKER_INFLUXDB_INIT_USERNAME: ${INFLUXDB_USERNAME}
DOCKER_INFLUXDB_INIT_PASSWORD: ${INFLUXDB_PASSWORD}
DOCKER_INFLUXDB_INIT_ORG: test-org
DOCKER_INFLUXDB_INIT_BUCKET: test-bucket
DOCKER_INFLUXDB_INIT_ADMIN_TOKEN: test-token
volumes:
- influxdb:/var/lib/influxdb2
- ${PWD}/influxdb.conf:/etc/influxdb/influxdb.conf:ro
ports:
- 8086:8086
telegraf:
container_name: test_telegraf
image: telegraf:alpine
restart: always
links:
- influxdb
depends_on:
- influxdb
volumes:
- ${PWD}/telegraf.conf:/etc/telegraf/telegraf.conf:ro
ports:
- 5050:5050
volumes:
postgres: {}
influxdb: {}
telegraf.conf:
[[outputs.influxdb_v2]]
urls = ["http://influxdb:8086"]
token = "test-token"
organization = "test-org"
bucket = "test-bucket"
[[inputs.mqtt_consumer]]
servers = ["tcp://test.mosquitto.org:1883"]
topics = [
"test/#",
]
Could it be that you have to use test_influxdb
instead of influxdb
as hostname in your telegraf.conf
file, because you explicitly named the influxdb container differently using container_name: test_influxdb
?
urls = ["http://test_influxdb:8086"]
Thanks for your reply!
It looks like container_name
is irrelevant to the container’s hostname. I still get the same error.
telegraf_1 | 2021-03-16T12:41:49Z E! [agent] Error writing to outputs.influxdb_v2: Post "http://test_influxdb:8086/api/v2/write?bucket=test-bucket&org=test-org": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
telegraf_1 | 2021-03-16T12:41:54Z E! [outputs.influxdb_v2] when writing to [http://test_influxdb:8086]: Post "http://test_influxdb:8086/api/v2/write?bucket=test-bucket&org=test-org": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
Any updates on this? I’m trying to troubleshoot the exact same issue. My log entries look similar as below:
2021-04-12T03:13:46Z E! [agent] Error writing to outputs.influxdb_v2: Post "http://hdc-gfappd1:8086/api/v2/write?bucket=telegraf%2Ftwo_months&org=wiltsegroup": dial tcp 10.10.100.107:8086: i/o timeout (Client.Timeout exceeded while awaiting headers)
2021-04-12T03:13:56Z E! [outputs.influxdb_v2] When writing to [http://hdc-gfappd1:8086]: Post "http://hdc-gfappd1:8086/api/v2/write?bucket=telegraf%2Ftwo_months&org=wiltsegroup": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
2021-04-12T03:13:56Z E! [agent] Error writing to outputs.influxdb_v2: Post "http://hdc-gfappd1:8086/api/v2/write?bucket=telegraf%2Ftwo_months&org=wiltsegroup": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
2021-04-12T03:14:01Z E! [outputs.influxdb_v2] When writing to [http://hdc-gfappd1:8086]: Post "http://hdc-gfappd1:8086/api/v2/write?bucket=telegraf%2Ftwo_months&org=wiltsegroup": context deadline exceeded (Client.Timeout exceeded while awaiting headers)
The above lines just repeat forever.
The strange thing is this is from just one client (a raspberry pi 3). I have another raspberry pi (granted this one is a raspberry pi zero w) which is working just fine.
I have noticed that I’m also unable to even access the login page for influx from the raspberry pi which seems super strange. I have Grafana running on the exact same server as Influx and am able to access Grafana from the raspberry pi without any issues. It almost seems like the port is blocked, except I know it’s not because other servers are able to enter data just fine.
If it is the same error as described in the opening thread, I still think that the hostname cannot be resolved.
If the API is accessible via the ip address but not via the hostname, what else could it be?
Maybe just a wrong hostname?
I may not be describing the error well.
So I have three machines in question: "raspberrypi, “pihole”, and “hdc-gfappd1”
hdc-gfappd1 (Ubuntu VM running on ESXi) hosts both Influx and Grafana. Pihole is a Raspberry Pi 3 and raspberrypi is a Raspberry Pi Zero W. I’m able to send data from raspberrypi to hdc-gfappd1 without issue, but I’m unable to send data from pihole to hdc-gfappd1.
I would agree with the name resolution being a potential issue, but I’m able to access Grafana at http://hdc-gfappd1:3000/ from pihole just fine. For some reason I simply cannot access Influx at http://hdc-gfappd1:8086/ from pihole (either from the web or via the Telegraf output.influx_v2 plugin).
That has me thinking it’s not the hostname. Do you have any other ideas for what I might check?
Please let me know if any of that isn’t clear and I’ll be happy to elaborate. Thanks for the help.