syepes / network_exporter

ICMP / Ping & MTR & TCP Port & HTTP Get - Network Prometheus exporter
Apache License 2.0
329 stars 59 forks source link

With version 1.7.2 and above the nameserver_timeout field is not optional, without it hosts are not resolved #41

Closed paebersold-tyro closed 1 year ago

paebersold-tyro commented 1 year ago

Hello,

With version 1.7.2 unless the (optional) config option 'nameserver_timeout' is set dns resolution will not work.

This is on Linux x86 (Suse Linux 12.5).

First test with 1.7.1 to show valid config/targets in test with nameserver_timeout commented out

# cat network_exporter.yaml
conf:
  # nameserver_timeout: 250ms # Optional

icmp:
  interval: 2s
  timeout: 1s
  count: 1
mtr:
  interval: 3s
  timeout: 500ms
  max-hops: 30
  count: 6
tcp:
  interval: 3s
  timeout: 1s
http_get:
  interval: 15m
  timeout: 5s

targets:
  - name: test
    host: jenkins-agent-5-sn.sn.tyrocorp.net
    type: ICMP
  - name: test2
    host: jenkins-agent-5-sn.sn.tyrocorp.net:22
    type: TCP

# ./network_exporter-1.7.1 --version
1.7.1

# ./network_exporter-1.7.1 --log.level=debug --config.file=network_exporter.yaml
ts=2023-10-12T05:19:58.658Z caller=main.go:56 level=info msg="Starting network_exporter" version=1.7.1
ts=2023-10-12T05:19:58.658Z caller=main.go:58 level=info msg="Loading config"
ts=2023-10-12T05:19:58.659Z caller=main.go:147 level=info msg="Configured default DNS resolver"
ts=2023-10-12T05:19:58.659Z caller=monitor_ping.go:59 level=debug type=ICMP func=AddTargets msg="Current Targets: 0, cfg: 1"
ts=2023-10-12T05:19:58.661Z caller=monitor_ping.go:80 level=debug type=ICMP func=AddTargets msg="targetName: [test 10.6.2.55]"
ts=2023-10-12T05:19:58.663Z caller=monitor_ping.go:111 level=info type=ICMP func=AddTargetDelayed msg="Adding Target: test 10.6.2.55 (jenkins-agent-5-sn.sn.tyrocorp.net/10.6.2.55) in 0s"
ts=2023-10-12T05:19:58.663Z caller=monitor_mtr.go:61 level=debug type=MTR func=AddTargets msg="Current Targets: 0, cfg: 0"
ts=2023-10-12T05:19:58.663Z caller=monitor_mtr.go:76 level=debug type=MTR func=AddTargets msg="targetName: []"
ts=2023-10-12T05:19:58.663Z caller=monitor_tcp.go:56 level=debug type=TCP func=AddTargets msg="Current Targets: 0, cfg: 1"
ts=2023-10-12T05:19:58.664Z caller=monitor_tcp.go:82 level=debug type=TCP func=AddTargets msg="targetName: [test2 10.6.2.55]"
ts=2023-10-12T05:19:58.668Z caller=monitor_tcp.go:128 level=info type=TCP func=AddTargetDelayed msg="Adding Target: test2 10.6.2.55 (jenkins-agent-5-sn.sn.tyrocorp.net/10.6.2.55:22) in 0s"
ts=2023-10-12T05:19:58.668Z caller=monitor_http.go:56 level=debug type=HTTPGet func=AddTargets msg="Current Targets: 0, cfg: 0"
ts=2023-10-12T05:19:58.668Z caller=monitor_http.go:71 level=debug type=HTTPGet func=AddTargets msg="targetName: []"
ts=2023-10-12T05:19:58.668Z caller=main.go:140 level=info msg="Starting ping exporter" version=1.7.1
ts=2023-10-12T05:19:58.668Z caller=main.go:141 level=info msg="Listening for /metrics on :9427"
ts=2023-10-12T05:20:01.669Z caller=target_tcp.go:95 level=debug type=TCP func=port msg="{\"success\":true,\"dest_address\":\"jenkins-agent-5-sn.sn.tyrocorp.net\",\"dest_ip\":\"10.6.2.55\",\"dest_port\":\"22\",\"src_ip\":\"10.6.2.54\",\"connection_time\":622569}"
ts=2023-10-12T05:20:02.665Z caller=target_ping.go:109 level=debug type=ICMP func=ping msg="{\"success\":true,\"dest_address\":\"jenkins-agent-5-sn.sn.tyrocorp.net\",\"dest_ip\":\"10.6.2.55\",\"drop_rate\":0,\"sum\":992409,\"best\":992409,\"avg\":992000,\"worst\":992409,\"sd\":0,\"usd\":0,\"csd\":-9223372036854775808,\"range\":0,\"snt_summary\":1,\"snt_fail_summary\":0,\"snt_time_summary\":0}"
ts=2023-10-12T05:20:04.665Z caller=target_ping.go:109 level=debug type=ICMP func=ping msg="{\"success\":true,\"dest_address\":\"jenkins-agent-5-sn.sn.tyrocorp.net\",\"dest_ip\":\"10.6.2.55\",\"drop_rate\":0,\"sum\":983380,\"best\":983380,\"avg\":983000,\"worst\":983380,\"sd\":0,\"usd\":0,\"csd\":-9223372036854775808,\"range\":0,\"snt_summary\":2,\"snt_fail_summary\":0,\"snt_time_summary\":0}"
ts=2023-10-12T05:20:04.669Z caller=target_tcp.go:95 level=debug type=TCP func=port msg="{\"success\":true,\"dest_address\":\"jenkins-agent-5-sn.sn.tyrocorp.net\",\"dest_ip\":\"10.6.2.55\",\"dest_port\":\"22\",\"src_ip\":\"10.6.2.54\",\"connection_time\":529819}"

