mirror of
https://github.com/nikdoof/aaisp-chaos.git
synced 2025-12-13 14:52:17 +00:00
Add aaisp_scrape_success gauge
Previously if we fail to connect to CHAOS during a scrape no metrics are emitted. Now a aaisp_scrape_success metric is always emitted with values 0 for failure and 1 for success, along the lines of blackbox_exporter's probe_success metric.
This commit is contained in:
@@ -37,6 +37,10 @@ var (
|
||||
[]string{"line_id"},
|
||||
nil,
|
||||
)
|
||||
scrapeSuccessGauge = prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
Name: "aaisp_scrape_success",
|
||||
Help: "Displays whether or not the AAISP API scrape was a success",
|
||||
})
|
||||
)
|
||||
|
||||
type broadbandCollector struct {
|
||||
@@ -51,8 +55,10 @@ func (bc broadbandCollector) Collect(ch chan<- prometheus.Metric) {
|
||||
lines, err := bc.BroadbandInfo()
|
||||
if err != nil {
|
||||
log.Printf("error getting broadband info: %v\n", err)
|
||||
scrapeSuccessGauge.Set(0)
|
||||
return
|
||||
}
|
||||
scrapeSuccessGauge.Set(1)
|
||||
for _, line := range lines {
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
broadbandQuotaRemainingDesc,
|
||||
@@ -93,6 +99,7 @@ func main() {
|
||||
}
|
||||
|
||||
prometheus.MustRegister(collector)
|
||||
prometheus.MustRegister(scrapeSuccessGauge)
|
||||
http.Handle("/metrics", promhttp.Handler())
|
||||
log.Fatal(http.ListenAndServe(*listen, nil))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user