-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprometheus_metrics.go
65 lines (62 loc) · 1.68 KB
/
prometheus_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
package main
import "github.com/prometheus/client_golang/prometheus"
var (
apiRequestsBadAuth = prometheus.NewCounter(
prometheus.CounterOpts{
Name: "api_requests_bad_auth",
Help: "Number of api requests that failed on auth.",
},
)
apiRateLimitedIP = prometheus.NewCounter(
prometheus.CounterOpts{
Name: "api_rate_limited_ip",
Help: "Number of api requests that were rate limited by ip.",
},
)
apiRateLimitedKey = prometheus.NewCounter(
prometheus.CounterOpts{
Name: "api_rate_limited_key",
Help: "Number of api requests that were rate limited by api key.",
},
)
apiCallFailed = prometheus.NewCounter(
prometheus.CounterOpts{
Name: "api_call_failed",
Help: "Number of otherwise failed api requests.",
},
)
apiCallSuccess = prometheus.NewCounter(
prometheus.CounterOpts{
Name: "api_call_success",
Help: "Number of successful api requests.",
},
)
apiCallCached = prometheus.NewCounter(
prometheus.CounterOpts{
Name: "api_call_cached",
Help: "Number of cached api requests.",
},
)
usersRegistered = prometheus.NewGauge(
prometheus.GaugeOpts{
Name: "users_registered",
Help: "Number registered users.",
},
)
tokensRefreshed = prometheus.NewCounter(
prometheus.CounterOpts{
Name: "tokens_refreshed",
Help: "Number of times users manually refreshed tokens.",
},
)
)
func metricsInit() {
prometheus.MustRegister(apiRequestsBadAuth)
prometheus.MustRegister(apiRateLimitedIP)
prometheus.MustRegister(apiRateLimitedKey)
prometheus.MustRegister(apiCallFailed)
prometheus.MustRegister(apiCallSuccess)
prometheus.MustRegister(apiCallCached)
prometheus.MustRegister(usersRegistered)
prometheus.MustRegister(tokensRefreshed)
}