@@ -41,20 +41,7 @@ describe('PrometheusManagerMetrics', () => {
41
41
const managerMetrics = new PrometheusManagerMetrics (
42
42
new QueryMapPrometheusClient (
43
43
{
44
- 'sum(rate(shadowsocks_data_bytes_per_location{dir=~"c<p|p>t"}[300s]))' : {
45
- resultType : 'vector' ,
46
- result : [
47
- {
48
- metric : {
49
- location : 'US' ,
50
- asn : '49490' ,
51
- asorg : 'Test AS Org' ,
52
- } ,
53
- value : [ 1739284734 , '1234' ] ,
54
- } ,
55
- ] ,
56
- } ,
57
- 'sum(increase(shadowsocks_data_bytes_per_location{dir=~"c<p|p>t"}[0s])) by (location, asn, asorg)' :
44
+ 'sum(increase(shadowsocks_tunnel_time_seconds_per_location[0s])) by (location, asn, asorg)' :
58
45
{
59
46
resultType : 'vector' ,
60
47
result : [
@@ -68,60 +55,25 @@ describe('PrometheusManagerMetrics', () => {
68
55
} ,
69
56
] ,
70
57
} ,
71
- 'sum(increase(shadowsocks_tunnel_time_seconds_per_location[0s])) by (location, asn, asorg)' :
58
+ } ,
59
+ {
60
+ 'sum(increase(shadowsocks_data_bytes_per_location{dir=~"c<p|p>t"}[300s])) by (location, asn, asorg)' :
72
61
{
73
- resultType : 'vector ' ,
62
+ resultType : 'matrix ' ,
74
63
result : [
75
64
{
76
65
metric : {
77
66
location : 'US' ,
78
67
asn : '49490' ,
79
68
asorg : 'Test AS Org' ,
80
69
} ,
81
- value : [ 1738959398 , '1000' ] ,
70
+ values : [
71
+ [ 1738959398 , '9000' ] ,
72
+ [ 1739284734 , '3000' ] ,
73
+ ] ,
82
74
} ,
83
75
] ,
84
76
} ,
85
- 'sum(increase(shadowsocks_data_bytes{dir=~"c<p|p>t"}[0s])) by (access_key)' : {
86
- resultType : 'vector' ,
87
- result : [
88
- {
89
- metric : {
90
- access_key : '0' ,
91
- } ,
92
- value : [ 1738959398 , '1000' ] ,
93
- } ,
94
- ] ,
95
- } ,
96
- 'sum(increase(shadowsocks_tunnel_time_seconds[0s])) by (access_key)' : {
97
- resultType : 'vector' ,
98
- result : [
99
- {
100
- metric : {
101
- access_key : '0' ,
102
- } ,
103
- value : [ 1738959398 , '1000' ] ,
104
- } ,
105
- ] ,
106
- } ,
107
- } ,
108
- {
109
- 'sum(rate(shadowsocks_data_bytes_per_location{dir=~"c<p|p>t"}[300s]))' : {
110
- resultType : 'matrix' ,
111
- result : [
112
- {
113
- metric : {
114
- location : 'US' ,
115
- asn : '49490' ,
116
- asorg : 'Test AS Org' ,
117
- } ,
118
- values : [
119
- [ 1738959398 , '5678' ] ,
120
- [ 1739284734 , '1234' ] ,
121
- ] ,
122
- } ,
123
- ] ,
124
- } ,
125
77
'sum(increase(shadowsocks_data_bytes{dir=~"c<p|p>t"}[300s])) by (access_key)' : {
126
78
resultType : 'matrix' ,
127
79
result : [
@@ -130,8 +82,8 @@ describe('PrometheusManagerMetrics', () => {
130
82
access_key : '0' ,
131
83
} ,
132
84
values : [
133
- [ 1738959398 , '1000 ' ] ,
134
- [ 1739284734 , '2000 ' ] ,
85
+ [ 1738959398 , '9000 ' ] ,
86
+ [ 1739284734 , '3000 ' ] ,
135
87
] ,
136
88
} ,
137
89
] ,
@@ -145,7 +97,7 @@ describe('PrometheusManagerMetrics', () => {
145
97
} ,
146
98
values : [
147
99
[ 1738959398 , '1000' ] ,
148
- [ 1739284734 , '0' ] ,
100
+ [ 1738959398 , '0' ] ,
149
101
] ,
150
102
} ,
151
103
] ,
@@ -162,18 +114,18 @@ describe('PrometheusManagerMetrics', () => {
162
114
"seconds": 1000
163
115
},
164
116
"dataTransferred": {
165
- "bytes": 1000
117
+ "bytes": 12000
166
118
},
167
119
"bandwidth": {
168
120
"current": {
169
121
"data": {
170
- "bytes": 1234
122
+ "bytes": 10
171
123
},
172
124
"timestamp": 1739284734
173
125
},
174
126
"peak": {
175
127
"data": {
176
- "bytes": 5678
128
+ "bytes": 30
177
129
},
178
130
"timestamp": 1738959398
179
131
}
@@ -184,7 +136,7 @@ describe('PrometheusManagerMetrics', () => {
184
136
"asn": 49490,
185
137
"asOrg": "Test AS Org",
186
138
"dataTransferred": {
187
- "bytes": 1000
139
+ "bytes": 12000
188
140
},
189
141
"tunnelTime": {
190
142
"seconds": 1000
@@ -196,7 +148,7 @@ describe('PrometheusManagerMetrics', () => {
196
148
{
197
149
"accessKeyId": 0,
198
150
"dataTransferred": {
199
- "bytes": 1000
151
+ "bytes": 12000
200
152
},
201
153
"tunnelTime": {
202
154
"seconds": 1000
@@ -218,20 +170,7 @@ describe('PrometheusManagerMetrics', () => {
218
170
const managerMetrics = new PrometheusManagerMetrics (
219
171
new QueryMapPrometheusClient (
220
172
{
221
- 'sum(rate(shadowsocks_data_bytes_per_location{dir=~"c<p|p>t"}[300s]))' : {
222
- resultType : 'vector' ,
223
- result : [
224
- {
225
- metric : {
226
- location : 'US' ,
227
- asn : '49490' ,
228
- asorg : 'Test AS Org' ,
229
- } ,
230
- value : [ 1739284734 , '1234' ] ,
231
- } ,
232
- ] ,
233
- } ,
234
- 'sum(increase(shadowsocks_data_bytes_per_location{dir=~"c<p|p>t"}[0s])) by (location, asn, asorg)' :
173
+ 'sum(increase(shadowsocks_tunnel_time_seconds_per_location[0s])) by (location, asn, asorg)' :
235
174
{
236
175
resultType : 'vector' ,
237
176
result : [
@@ -245,58 +184,25 @@ describe('PrometheusManagerMetrics', () => {
245
184
} ,
246
185
] ,
247
186
} ,
248
- 'sum(increase(shadowsocks_tunnel_time_seconds_per_location[0s])) by (location, asn, asorg)' :
187
+ } ,
188
+ {
189
+ 'sum(increase(shadowsocks_data_bytes_per_location{dir=~"c<p|p>t"}[300s])) by (location, asn, asorg)' :
249
190
{
250
- resultType : 'vector ' ,
191
+ resultType : 'matrix ' ,
251
192
result : [
252
193
{
253
194
metric : {
254
- location : 'CA' ,
195
+ location : 'US' ,
196
+ asn : '49490' ,
197
+ asorg : 'Test AS Org' ,
255
198
} ,
256
- value : [ 1738959398 , '1000' ] ,
199
+ values : [
200
+ [ 1738959398 , '9000' ] ,
201
+ [ 1739284734 , '3000' ] ,
202
+ ] ,
257
203
} ,
258
204
] ,
259
205
} ,
260
- 'sum(increase(shadowsocks_data_bytes{dir=~"c<p|p>t"}[0s])) by (access_key)' : {
261
- resultType : 'vector' ,
262
- result : [
263
- {
264
- metric : {
265
- access_key : '0' ,
266
- } ,
267
- value : [ 1738959398 , '1000' ] ,
268
- } ,
269
- ] ,
270
- } ,
271
- 'sum(increase(shadowsocks_tunnel_time_seconds[0s])) by (access_key)' : {
272
- resultType : 'vector' ,
273
- result : [
274
- {
275
- metric : {
276
- access_key : '1' ,
277
- } ,
278
- value : [ 1738959398 , '1000' ] ,
279
- } ,
280
- ] ,
281
- } ,
282
- } ,
283
- {
284
- 'sum(rate(shadowsocks_data_bytes_per_location{dir=~"c<p|p>t"}[300s]))' : {
285
- resultType : 'matrix' ,
286
- result : [
287
- {
288
- metric : {
289
- location : 'US' ,
290
- asn : '49490' ,
291
- asorg : 'Test AS Org' ,
292
- } ,
293
- values : [
294
- [ 1738959398 , '5678' ] ,
295
- [ 1739284734 , '1234' ] ,
296
- ] ,
297
- } ,
298
- ] ,
299
- } ,
300
206
'sum(increase(shadowsocks_data_bytes{dir=~"c<p|p>t"}[300s])) by (access_key)' : {
301
207
resultType : 'matrix' ,
302
208
result : [
@@ -305,8 +211,8 @@ describe('PrometheusManagerMetrics', () => {
305
211
access_key : '0' ,
306
212
} ,
307
213
values : [
308
- [ 1738959398 , '1000 ' ] ,
309
- [ 1738959398 , '2000 ' ] ,
214
+ [ 1738959398 , '9000 ' ] ,
215
+ [ 1739284734 , '3000 ' ] ,
310
216
] ,
311
217
} ,
312
218
] ,
@@ -337,74 +243,47 @@ describe('PrometheusManagerMetrics', () => {
337
243
"seconds": 1000
338
244
},
339
245
"dataTransferred": {
340
- "bytes": 1000
246
+ "bytes": 12000
341
247
},
342
248
"bandwidth": {
343
249
"current": {
344
250
"data": {
345
- "bytes": 1234
251
+ "bytes": 10
346
252
},
347
253
"timestamp": 1739284734
348
254
},
349
255
"peak": {
350
256
"data": {
351
- "bytes": 5678
257
+ "bytes": 30
352
258
},
353
259
"timestamp": 1738959398
354
260
}
355
261
},
356
262
"locations": [
357
- {
358
- "location": "CA",
359
- "asn": null,
360
- "asOrg": null,
361
- "dataTransferred": {
362
- "bytes": 0
363
- },
364
- "tunnelTime": {
365
- "seconds": 1000
366
- }
367
- },
368
263
{
369
264
"location": "US",
370
265
"asn": 49490,
371
266
"asOrg": "Test AS Org",
372
267
"dataTransferred": {
373
- "bytes": 1000
268
+ "bytes": 12000
374
269
},
375
270
"tunnelTime": {
376
- "seconds": 0
271
+ "seconds": 1000
377
272
}
378
273
}
379
274
]
380
275
},
381
276
"accessKeys": [
382
- {
383
- "accessKeyId": 1,
384
- "dataTransferred": {
385
- "bytes": 0
386
- },
387
- "tunnelTime": {
388
- "seconds": 1000
389
- },
390
- "connection": {
391
- "lastTrafficSeen": null,
392
- "peakDeviceCount": {
393
- "data": 0,
394
- "timestamp": null
395
- }
396
- }
397
- },
398
277
{
399
278
"accessKeyId": 0,
400
279
"dataTransferred": {
401
- "bytes": 1000
280
+ "bytes": 12000
402
281
},
403
282
"tunnelTime": {
404
- "seconds": 0
283
+ "seconds": 1000
405
284
},
406
285
"connection": {
407
- "lastTrafficSeen": 1738959398 ,
286
+ "lastTrafficSeen": 1739284734 ,
408
287
"peakDeviceCount": {
409
288
"data": 4,
410
289
"timestamp": 1738959398
0 commit comments