In my telegraf config there is no specific DNS set so I would assume my system’s DNS settings apply. Yet, in my syslog I discover that during boot the telegraf service tries to resolve the address of my influxdb host using Google’s DNS:
Jun 29 12:17:28 XXXX telegraf[484]: 2021-06-29T10:17:28Z E! [outputs.influxdb] When writing to [http://influxdb.lan:8086]: failed doing req: Post "http://influxdb.lan:8086/write?db=rpi_monitoring": dial tcp: lookup influxdb.lan on 8.8.8.8:53: dial udp 8.8.8.8:53: connect: network is unreachable
Is this hardcoded somewhere and can it be disabled without having to explicitly enter a DNS server?
Hm, I’m not seeing anything that would cause this in telegraf itself, but perhaps one of the modules we pull in reverts to a known dns server. Will need some more investigation. Please bear with me.
The dns_query input plugin’s sample config uses 8.8.8.8 as DNS server. @giddyhup are you using the dns_query plugin? If so, do you have 8.8.8.8 in your telegraf.conf? This shouldn’t affect how the influxdb output uses DNS, but maybe it’s worth checking.
The other hits in your grep results are in unit tests or documentation and don’t affect how telegraf works.
Like you noticed, the telegraf output you included shows it was the influxdb output plugin trying to connect to its server that caused the DNS lookup. This code uses golang’s built-in http.Client (https://golang.org/pkg/net/http/#Client) to talk to the influxdb server. There is no extra code in the influxdb output plugin that changes the DNS server from the system default.
I think it’s more likely that your system is telling telegraf to use 8.8.8.8. Are other programs on this system using 8.8.8.8, possibly only during startup? Could you double check your /etc/resolv.conf and your network or DHCP settings?