telegraf icon indicating copy to clipboard operation
telegraf copied to clipboard

Pdns_recursor plugin fails collection with I/O timeout

Open levithanius opened this issue 5 years ago • 6 comments

Relevant telegraf.conf:

[[inputs.powerdns_recursor]]
  unix_sockets = ["/var/run/pdns/pdns_recursor.controlsocket"]
  socket_dir = "/var/run/pdns/"
  socket_mode = "0666"

System info:

OS: Debian 10 buster Telegraf: 1.19.0-1 pdns-recursor: 4.5.2-1pdns.buster

Steps to reproduce:

Everything has been set up according to the manuals, no data is been sent to the InfluxDB.

(Same procdure as stated here: https://community.influxdata.com/t/pdns-recursor-plugin-fails-collection-with-i-o-timeout/19759)

Trying sudo -u telegraf rec_control get-all works, but when started normally in daemon mode, we get i/o timeouts.

Actual behavior:

Jul 12 17:29:35 pdns-rec02 telegraf[80265]: 2021-07-12T15:29:35Z E! [inputs.powerdns_recursor] Error in plugin: read unixgram /var/run/pdns/pdns_recursor_telegraf2809338431652061292->/var/run/pdns/pdns_recursor.controlsocket: i/o timeout

Additional info:

As mentioned in the influxdata link above, maybe this has something to do with the inserted newline?

Received rec_control command 'get-all
' from control socket

levithanius avatar Jul 13 '21 08:07 levithanius

The only problem is with the documentation, the plugin itself is fine (I had the same problem as you, but I got it working with Telegraf 19.1 and PDNS Recursor 4.4.3).

Telegraf config:

[[inputs.powerdns_recursor]]
  unix_sockets = ["/var/run/pdns-recursor/pdns_recursor.controlsocket"]
  socket_dir = "/var/run/telegraf-pdns-recursor"
  socket_mode = "0666"
  interval = "1m"

Recursor's config: socket-mode = 660

telegraf is added to pdns-recursor group:

[root@server]# grep pdns-recursor /etc/group
pdns-recursor:x:992:telegraf

telegraf-pdns-recursor folder:

[root@lab-eu-1a-0504-h12 run]# ls -lH /var/run | grep telegraf-pdns-r
drwxrwx--x  2 root          pdns-recursor   40 Jul 21 18:34 telegraf-pdns-recursor

d-mankowski-samsung avatar Jul 21 '21 18:07 d-mankowski-samsung

I'm still getting the i/o timeout.

The only thing I was missing from your Telegraf config was interval = "1m" Using this made no difference, the error just appears a bit later.

We are using the pdns user instead of a dedicated pdns-recursor user:

root@server:/run # grep pdns /etc/group
pdns:x:115:telegraf

The folder permissions are also the same:

root@server:/run # ll /var/run/ | grep pdns
drwxrwx--x  2 pdns      pdns       80 Jul 22 09:34 pdns

In the past this exact configuration was working. The problem exists since updating pdns-recursor to 4.5.x and telegraf to 1.19.x.

levithanius avatar Jul 22 '21 07:07 levithanius

@levithanius looks like PowerDNS changed how the socket control protocol works in 4.5.0. I have implemented a fix and sent a PR which you can grab from here: https://github.com/influxdata/telegraf/pull/9633

If you want to use this for yourself just build it and set new_control_protocol to true in your telegraf config for the powerdns_recursor input.

OrfeasZ avatar Aug 16 '21 19:08 OrfeasZ

Actually looks like the build bot automatically build artifacts for different platforms, so you could probably just use those.

OrfeasZ avatar Aug 16 '21 20:08 OrfeasZ

@OrfeasZ works like a charm! Thank you so much!

levithanius avatar Aug 18 '21 07:08 levithanius

Are there any plans to fix this in a Telegraf release? I see it wasn't included in 1.21.0.

ajoergensen avatar Dec 17 '21 09:12 ajoergensen