/
metrics.go
103 lines (93 loc) · 1.98 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
// Unless explicitly stated otherwise all files in this repository are licensed
// under the MIT License.
// This product includes software developed at Guance Cloud (https://www.guance.com/).
// Copyright 2021-present Guance, Inc.
package stats
import (
"github.com/GuanceCloud/cliutils/metrics"
"github.com/prometheus/client_golang/prometheus"
)
var (
plPtsVec,
plErrPtsVec,
plDropVec *prometheus.CounterVec
plUpdateVec *prometheus.GaugeVec
plCostVec *prometheus.SummaryVec
)
func Metrics() []prometheus.Collector {
return []prometheus.Collector{
plPtsVec,
plDropVec,
plUpdateVec,
plCostVec,
}
}
// nolint:gochecknoinits
func init() {
plPtsVec = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "datakit",
Subsystem: "pipeline",
Name: "point_total",
Help: "Pipeline processed total points",
},
[]string{
"category",
"name",
"namespace",
},
)
plDropVec = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "datakit",
Subsystem: "pipeline",
Name: "drop_point_total",
Help: "Pipeline total dropped points",
},
[]string{
"category",
"name",
"namespace",
},
)
plErrPtsVec = prometheus.NewCounterVec(
prometheus.CounterOpts{
Namespace: "datakit",
Subsystem: "pipeline",
Name: "error_point_total",
Help: "Pipeline processed total error points",
},
[]string{
"category",
"name",
"namespace",
},
)
plCostVec = prometheus.NewSummaryVec(
prometheus.SummaryOpts{
Namespace: "datakit",
Subsystem: "pipeline",
Name: "cost_seconds",
Help: "Pipeline total running time",
},
[]string{
"category",
"name",
"namespace",
},
)
plUpdateVec = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: "datakit",
Subsystem: "pipeline",
Name: "last_update_timestamp_seconds",
Help: "Pipeline last update time",
},
[]string{
"category",
"name",
"namespace",
},
)
metrics.MustRegister(Metrics()...)
}