Hi,
Im quite new to this so maybe i express myself a bit wage
I have put up a docker system consisting of InfluxDB, Telegraf, MariaDB and Grafana.
Telegraf behavious differently is I create the telegraf.conf within influxDB or if i run the telegraf as a separat container.
If i create the config in influx the system starts up and the opcua data is getting in to the influxDB.
If I run the telegraf in a separate container, with the same telefrag.conf as i just created in bullet above, the telegraf have troubles connection to the OPCUA server.
The message: E! [telegraf] Error running agent: could not initialize input inputs.opcua: opcua: could not resolve address […]
At the moment everything is running on localhost and im using a OPCUA simulator.
Correct me if im wrong but, I think that the difference in the 2 bullets is that if the config is created in the influxDB its running in the same container as the DB, and otherwise these are separated into different containers. Is this true?
I dont really know what to ask, but maybe if there are changes needed to be done in the docker-compose.yaml to ensure that the telegraf reach the localhost?
Or what can cause the issue of not finding the same OPCUA server depending on the two different ways of creating telegraf.conf?
Hey @anton_neab! The error is telling you that something is wrong with the name resolution (DNS) in your telegraf container. The most obvious difference I see is that you don’t provide the same env to both containers, so maybe that’s a source of trouble?
I added the .env to telegraf, which i have missed.
The only thing related to the telegraf in .env was:
TELEGRAF_CFG_PATH=./telegraf.conf
OK, i think i understand.
The DNS is wrong in the telegraf container, but not in the influx container?
I specify the address in the telegraf.conf. It is able to reach the address when generaten in influx, but not seperated into its own container.
Do i somehow need to specify the DNS in the containers?
Hi @anton_neab,
So I am surprised that the specification of localhost works within the scope of the config being hosted in InfluxDB. It could be down to the fact that InfluxDB is exposed on port 8086 so brings with it the routing of the host. I don’t see this as likely unless it’s an interesting workaround of a bridge network.
To answer your question however you should assign the network: host to all containers and remove the port forwarding.
Thx for the answer!
I played around with it a bit.
Removing the port forwarding and try to go thru the network.
When adding network: host i get the respons: services.telegraf Additional property network is not allowed
Which container that compains differs
I added it as a list:
networks:
- host
Which gave the respons service “grafana” refers to undefined network host: invalid compose project
Do i need to define the network in the end of the file? How does it look?
I tried stuff like this, without success:
networks:
default:
driver: localhost
I also tried to set network_mode: host ( im not sure if thats relevant)
This start the containers as before but the same issue with accessing the input OPC.
So, no luck yet.
Do you have more ideas? Or the answer to if i need to specify the localhost-network?
Ill try to find more information about network definisions