Now test with 1.7.2

# ./network_exporter-1.7.2 --version
1.7.2

# ./network_exporter-1.7.2 --log.level=debug --config.file=network_exporter.yaml
ts=2023-10-12T05:21:16.639Z caller=main.go:56 level=info msg="Starting network_exporter" version=1.7.2
ts=2023-10-12T05:21:16.639Z caller=main.go:58 level=info msg="Loading config"
ts=2023-10-12T05:21:16.640Z caller=main.go:147 level=info msg="Configured default DNS resolver"
ts=2023-10-12T05:21:16.641Z caller=monitor_mtr.go:61 level=debug type=MTR func=AddTargets msg="Current Targets: 0, cfg: 0"
ts=2023-10-12T05:21:16.641Z caller=monitor_mtr.go:76 level=debug type=MTR func=AddTargets msg="targetName: []"
ts=2023-10-12T05:21:16.641Z caller=monitor_http.go:55 level=debug type=HTTPGet func=AddTargets msg="Current Targets: 0, cfg: 0"
ts=2023-10-12T05:21:16.641Z caller=monitor_ping.go:59 level=debug type=ICMP func=AddTargets msg="Current Targets: 0, cfg: 1"
ts=2023-10-12T05:21:16.641Z caller=monitor_http.go:70 level=debug type=HTTPGet func=AddTargets msg="targetName: []"
ts=2023-10-12T05:21:16.641Z caller=main.go:140 level=info msg="Starting ping exporter" version=1.7.2
ts=2023-10-12T05:21:16.641Z caller=main.go:141 level=info msg="Listening for /metrics on :9427"
ts=2023-10-12T05:21:16.641Z caller=monitor_tcp.go:56 level=debug type=TCP func=AddTargets msg="Current Targets: 0, cfg: 1"
ts=2023-10-12T05:21:16.641Z caller=monitor_ping.go:71 level=warn type=ICMP func=AddTargets msg="Skipping resolve target: jenkins-agent-5-sn.sn.tyrocorp.net" err="resolving target: lookup jenkins-agent-5-sn.sn.tyrocorp.net: i/o timeout"
ts=2023-10-12T05:21:16.641Z caller=monitor_ping.go:80 level=debug type=ICMP func=AddTargets msg="targetName: []"
ts=2023-10-12T05:21:16.641Z caller=monitor_tcp.go:73 level=warn type=TCP func=AddTargets msg="Skipping resolve target: jenkins-agent-5-sn.sn.tyrocorp.net:22" err="resolving target: lookup jenkins-agent-5-sn.sn.tyrocorp.net: i/o timeout"
ts=2023-10-12T05:21:16.641Z caller=monitor_tcp.go:82 level=debug type=TCP func=AddTargets msg="targetName: []"

