1// Package metrics has (prometheus) metrics shared between components of mox, e.g. for authentication.
5 "github.com/prometheus/client_golang/prometheus"
6 "github.com/prometheus/client_golang/prometheus/promauto"
10 metricAuth = promauto.NewCounterVec(
11 prometheus.CounterOpts{
12 Name: "mox_authentication_total",
13 Help: "Authentication attempts and results.",
16 "kind", // submission, imap, webmail, webapi, webaccount, webadmin (formerly httpaccount, httpadmin)
17 "variant", // login, plain, scram-sha-256, scram-sha-1, cram-md5, weblogin, websessionuse, httpbasic.
18 // todo: we currently only use badcreds, but known baduser can be helpful
19 "result", // ok, baduser, badpassword, badcreds, badchanbind, error, aborted
23 metricAuthRatelimited = promauto.NewCounterVec(
24 prometheus.CounterOpts{
25 Name: "mox_authentication_ratelimited_total",
26 Help: "Authentication attempts that were refused due to rate limiting.",
29 "kind", // submission, imap, httpaccount, httpadmin
34func AuthenticationInc(kind, variant, result string) {
35 metricAuth.WithLabelValues(kind, variant, result).Inc()
38func AuthenticationRatelimitedInc(kind string) {
39 metricAuthRatelimited.WithLabelValues(kind).Inc()