2023-01-30 16:27:06 +03:00
|
|
|
package metrics
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
|
|
"github.com/prometheus/client_golang/prometheus/promauto"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
2023-02-13 15:53:47 +03:00
|
|
|
metricAuth = promauto.NewCounterVec(
|
2023-01-30 16:27:06 +03:00
|
|
|
prometheus.CounterOpts{
|
|
|
|
Name: "mox_authentication_total",
|
|
|
|
Help: "Authentication attempts and results.",
|
|
|
|
},
|
|
|
|
[]string{
|
|
|
|
"kind", // submission, imap, httpaccount, httpadmin
|
2023-02-05 18:29:03 +03:00
|
|
|
"variant", // login, plain, scram-sha-256, scram-sha-1, cram-md5, httpbasic
|
2023-01-30 16:27:06 +03:00
|
|
|
// todo: we currently only use badcreds, but known baduser can be helpful
|
|
|
|
"result", // ok, baduser, badpassword, badcreds, error, aborted
|
|
|
|
},
|
|
|
|
)
|
2023-02-13 15:53:47 +03:00
|
|
|
|
|
|
|
metricAuthRatelimited = promauto.NewCounterVec(
|
|
|
|
prometheus.CounterOpts{
|
|
|
|
Name: "mox_authentication_ratelimited_total",
|
|
|
|
Help: "Authentication attempts that were refused due to rate limiting.",
|
|
|
|
},
|
|
|
|
[]string{
|
|
|
|
"kind", // submission, imap, httpaccount, httpadmin
|
|
|
|
},
|
|
|
|
)
|
2023-01-30 16:27:06 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func AuthenticationInc(kind, variant, result string) {
|
2023-02-13 15:53:47 +03:00
|
|
|
metricAuth.WithLabelValues(kind, variant, result).Inc()
|
|
|
|
}
|
|
|
|
|
|
|
|
func AuthenticationRatelimitedInc(kind string) {
|
|
|
|
metricAuthRatelimited.WithLabelValues(kind).Inc()
|
2023-01-30 16:27:06 +03:00
|
|
|
}
|