Add metric for count of events by action

Signed-off-by: Brian Akins <brian@akins.org>
This commit is contained in:
Brian Akins 2019-03-25 18:16:38 -04:00
parent 71df5a3198
commit 1cbc5a9b27
2 changed files with 10 additions and 0 deletions

View file

@ -322,6 +322,7 @@ func (b *Exporter) handleEvent(event Event) {
} }
if mapping.Action == mapper.ActionTypeDrop { if mapping.Action == mapper.ActionTypeDrop {
eventsActions.WithLabelValues("drop").Inc()
return return
} }
@ -342,6 +343,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)
} }