-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmetrics.go
73 lines (70 loc) · 2.09 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 main
import (
"github.com/prometheus/client_golang/prometheus"
)
type Metrics struct {
ApiRequests *prometheus.CounterVec
ApiErrors *prometheus.CounterVec
CleanedUpFiles prometheus.Counter
CleanUpErrors *prometheus.CounterVec
JobErrors prometheus.Counter
Detections prometheus.Counter
PredTime prometheus.Histogram
TotalTime prometheus.Histogram
}
func setupMetrics() Metrics {
m := Metrics{}
m.ApiRequests = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: "darknetd",
Name: "api_requests",
Help: "API requests.",
}, []string{"handler"})
m.ApiErrors = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: "darknetd",
Name: "api_errors",
Help: "API errors.",
}, []string{"handler", "error"})
m.CleanUpErrors = prometheus.NewCounterVec(prometheus.CounterOpts{
Namespace: "darknetd",
Name: "cleanup_errors",
Help: "Image cleanup errors.",
}, []string{"error"})
m.CleanedUpFiles = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "darknetd",
Name: "cleanup_files",
Help: "Image files cleaned up.",
})
m.JobErrors = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "darknetd",
Name: "detection_errors",
Help: "Darknet detection errors.",
})
m.Detections = prometheus.NewCounter(prometheus.CounterOpts{
Namespace: "darknetd",
Name: "detections",
Help: "Darknet successful detection jobs.",
})
m.PredTime = prometheus.NewHistogram(prometheus.HistogramOpts{
Namespace: "darknetd",
Name: "prediction_sec",
Help: "Darknet prediction time sec",
Buckets: []float64{.001, .025, .05, .1, .25, .5, .6, .7, .8, .9, 1, 1.5, 2},
})
m.TotalTime = prometheus.NewHistogram(prometheus.HistogramOpts{
Namespace: "darknetd",
Name: "total_sec",
Help: "Total job time sec",
Buckets: []float64{.001, .025, .05, .1, .25, .5, .6, .7, .8, .9, 1, 1.5, 2},
})
prometheus.MustRegister(
m.ApiRequests,
m.ApiErrors,
m.CleanUpErrors,
m.CleanedUpFiles,
m.Detections,
m.JobErrors,
m.PredTime,
m.TotalTime,
)
return m
}