Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add SNMPInflight metric #1119

Merged
merged 3 commits into from
Feb 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@ type Metrics struct {
SNMPDuration prometheus.Histogram
SNMPPackets prometheus.Counter
SNMPRetries prometheus.Counter
SNMPInflight prometheus.Gauge
}

type NamedModule struct {
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Loading