4 "github.com/prometheus/client_golang/prometheus"
5 "github.com/prometheus/client_golang/prometheus/promauto"
9 metricAuth = promauto.NewCounterVec(
10 prometheus.CounterOpts{
11 Name: "mox_authentication_total",
12 Help: "Authentication attempts and results.",
15 "kind", // submission, imap, webmail, webaccount, webadmin (formerly httpaccount, httpadmin)
16 "variant", // login, plain, scram-sha-256, scram-sha-1, cram-md5, weblogin, websessionuse. formerly: httpbasic.
17 // todo: we currently only use badcreds, but known baduser can be helpful
18 "result", // ok, baduser, badpassword, badcreds, error, aborted
22 metricAuthRatelimited = promauto.NewCounterVec(
23 prometheus.CounterOpts{
24 Name: "mox_authentication_ratelimited_total",
25 Help: "Authentication attempts that were refused due to rate limiting.",
28 "kind", // submission, imap, httpaccount, httpadmin
33func AuthenticationInc(kind, variant, result string) {
34 metricAuth.WithLabelValues(kind, variant, result).Inc()
37func AuthenticationRatelimitedInc(kind string) {
38 metricAuthRatelimited.WithLabelValues(kind).Inc()