Update config and add in nameserver_timeout option

# head -5 network_exporter.yaml
conf:
  nameserver_timeout: 250ms # Optional

icmp:
  interval: 2s

# ./network_exporter-1.7.2 --log.level=debug --config.file=network_exporter.yaml
ts=2023-10-12T05:22:11.067Z caller=main.go:56 level=info msg="Starting network_exporter" version=1.7.2
ts=2023-10-12T05:22:11.067Z caller=main.go:58 level=info msg="Loading config"
ts=2023-10-12T05:22:11.068Z caller=main.go:147 level=info msg="Configured default DNS resolver"
ts=2023-10-12T05:22:11.068Z caller=main.go:140 level=info msg="Starting ping exporter" version=1.7.2
ts=2023-10-12T05:22:11.069Z caller=main.go:141 level=info msg="Listening for /metrics on :9427"
ts=2023-10-12T05:22:11.069Z caller=monitor_ping.go:59 level=debug type=ICMP func=AddTargets msg="Current Targets: 0, cfg: 1"
ts=2023-10-12T05:22:11.070Z caller=monitor_mtr.go:61 level=debug type=MTR func=AddTargets msg="Current Targets: 0, cfg: 0"
ts=2023-10-12T05:22:11.070Z caller=monitor_mtr.go:76 level=debug type=MTR func=AddTargets msg="targetName: []"
ts=2023-10-12T05:22:11.070Z caller=monitor_tcp.go:56 level=debug type=TCP func=AddTargets msg="Current Targets: 0, cfg: 1"
ts=2023-10-12T05:22:11.070Z caller=monitor_http.go:55 level=debug type=HTTPGet func=AddTargets msg="Current Targets: 0, cfg: 0"
ts=2023-10-12T05:22:11.070Z caller=monitor_http.go:70 level=debug type=HTTPGet func=AddTargets msg="targetName: []"
ts=2023-10-12T05:22:11.071Z caller=monitor_tcp.go:82 level=debug type=TCP func=AddTargets msg="targetName: [test2 10.6.2.55]"
ts=2023-10-12T05:22:11.071Z caller=monitor_ping.go:80 level=debug type=ICMP func=AddTargets msg="targetName: [test 10.6.2.55]"
ts=2023-10-12T05:22:11.073Z caller=monitor_ping.go:111 level=info type=ICMP func=AddTargetDelayed msg="Adding Target: test 10.6.2.55 (jenkins-agent-5-sn.sn.tyrocorp.net/10.6.2.55) in 0s"
ts=2023-10-12T05:22:11.075Z caller=monitor_tcp.go:128 level=info type=TCP func=AddTargetDelayed msg="Adding Target: test2 10.6.2.55 (jenkins-agent-5-sn.sn.tyrocorp.net/10.6.2.55:22) in 0s"
ts=2023-10-12T05:22:14.076Z caller=target_tcp.go:95 level=debug type=TCP func=port msg="{\"success\":true,\"dest_address\":\"jenkins-agent-5-sn.sn.tyrocorp.net\",\"dest_ip\":\"10.6.2.55\",\"dest_port\":\"22\",\"src_ip\":\"10.6.2.54\",\"connection_time\":702514}"
ts=2023-10-12T05:22:15.078Z caller=target_ping.go:109 level=debug type=ICMP func=ping msg="{\"success\":true,\"dest_address\":\"jenkins-agent-5-sn.sn.tyrocorp.net\",\"dest_ip\":\"10.6.2.55\",\"drop_rate\":0,\"sum\":1782875,\"best\":1782875,\"avg\":1782000,\"worst\":1782875,\"sd\":0,\"usd\":0,\"csd\":-9223372036854775808,\"range\":0,\"snt_summary\":1,\"snt_fail_summary\":0,\"snt_time_summary\":0}"