diff --git a/honeypot/ssh/store/metrics.go b/honeypot/ssh/store/metrics.go index c9277b4..e2c53b2 100644 --- a/honeypot/ssh/store/metrics.go +++ b/honeypot/ssh/store/metrics.go @@ -14,6 +14,7 @@ type MetricsCollectingStore struct { uniqueUsernamesCount prometheus.Gauge uniquePasswordsCount prometheus.Gauge uniqueIPsCount prometheus.Gauge + totalAttemptsCount prometheus.Gauge } func NewMetricsCollectingStore(ctx context.Context, store LoginAttemptStore) *MetricsCollectingStore { @@ -48,10 +49,18 @@ func NewMetricsCollectingStore(ctx context.Context, store LoginAttemptStore) *Me ConstLabels: prometheus.Labels{"service": "honeypot_ssh"}, }) + mcs.totalAttemptsCount = prometheus.NewGauge( + prometheus.GaugeOpts{ + Name: "apiary_ssh_total_login_attempts", + Help: "Total amount of login attempts made.", + ConstLabels: prometheus.Labels{"service": "honeypot_ssh"}, + }) + prometheus.MustRegister(mcs.attemptsCounter) prometheus.MustRegister(mcs.uniqueUsernamesCount) prometheus.MustRegister(mcs.uniquePasswordsCount) prometheus.MustRegister(mcs.uniqueIPsCount) + prometheus.MustRegister(mcs.totalAttemptsCount) // Kinda jank, we just fetch the stats every 10seconds, but it should be cached most of the time. go func(ctx context.Context) { @@ -88,6 +97,8 @@ func (s *MetricsCollectingStore) Stats(statType LoginStats, limit int) ([]StatsR s.uniqueUsernamesCount.Set(float64(element.Count)) case "UniqueIPs": s.uniqueIPsCount.Set(float64(element.Count)) + case "TotalLoginAttempts": + s.totalAttemptsCount.Set(float64(element.Count)) default: continue } diff --git a/version.go b/version.go index b167bb3..f7a3ccf 100644 --- a/version.go +++ b/version.go @@ -5,7 +5,7 @@ import ( "runtime" ) -var Version = "v0.1.16" +var Version = "v0.1.17" var Build string func FullVersion() string {