tynany / junos_exporter

Prometheus Exporter for Junos Devices
MIT License
19 stars 8 forks source link

junos_up metric seems to be missing? #16

Closed mog01 closed 3 weeks ago

mog01 commented 1 year ago

Hi hi,

I managed to run junos_exporter on FreeBSD, I couldn't see the "junos_up" metric listed though... Should it be included in the metrics list by default? Or am I doing something wrong please?

thanks in advance!

cwaynej commented 1 year ago

I dont think there is a junos_up metric. There is the prometheus up{} for the target itself. But I am not entirely sure if this will actually go down if junos_exporter can't reach the target behind it. Because technically, the scrape job configured in prometheus is for the junos_exporter and successful, even the output is not what you expect.

You could alert on junos_scrape_duration_seconds{} and alert if it hits the timeout specified in your prometheus job. Alternatively you could check if you can alert on the last value being nil. Or you could use the prometheus blackbox_exporter to send icmp to the network devices.

mog01 commented 1 year ago

I thought it was one generated automatically like these...

junosDesc = map[string]*prometheus.Desc {
    "ScrapesTotal":   promDesc("scrapes_total", "Total number of times Junos has been scraped.", nil),
    "ScrapeErrTotal": promDesc("scrape_errors_total", "Total number of errors from a collector.", junosLabels),
    "ScrapeDuration": promDesc("scrape_duration_seconds", "Time it took for a collector's scrape to complete.", junosLabels),
    "CollectorUp":    promDesc("collector_up", "Whether the collector's last scrape was successful (1 = successful, 0 = unsuccessful).", junosLabels),
    "Up":             promDesc("up", "Whether the Junos collector is currently up.", nil),
}

I see things like:

# TYPE junos_scrapes_total counter
junos_scrapes_total 15287

# TYPE junos_scrape_errors_total gauge
junos_scrape_errors_total{collector="environment"} 0
junos_scrape_errors_total{collector="interface"} 0
junos_scrape_errors_total{collector="power"} 15287

But the last one in the code, junos_up{}, seems to be missing?

tynany commented 11 months ago

You are correct. The junos_up metric was not implemented because the more specific collector_up metric covers it.

Thanks for highlighting the code thate needs cleaning up.