@@ -57,7 +57,7 @@ func TestDistributedExecution(t *testing.T) {
57
57
expr : `sum by (pod) (rate(http_requests_total[5m]))` ,
58
58
expected : `
59
59
sum by (pod) (dedup(
60
- remote(sum by (pod, region) (rate(http_requests_total[5m]))),
60
+ remote(sum by (pod, region) (rate(http_requests_total[5m]))),
61
61
remote(sum by (pod, region) (rate(http_requests_total[5m])))))` ,
62
62
},
63
63
{
@@ -158,7 +158,7 @@ sum by (pod) (
158
158
expr : `max by (pod) (sum by (pod) (http_requests_total))` ,
159
159
expected : `
160
160
max by (pod) (
161
- sum by (pod) (
161
+ sum by (pod) (
162
162
dedup(
163
163
remote(sum by (pod, region) (http_requests_total)),
164
164
remote(sum by (pod, region) (http_requests_total))
@@ -194,7 +194,7 @@ max by (pod) (quantile(0.9,
194
194
expr : `label_replace(http_requests_total, "pod", "$1", "instance", "(.*)")` ,
195
195
expected : `
196
196
dedup(
197
- remote(label_replace(http_requests_total, "pod", "$1", "instance", "(.*)")),
197
+ remote(label_replace(http_requests_total, "pod", "$1", "instance", "(.*)")),
198
198
remote(label_replace(http_requests_total, "pod", "$1", "instance", "(.*)"))
199
199
)` ,
200
200
},
@@ -204,7 +204,7 @@ dedup(
204
204
expected : `
205
205
max by (instance) (
206
206
dedup(
207
- remote(max by (instance, region) (label_replace(http_requests_total, "pod", "$1", "instance", "(.*)"))),
207
+ remote(max by (instance, region) (label_replace(http_requests_total, "pod", "$1", "instance", "(.*)"))),
208
208
remote(max by (instance, region) (label_replace(http_requests_total, "pod", "$1", "instance", "(.*)")))
209
209
)
210
210
)` ,
@@ -214,7 +214,7 @@ max by (instance) (
214
214
expr : `max by (location) (label_replace(http_requests_total, "zone", "$1", "location", "(.*)"))` ,
215
215
expected : `
216
216
max by (location) (dedup(
217
- remote(max by (location, region) (label_replace(http_requests_total, "zone", "$1", "location", "(.*)"))),
217
+ remote(max by (location, region) (label_replace(http_requests_total, "zone", "$1", "location", "(.*)"))),
218
218
remote(max by (location, region) (label_replace(http_requests_total, "zone", "$1", "location", "(.*)")))
219
219
))` ,
220
220
},
@@ -237,20 +237,20 @@ max by (location) (dedup(
237
237
sum by (location) (
238
238
dedup(
239
239
remote(sum by (location, region) (label_replace(http_requests_total, "zone", "$1", "location", "(.*)"))),
240
- remote(sum by (location, region) (label_replace(http_requests_total, "zone", "$1", "location", "(.*)")))))
240
+ remote(sum by (location, region) (label_replace(http_requests_total, "zone", "$1", "location", "(.*)")))))
241
241
/ on (location)
242
242
sum by (location) (
243
243
dedup(
244
244
remote(count by (location, region) (label_replace(http_requests_total, "zone", "$1", "location", "(.*)"))),
245
- remote(count by (location, region) (label_replace(http_requests_total, "zone", "$1", "location", "(.*)")))))
245
+ remote(count by (location, region) (label_replace(http_requests_total, "zone", "$1", "location", "(.*)")))))
246
246
` ,
247
247
},
248
248
{
249
249
name : "label replace after an aggregation" ,
250
250
expr : `label_replace(max by (location) (http_requests_total), "region", "$1", "location", "(.*)")` ,
251
251
expected : `
252
252
label_replace(max by (location) (dedup(
253
- remote(max by (location, region) (http_requests_total)),
253
+ remote(max by (location, region) (http_requests_total)),
254
254
remote(max by (location, region) (http_requests_total))
255
255
)), "region", "$1", "location", "(.*)")` ,
256
256
expectWarn : true ,
@@ -272,12 +272,12 @@ max by (pod) (
272
272
expr : `sum by (pod) (metric_a) / sum by (pod) (metric_b)` ,
273
273
expected : `
274
274
sum by (pod) (dedup(
275
- remote(sum by (pod, region) (metric_a)),
275
+ remote(sum by (pod, region) (metric_a)),
276
276
remote(sum by (pod, region) (metric_a)))
277
277
)
278
- /
278
+ /
279
279
sum by (pod) (dedup(
280
- remote(sum by (pod, region) (metric_b)),
280
+ remote(sum by (pod, region) (metric_b)),
281
281
remote(sum by (pod, region) (metric_b))
282
282
))` ,
283
283
},
@@ -286,7 +286,7 @@ sum by (pod) (dedup(
286
286
expr : `rate(http_requests_total[2m])` ,
287
287
expected : `
288
288
dedup(
289
- remote(rate(http_requests_total[2m])),
289
+ remote(rate(http_requests_total[2m])),
290
290
remote(rate(http_requests_total[2m]))
291
291
)` ,
292
292
},
@@ -305,7 +305,7 @@ dedup(
305
305
expr : `histogram_quantile(0.5, sum by (le) (rate(coredns_dns_request_duration_seconds_bucket[5m])))` ,
306
306
expected : `
307
307
histogram_quantile(0.5, sum by (le) (dedup(
308
- remote(sum by (le, region) (rate(coredns_dns_request_duration_seconds_bucket[5m]))),
308
+ remote(sum by (le, region) (rate(coredns_dns_request_duration_seconds_bucket[5m]))),
309
309
remote(sum by (le, region) (rate(coredns_dns_request_duration_seconds_bucket[5m])))
310
310
)))` ,
311
311
},
@@ -338,7 +338,7 @@ histogram_quantile(0.5, sum by (le) (dedup(
338
338
name : "binary expression with constant" ,
339
339
expr : `sum by (pod) (rate(http_requests_total[2m]) * 60)` ,
340
340
expected : `sum by (pod) (dedup(
341
- remote(sum by (pod, region) (rate(http_requests_total[2m]) * 60)),
341
+ remote(sum by (pod, region) (rate(http_requests_total[2m]) * 60)),
342
342
remote(sum by (pod, region) (rate(http_requests_total[2m]) * 60))))` ,
343
343
},
344
344
{
@@ -361,7 +361,7 @@ remote(sum by (pod, region) (rate(http_requests_total[2m]) * 60))))`,
361
361
expr : `sum_over_time(max(http_requests_total)[5m:1m])` ,
362
362
expected : `
363
363
sum_over_time(max(dedup(
364
- remote(max by (region) (http_requests_total)) [1969-12-31 23:55:00 +0000 UTC, 1970-01-01 00:00:00 +0000 UTC],
364
+ remote(max by (region) (http_requests_total)) [1969-12-31 23:55:00 +0000 UTC, 1970-01-01 00:00:00 +0000 UTC],
365
365
remote(max by (region) (http_requests_total)) [1969-12-31 23:55:00 +0000 UTC, 1970-01-01 00:00:00 +0000 UTC])
366
366
)[5m:1m])` ,
367
367
},
@@ -415,7 +415,7 @@ count by (cluster) (
415
415
)` ,
416
416
expected : `
417
417
sum by (cluster) (dedup(
418
- remote(count by (cluster, region) (label_replace(up, "ns", "$0", "namespace", ".*") * on (region) group_left (project) label_replace(k8s_cluster_info, "k8s_cluster", "$0", "cluster", ".*"))),
418
+ remote(count by (cluster, region) (label_replace(up, "ns", "$0", "namespace", ".*") * on (region) group_left (project) label_replace(k8s_cluster_info, "k8s_cluster", "$0", "cluster", ".*"))),
419
419
remote(count by (cluster, region) (label_replace(up, "ns", "$0", "namespace", ".*") * on (region) group_left (project) label_replace(k8s_cluster_info, "k8s_cluster", "$0", "cluster", ".*"))))
420
420
)` ,
421
421
},
@@ -548,7 +548,7 @@ dedup(
548
548
expr : `sum_over_time(sum_over_time(metric[1h])[1h:30m])` ,
549
549
expected : `
550
550
dedup(
551
- remote(sum_over_time(sum_over_time(metric[1h])[1h:30m])),
551
+ remote(sum_over_time(sum_over_time(metric[1h])[1h:30m])),
552
552
remote(sum_over_time(sum_over_time(metric[1h])[1h:30m])) [1970-01-01 08:00:00 +0000 UTC, 1970-01-01 12:00:00 +0000 UTC]
553
553
)` ,
554
554
},
@@ -606,7 +606,7 @@ dedup(
606
606
expr : `sum(metric @ 25200)` ,
607
607
expected : `
608
608
sum(dedup(
609
- remote(sum by (region) (metric @ 25200.000)),
609
+ remote(sum by (region) (metric @ 25200.000)),
610
610
remote(sum by (region) (metric @ 25200.000)) [1970-01-01 06:00:00 +0000 UTC, 1970-01-01 12:00:00 +0000 UTC]
611
611
))` ,
612
612
},
@@ -685,7 +685,7 @@ func TestDistributedExecutionPruningByTime(t *testing.T) {
685
685
expected : `
686
686
sum(
687
687
dedup(
688
- remote(sum by (region) (metric)) [1970-01-01 06:00:00 +0000 UTC, 1970-01-01 06:00:00 +0000 UTC],
688
+ remote(sum by (region) (metric)) [1970-01-01 06:00:00 +0000 UTC, 1970-01-01 06:00:00 +0000 UTC],
689
689
remote(sum by (region) (metric)) [1970-01-01 06:00:00 +0000 UTC, 1970-01-01 06:00:00 +0000 UTC]
690
690
)
691
691
)` ,
@@ -720,7 +720,7 @@ func TestDistributedExecutionClonesNodes(t *testing.T) {
720
720
step = time .Second
721
721
expected = `
722
722
sum(dedup(
723
- remote(sum by (region) (metric{region="east"})),
723
+ remote(sum by (region) (metric{region="east"})),
724
724
remote(sum by (region) (metric{region="east"}))
725
725
))`
726
726
)
@@ -776,6 +776,10 @@ func (e engineMock) LabelSets() []labels.Labels {
776
776
return e .labelSets
777
777
}
778
778
779
+ func (e engineMock ) PartitionLabelSets () []labels.Labels {
780
+ return e .labelSets
781
+ }
782
+
779
783
func newEngineMock (mint , maxt int64 , labelSets []labels.Labels ) * engineMock {
780
784
return & engineMock {minT : mint , maxT : maxt , labelSets : labelSets }
781
785
}
0 commit comments