Add total attempts metric
This commit is contained in:
parent
0560e2a76c
commit
492c88c5b2
@ -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
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import (
|
||||
"runtime"
|
||||
)
|
||||
|
||||
var Version = "v0.1.16"
|
||||
var Version = "v0.1.17"
|
||||
var Build string
|
||||
|
||||
func FullVersion() string {
|
||||
|
Loading…
Reference in New Issue
Block a user