-
Notifications
You must be signed in to change notification settings - Fork 0
/
metrics.go
51 lines (43 loc) · 1.63 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
package main
import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promhttp"
"net/http"
)
var (
counterContainerCheck prometheus.Counter
counterContainerCheckFailure prometheus.Counter
counterContainerRestart prometheus.Counter
counterContainerRestartFailure prometheus.Counter
)
func initPrometheus(env envConfig, mux *http.ServeMux) {
counterContainerCheck = prometheus.NewCounter(prometheus.CounterOpts{
Name: "check_count",
Help: "Count how many container checks has been run",
Namespace: env.MetricsNamespace,
Subsystem: env.MetricsSubsystem,
})
prometheus.MustRegister(counterContainerCheck)
counterContainerCheckFailure = prometheus.NewCounter(prometheus.CounterOpts{
Name: "check_failure_count",
Help: "Count how many container check failures happened",
Namespace: env.MetricsNamespace,
Subsystem: env.MetricsSubsystem,
})
prometheus.MustRegister(counterContainerCheckFailure)
counterContainerRestart = prometheus.NewCounter(prometheus.CounterOpts{
Name: "restart_count",
Help: "Count how many container restarts has been run",
Namespace: env.MetricsNamespace,
Subsystem: env.MetricsSubsystem,
})
prometheus.MustRegister(counterContainerRestart)
counterContainerRestartFailure = prometheus.NewCounter(prometheus.CounterOpts{
Name: "restart_failure_count",
Help: "Count how many container restart failures happened",
Namespace: env.MetricsNamespace,
Subsystem: env.MetricsSubsystem,
})
prometheus.MustRegister(counterContainerRestartFailure)
mux.Handle(env.MetricsPath, promhttp.Handler())
}