diff --git a/collector/collector.go b/collector/collector.go index cb1faed0..1b7337ac 100644 --- a/collector/collector.go +++ b/collector/collector.go @@ -275,6 +275,7 @@ type Metrics struct { SNMPDuration prometheus.Histogram SNMPPackets prometheus.Counter SNMPRetries prometheus.Counter + SNMPInflight prometheus.Gauge } type NamedModule struct { @@ -346,7 +347,9 @@ func (c Collector) collect(ch chan<- prometheus.Metric, logger log.Logger, clien ) start := time.Now() moduleLabel := prometheus.Labels{"module": module.name} + c.metrics.SNMPInflight.Inc() results, err := ScrapeTarget(client, c.target, c.auth, module.Module, logger, c.metrics) + c.metrics.SNMPInflight.Dec() if err != nil { level.Info(logger).Log("msg", "Error scraping target", "err", err) ch <- prometheus.NewInvalidMetric(prometheus.NewDesc("snmp_error", "Error scraping target", nil, moduleLabel), err) diff --git a/main.go b/main.go index 43193d18..72bdb2b9 100644 --- a/main.go +++ b/main.go @@ -267,6 +267,13 @@ func main() { Help: "Number of SNMP packet retries.", }, ), + SNMPInflight: promauto.NewGauge( + prometheus.GaugeOpts{ + Namespace: namespace, + Name: "request_in_flight", + Help: "Current number of SNMP scrapes being requested.", + }, + ), } http.Handle(*metricsPath, promhttp.Handler()) // Normal metrics endpoint for SNMP exporter itself.