czerwonk / bird_exporter

Bird protocol state exporter for bird routing daemon to use with https://prometheus.io/
MIT License
173 stars 45 forks source link

Add support for sinceEpoch field in bfd session #97

Closed unixsurfer closed 10 months ago

unixsurfer commented 11 months ago

I noticed that there are no metrics for BFD sessions and found out that latest version of bird_exporter can not match the lines because Bird nows has another field with Unix epoch, see 1697620076 in below output

[xxx@node01 ~] (@coxz) $ sudo birdc show bfd session
BIRD 2.13.1 ready.
bfd1:
IP address                Interface  State      Since         Interval  Timeout
110.140.101.2               eth0       Down       2023-10-18 11:07:56 1697620076    1.000    0.000
110.140.101.1               eth0       Down       2023-10-18 11:07:56 1697620076    1.000    0.000

This my first Golang commit but I tried to fix it by adding support for that new field in a a way that it does not break the old output from Bird.

With this change I see BFD metrics but the uptime_seconds metric has value 0 and I don't know if it is due to my change or not; I don't have older versions of Bird to see if without the commit and with the older output that metric has a correct value.

$ curl -s http://127.0.0.1:9324/metrics |grep ^bird_bfd_session_up
bird_bfd_session_up{interface="eth0",ip="110.140.101.1",name="bfd1"} 0
bird_bfd_session_up{interface="eth0",ip="110.410.101.2",name="bfd1"} 0
bird_bfd_session_uptime_seconds{interface="eth0",ip="110.140.101.1",name="bfd1"} 0
bird_bfd_session_uptime_seconds{interface="eth0",ip="110.140.101.2",name="bfd1"} 0