nshttpd / mikrotik-exporter

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

Netwatch status missing for hosts that do not have `disabled` field set #148

Open knyar opened 2 years ago

knyar commented 2 years ago

I am using mikrotik-exporter to collect metrics from a RB4011iGS+5HacQ2HnD router running RouterOS 7.4.

When I add a new netwatch host, its status does not get exported:

$ ssh 10.11.12.1 '/tool/netwatch add host=1.1.1.1'
$ curl -s localhost:11223/metrics | grep 1.1.1.1
$ 

Explicitly setting disabled=no fixes this:

$ ssh 10.11.12.1 '/tool/netwatch set disabled=no [find host=1.1.1.1]'
$ curl -s localhost:11223/metrics | grep 1.1.1.1
mikrotik_netwatch_status{address="10.11.12.1",comment="",host="1.1.1.1",name="router"} 1
$

It seems that ?disabled=false condition does not hold true if disabled field is not set at all. Is this expected?

Silently omitting data from exported metrics does not seem like a great default. Would it make sense to remove the ?disabled=false condition while querying data via the API and either exclude disabled hosts in the exporter, or maybe just expose disabled as a separate metric label?

I will be happy to prepare a PR for this.