@@ -3,7 +3,6 @@ package monitoring
3
3
import (
4
4
"github.com/prometheus/client_golang/prometheus"
5
5
"strconv"
6
- "time"
7
6
)
8
7
9
8
type StaticCollector struct {
@@ -34,28 +33,28 @@ type PoolNodeCollector struct {
34
33
func NewPoolCollector (nodesCount int ) * PoolCollector {
35
34
ent := & PoolCollector {}
36
35
37
- ent .IdleLoad0 = prometheus .NewDesc ("pool_idle_load0 " ,
38
- "400, 600, 800 %" ,
36
+ ent .IdleLoad0 = prometheus .NewDesc ("pind_pool_idle_load0 " ,
37
+ "idle cores load, like 400, 600, 800 %" ,
39
38
nil , nil ,
40
39
)
41
- ent .IdleLoad1 = prometheus .NewDesc ("pool_idle_load1 " ,
42
- "0-100 %" ,
40
+ ent .IdleLoad1 = prometheus .NewDesc ("pind_pool_idle_load1 " ,
41
+ "idle cores load, like 0-100 %" ,
43
42
nil , nil ,
44
43
)
45
- ent .LoadFree0 = prometheus .NewDesc ("pool_load_free0 " ,
46
- "400, 600, 800 %" ,
44
+ ent .LoadFree0 = prometheus .NewDesc ("pind_pool_load_free0 " ,
45
+ "free cores load, like 400, 600, 800 %" ,
47
46
nil , nil ,
48
47
)
49
- ent .LoadFree1 = prometheus .NewDesc ("pool_load_free1 " ,
50
- "0-100 %" ,
48
+ ent .LoadFree1 = prometheus .NewDesc ("pind_pool_load_free1 " ,
49
+ "free cores load, like 0-100 %" ,
51
50
nil , nil ,
52
51
)
53
- ent .LoadUsed0 = prometheus .NewDesc ("pool_load_used0 " ,
54
- "400, 600, 800 %" ,
52
+ ent .LoadUsed0 = prometheus .NewDesc ("pind_pool_load_used0 " ,
53
+ "used cores load, like 400, 600, 800 %" ,
55
54
nil , nil ,
56
55
)
57
- ent .LoadUsed1 = prometheus .NewDesc ("pool_load_used1 " ,
58
- "0-100 %" ,
56
+ ent .LoadUsed1 = prometheus .NewDesc ("pind_pool_load_used1 " ,
57
+ "used cores load, like 0-100 %" ,
59
58
nil , nil ,
60
59
)
61
60
@@ -68,20 +67,20 @@ func NewPoolCollector(nodesCount int) *PoolCollector {
68
67
"node" : strconv .Itoa (i ),
69
68
}
70
69
71
- node .LoadFree0 = prometheus .NewDesc ("node_load_free0 " ,
72
- "400, 600, 800 %" ,
70
+ node .LoadFree0 = prometheus .NewDesc ("pind_node_load_free0 " ,
71
+ "node free cores load, like 400, 600, 800 %" ,
73
72
nil , labels0 ,
74
73
)
75
- node .LoadFree1 = prometheus .NewDesc ("node_load_free1 " ,
76
- "0-100 %" ,
74
+ node .LoadFree1 = prometheus .NewDesc ("pind_node_load_free1 " ,
75
+ "node free cores load, like 0-100 %" ,
77
76
nil , labels0 ,
78
77
)
79
- node .LoadUsed0 = prometheus .NewDesc ("node_load_used0 " ,
80
- "400, 600, 800 %" ,
78
+ node .LoadUsed0 = prometheus .NewDesc ("pind_node_load_used0 " ,
79
+ "node used cores load, like 400, 600, 800 %" ,
81
80
nil , labels0 ,
82
81
)
83
- node .LoadUsed1 = prometheus .NewDesc ("node_load_used1 " ,
84
- "0-100 %" ,
82
+ node .LoadUsed1 = prometheus .NewDesc ("pind_node_load_used1 " ,
83
+ "node used cores load, like 0-100 %" ,
85
84
nil , labels0 ,
86
85
)
87
86
@@ -126,13 +125,13 @@ func (x *StaticCollector) Collect(ch chan<- prometheus.Metric) {
126
125
m4 := prometheus .MustNewConstMetric (x .PoolCollector .LoadUsed0 , prometheus .GaugeValue , x .State .Pool .LoadUsed0 )
127
126
m5 := prometheus .MustNewConstMetric (x .PoolCollector .LoadUsed1 , prometheus .GaugeValue , x .State .Pool .LoadUsed1 )
128
127
129
- now := time . Now ()
130
- mt0 := prometheus .NewMetricWithTimestamp (now , m0 )
131
- mt1 := prometheus .NewMetricWithTimestamp (now , m1 )
132
- mt2 := prometheus .NewMetricWithTimestamp (now , m2 )
133
- mt3 := prometheus .NewMetricWithTimestamp (now , m3 )
134
- mt4 := prometheus .NewMetricWithTimestamp (now , m4 )
135
- mt5 := prometheus .NewMetricWithTimestamp (now , m5 )
128
+ t0 := x . State . Time
129
+ mt0 := prometheus .NewMetricWithTimestamp (t0 , m0 )
130
+ mt1 := prometheus .NewMetricWithTimestamp (t0 , m1 )
131
+ mt2 := prometheus .NewMetricWithTimestamp (t0 , m2 )
132
+ mt3 := prometheus .NewMetricWithTimestamp (t0 , m3 )
133
+ mt4 := prometheus .NewMetricWithTimestamp (t0 , m4 )
134
+ mt5 := prometheus .NewMetricWithTimestamp (t0 , m5 )
136
135
137
136
ch <- mt0
138
137
ch <- mt1
@@ -152,10 +151,10 @@ func (x *StaticCollector) Collect(ch chan<- prometheus.Metric) {
152
151
mn2 := prometheus .MustNewConstMetric (nodeCollector .LoadUsed0 , prometheus .GaugeValue , node .LoadUsed0 )
153
152
mn3 := prometheus .MustNewConstMetric (nodeCollector .LoadUsed1 , prometheus .GaugeValue , node .LoadUsed1 )
154
153
155
- mnt0 := prometheus .NewMetricWithTimestamp (now , mn0 )
156
- mnt1 := prometheus .NewMetricWithTimestamp (now , mn1 )
157
- mnt2 := prometheus .NewMetricWithTimestamp (now , mn2 )
158
- mnt3 := prometheus .NewMetricWithTimestamp (now , mn3 )
154
+ mnt0 := prometheus .NewMetricWithTimestamp (t0 , mn0 )
155
+ mnt1 := prometheus .NewMetricWithTimestamp (t0 , mn1 )
156
+ mnt2 := prometheus .NewMetricWithTimestamp (t0 , mn2 )
157
+ mnt3 := prometheus .NewMetricWithTimestamp (t0 , mn3 )
159
158
160
159
ch <- mnt0
161
160
ch <- mnt1
0 commit comments