forked from openshift/origin
-
Notifications
You must be signed in to change notification settings - Fork 1
/
metrics.go
73 lines (66 loc) · 1.95 KB
/
metrics.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package metrics
import (
"github.com/prometheus/client_golang/prometheus"
)
const (
authSubsystem = "openshift_auth"
)
const (
SuccessResult = "success"
FailResult = "failure"
ErrorResult = "error"
)
var (
authPasswordTotal = prometheus.NewCounterVec(
prometheus.CounterOpts{
Subsystem: authSubsystem,
Name: "password_total",
Help: "Counts total password authentication attempts",
}, []string{},
)
authFormCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Subsystem: authSubsystem,
Name: "form_password_count",
Help: "Counts form password authentication attempts",
}, []string{},
)
authFormCounterResult = prometheus.NewCounterVec(
prometheus.CounterOpts{
Subsystem: authSubsystem,
Name: "form_password_count_result",
Help: "Counts form password authentication attempts by result",
}, []string{"result"},
)
authBasicCounter = prometheus.NewCounterVec(
prometheus.CounterOpts{
Subsystem: authSubsystem,
Name: "basic_password_count",
Help: "Counts basic password authentication attempts",
}, []string{},
)
authBasicCounterResult = prometheus.NewCounterVec(
prometheus.CounterOpts{
Subsystem: authSubsystem,
Name: "basic_password_count_result",
Help: "Counts basic password authentication attempts by result",
}, []string{"result"},
)
)
func init() {
prometheus.MustRegister(authPasswordTotal)
prometheus.MustRegister(authFormCounter)
prometheus.MustRegister(authFormCounterResult)
prometheus.MustRegister(authBasicCounter)
prometheus.MustRegister(authBasicCounterResult)
}
func RecordBasicPasswordAuth(result string) {
authPasswordTotal.WithLabelValues().Inc()
authBasicCounter.WithLabelValues().Inc()
authBasicCounterResult.WithLabelValues(result).Inc()
}
func RecordFormPasswordAuth(result string) {
authPasswordTotal.WithLabelValues().Inc()
authFormCounter.WithLabelValues().Inc()
authFormCounterResult.WithLabelValues(result).Inc()
}