From 71f7a444398275923246e1bc8283938a63a8267a Mon Sep 17 00:00:00 2001 From: bndw Date: Sun, 15 Feb 2026 08:22:03 -0800 Subject: feat: add metrics for blocked events Track and display blocked event counts with per-kind breakdown. - Add events_blocked_total counter with kind label - Add RecordBlockedEvent method to metrics - Display blocked count in dashboard Storage section - Call metric when rejecting non-core protocol kinds Allows monitoring spam patterns and verifying kind filter effectiveness. Raw metrics show breakdown by kind (e.g., kind=20001, kind=30311). --- internal/metrics/metrics.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'internal/metrics/metrics.go') diff --git a/internal/metrics/metrics.go b/internal/metrics/metrics.go index 74f9ffb..dea0748 100644 --- a/internal/metrics/metrics.go +++ b/internal/metrics/metrics.go @@ -2,6 +2,7 @@ package metrics import ( _ "embed" + "fmt" "net/http" "github.com/prometheus/client_golang/prometheus" @@ -30,6 +31,7 @@ type Metrics struct { eventsTotal prometheus.Gauge dbSizeBytes prometheus.Gauge eventDeletionsTotal prometheus.Counter + eventsBlockedTotal *prometheus.CounterVec // Config config *Config @@ -195,6 +197,16 @@ func New(config *Config) *Metrics { }, ) + m.eventsBlockedTotal = promauto.NewCounterVec( + prometheus.CounterOpts{ + Namespace: config.Namespace, + Subsystem: config.Subsystem, + Name: "events_blocked_total", + Help: "Total events blocked by kind filter", + }, + []string{"kind"}, + ) + return m } @@ -274,6 +286,11 @@ func (m *Metrics) RecordEventDeletion() { m.eventDeletionsTotal.Inc() } +// RecordBlockedEvent records an event blocked by kind filter. +func (m *Metrics) RecordBlockedEvent(kind int32) { + m.eventsBlockedTotal.WithLabelValues(fmt.Sprintf("%d", kind)).Inc() +} + // RequestStatus represents the status of a request for metrics. type RequestStatus string -- cgit v1.2.3