nshttpd / mikrotik-exporter

prometheus mikrotik device(s) exporter
BSD 3-Clause "New" or "Revised" License
558 stars 153 forks source link

Issues with current DNS SRV implementation #127

Open laurivosandi opened 3 years ago

laurivosandi commented 3 years ago

There is no documentation how to configure the SRV records, but using the scheme that I had used in the past and which does in fact work with Prometheus native DNS SRV discovery dns_sd_configs I get following errors:

{"level":"info","msg":"setting up collector for devices","numDevices":1,"time":"2021-11-14T07:01:40Z"}
{"level":"info","msg":"Listening on :9436","time":"2021-11-14T07:01:40Z"}
{"device":"routers_srv_dns","error":"dial tcp :8728: connect: connection refused","level":"error","msg":"error dialing device","time":"2021-11-14T07:01:56Z"}
{"level":"error","msg":"ERROR: routers_srv_dns collector failed after 0.000418s: dial tcp :8728: connect: connection refused","time":"2021-11-14T07:01:56Z"}

Zonefile contents:

$ORIGIN example.com.
_mikrotik._tcp          SRV     0 100 8728 router1
                        SRV     0 100 8728 router2
                        SRV     0 100 8728 router3
router1              A       192.168.0.1
router2              A       192.168.0.2
router3              A       192.168.0.3

Exporter configuration:

    devices:
      - name: routers_srv_dns
        user: netpoller
        password: "123456"
        srv:
          record: _mikrotik._tcp.example.com

Instead of reinventing the DNS SRV discovery in your exporter, I would rather have you drop the homebrew code and reuse Prometheus native DNS SRV discovery as described in #126

Also looks like DNS failover will not ever work: https://github.com/nshttpd/mikrotik-exporter/blob/4bfa7adfef500ff621a677adfab1f7010af920d1/collector/collector.go#L253