Merge pull request #193 from bakins/statsd_exporter_events_total

Add metric for count of events by action
This commit is contained in:
Matthias Rampke 2019-04-09 12:13:17 +00:00 committed by GitHub
commit 178d130388
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View file

@ -355,6 +355,7 @@ func (b *Exporter) handleEvent(event Event) {
} }
if mapping.Action == mapper.ActionTypeDrop { if mapping.Action == mapper.ActionTypeDrop {
eventsActions.WithLabelValues("drop").Inc()
return return
} }
@ -375,6 +376,7 @@ func (b *Exporter) handleEvent(event Event) {
for label, value := range labels { for label, value := range labels {
prometheusLabels[label] = value prometheusLabels[label] = value
} }
eventsActions.WithLabelValues(string(mapping.Action)).Inc()
} else { } else {
eventsUnmapped.Inc() eventsUnmapped.Inc()
metricName = escapeMetricName(event.MetricName()) metricName = escapeMetricName(event.MetricName())

View file

@ -109,6 +109,13 @@ var (
}, },
[]string{"reason"}, []string{"reason"},
) )
eventsActions = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "statsd_exporter_events_actions_total",
Help: "The total number of StatsD events by action.",
},
[]string{"action"},
)
) )
func init() { func init() {
@ -127,4 +134,5 @@ func init() {
prometheus.MustRegister(mappingsCount) prometheus.MustRegister(mappingsCount)
prometheus.MustRegister(conflictingEventStats) prometheus.MustRegister(conflictingEventStats)
prometheus.MustRegister(errorEventStats) prometheus.MustRegister(errorEventStats)
prometheus.MustRegister(eventsActions)
} }