@@ -59,18 +59,39 @@ func GetReloadCount(promInstance PrometheusInstance, ngfPodName string) (float64
59
59
)
60
60
}
61
61
62
- //func getReloadErrsCount(promInstance PrometheusInstance, ngfPodName string, startTime time.Time) float64 {
63
- // return getFirstValueOfVector(
64
- // fmt.Sprintf(
65
- // `nginx_gateway_fabric_nginx_reload_errors_total{pod="%[1]s"}`+
66
- // ` - `+
67
- // `nginx_gateway_fabric_nginx_reload_errors_total{pod="%[1]s"} @ %d`,
68
- // ngfPodName,
69
- // startTime.Unix(),
70
- // ),
71
- // promInstance,
72
- // )
73
- //}
62
+ func GetReloadCountWithStartTime (
63
+ promInstance PrometheusInstance ,
64
+ ngfPodName string ,
65
+ startTime time.Time ,
66
+ ) (float64 , error ) {
67
+ return getFirstValueOfVector (
68
+ fmt .Sprintf (
69
+ `nginx_gateway_fabric_nginx_reloads_total{pod="%[1]s"}` +
70
+ ` - ` +
71
+ `nginx_gateway_fabric_nginx_reloads_total{pod="%[1]s"} @ %d` ,
72
+ ngfPodName ,
73
+ startTime .Unix (),
74
+ ),
75
+ promInstance ,
76
+ )
77
+ }
78
+
79
+ func GetReloadErrsCountWithStartTime (
80
+ promInstance PrometheusInstance ,
81
+ ngfPodName string ,
82
+ startTime time.Time ,
83
+ ) (float64 , error ) {
84
+ return getFirstValueOfVector (
85
+ fmt .Sprintf (
86
+ `nginx_gateway_fabric_nginx_reload_errors_total{pod="%[1]s"}` +
87
+ ` - ` +
88
+ `nginx_gateway_fabric_nginx_reload_errors_total{pod="%[1]s"} @ %d` ,
89
+ ngfPodName ,
90
+ startTime .Unix (),
91
+ ),
92
+ promInstance ,
93
+ )
94
+ }
74
95
75
96
func GetReloadAvgTime (promInstance PrometheusInstance , ngfPodName string ) (float64 , error ) {
76
97
return getFirstValueOfVector (
@@ -84,6 +105,27 @@ func GetReloadAvgTime(promInstance PrometheusInstance, ngfPodName string) (float
84
105
)
85
106
}
86
107
108
+ func GetReloadAvgTimeWithStartTime (
109
+ promInstance PrometheusInstance ,
110
+ ngfPodName string ,
111
+ startTime time.Time ,
112
+ ) (float64 , error ) {
113
+ return getFirstValueOfVector (
114
+ fmt .Sprintf (
115
+ `(nginx_gateway_fabric_nginx_reloads_milliseconds_sum{pod="%[1]s"}` +
116
+ ` - ` +
117
+ `nginx_gateway_fabric_nginx_reloads_milliseconds_sum{pod="%[1]s"} @ %[2]d)` +
118
+ ` / ` +
119
+ `(nginx_gateway_fabric_nginx_reloads_total{pod="%[1]s"}` +
120
+ ` - ` +
121
+ `nginx_gateway_fabric_nginx_reloads_total{pod="%[1]s"} @ %[2]d)` ,
122
+ ngfPodName ,
123
+ startTime .Unix (),
124
+ ),
125
+ promInstance ,
126
+ )
127
+ }
128
+
87
129
func GetReloadBuckets (promInstance PrometheusInstance , ngfPodName string ) ([]Bucket , error ) {
88
130
return getBuckets (
89
131
fmt .Sprintf (
@@ -94,6 +136,23 @@ func GetReloadBuckets(promInstance PrometheusInstance, ngfPodName string) ([]Buc
94
136
)
95
137
}
96
138
139
+ func GetReloadBucketsWithStartTime (
140
+ promInstance PrometheusInstance ,
141
+ ngfPodName string ,
142
+ startTime time.Time ,
143
+ ) ([]Bucket , error ) {
144
+ return getBuckets (
145
+ fmt .Sprintf (
146
+ `nginx_gateway_fabric_nginx_reloads_milliseconds_bucket{pod="%[1]s"}` +
147
+ ` - ` +
148
+ `nginx_gateway_fabric_nginx_reloads_milliseconds_bucket{pod="%[1]s"} @ %d` ,
149
+ ngfPodName ,
150
+ startTime .Unix (),
151
+ ),
152
+ promInstance ,
153
+ )
154
+ }
155
+
97
156
func GetEventsCount (promInstance PrometheusInstance , ngfPodName string ) (float64 , error ) {
98
157
return getFirstValueOfVector (
99
158
fmt .Sprintf (
@@ -104,6 +163,23 @@ func GetEventsCount(promInstance PrometheusInstance, ngfPodName string) (float64
104
163
)
105
164
}
106
165
166
+ func GetEventsCountWithStartTime (
167
+ promInstance PrometheusInstance ,
168
+ ngfPodName string ,
169
+ startTime time.Time ,
170
+ ) (float64 , error ) {
171
+ return getFirstValueOfVector (
172
+ fmt .Sprintf (
173
+ `nginx_gateway_fabric_event_batch_processing_milliseconds_count{pod="%[1]s"}` +
174
+ ` - ` +
175
+ `nginx_gateway_fabric_event_batch_processing_milliseconds_count{pod="%[1]s"} @ %d` ,
176
+ ngfPodName ,
177
+ startTime .Unix (),
178
+ ),
179
+ promInstance ,
180
+ )
181
+ }
182
+
107
183
func GetEventsAvgTime (promInstance PrometheusInstance , ngfPodName string ) (float64 , error ) {
108
184
return getFirstValueOfVector (
109
185
fmt .Sprintf (
@@ -116,6 +192,27 @@ func GetEventsAvgTime(promInstance PrometheusInstance, ngfPodName string) (float
116
192
)
117
193
}
118
194
195
+ func GetEventsAvgTimeWithStartTime (
196
+ promInstance PrometheusInstance ,
197
+ ngfPodName string ,
198
+ startTime time.Time ,
199
+ ) (float64 , error ) {
200
+ return getFirstValueOfVector (
201
+ fmt .Sprintf (
202
+ `(nginx_gateway_fabric_event_batch_processing_milliseconds_sum{pod="%[1]s"}` +
203
+ ` - ` +
204
+ `nginx_gateway_fabric_event_batch_processing_milliseconds_sum{pod="%[1]s"} @ %[2]d)` +
205
+ ` / ` +
206
+ `(nginx_gateway_fabric_event_batch_processing_milliseconds_count{pod="%[1]s"}` +
207
+ ` - ` +
208
+ `nginx_gateway_fabric_event_batch_processing_milliseconds_count{pod="%[1]s"} @ %[2]d)` ,
209
+ ngfPodName ,
210
+ startTime .Unix (),
211
+ ),
212
+ promInstance ,
213
+ )
214
+ }
215
+
119
216
func GetEventsBuckets (promInstance PrometheusInstance , ngfPodName string ) ([]Bucket , error ) {
120
217
return getBuckets (
121
218
fmt .Sprintf (
@@ -126,6 +223,23 @@ func GetEventsBuckets(promInstance PrometheusInstance, ngfPodName string) ([]Buc
126
223
)
127
224
}
128
225
226
+ func GetEventsBucketsWithStartTime (
227
+ promInstance PrometheusInstance ,
228
+ ngfPodName string ,
229
+ startTime time.Time ,
230
+ ) ([]Bucket , error ) {
231
+ return getBuckets (
232
+ fmt .Sprintf (
233
+ `nginx_gateway_fabric_event_batch_processing_milliseconds_bucket{pod="%[1]s"}` +
234
+ ` - ` +
235
+ `nginx_gateway_fabric_event_batch_processing_milliseconds_bucket{pod="%[1]s"} @ %d` ,
236
+ ngfPodName ,
237
+ startTime .Unix (),
238
+ ),
239
+ promInstance ,
240
+ )
241
+ }
242
+
129
243
func CreateMetricExistChecker (
130
244
promInstance PrometheusInstance ,
131
245
query string ,
@@ -175,20 +289,20 @@ func CreateEndTimeFinder(
175
289
}
176
290
}
177
291
178
- // func createResponseChecker (url, address string, requestTimeout time.Duration) func() error {
179
- // return func() error {
180
- // status, _, err := Get(url, address, requestTimeout)
181
- // if err != nil {
182
- // return fmt.Errorf("bad response: %w", err)
183
- // }
184
- //
185
- // if status != 200 {
186
- // return fmt.Errorf("unexpected status code: %d", status)
187
- // }
188
- //
189
- // return nil
190
- // }
191
- // }
292
+ func CreateResponseChecker (url , address string , requestTimeout time.Duration ) func () error {
293
+ return func () error {
294
+ status , _ , err := Get (url , address , requestTimeout )
295
+ if err != nil {
296
+ return fmt .Errorf ("bad response: %w" , err )
297
+ }
298
+
299
+ if status != 200 {
300
+ return fmt .Errorf ("unexpected status code: %d" , status )
301
+ }
302
+
303
+ return nil
304
+ }
305
+ }
192
306
193
307
type Bucket struct {
194
308
Le string
0 commit comments