@@ -359,31 +359,31 @@ func TestObjective_Burnrates(t *testing.T) {
359
359
Interval : monitoringDuration ("30s" ),
360
360
Rules : []monitoringv1.Rule {{
361
361
Record : "http_request_duration_seconds:burnrate5m" ,
362
- Expr : intstr .FromString (`1 - histogram_fraction(0, 1, rate(http_request_duration_seconds{code=~"2..",job="metrics-service-thanos-receive-default"}[5m]))` ),
362
+ Expr : intstr .FromString (`1 - histogram_fraction(0, 1, sum( rate(http_request_duration_seconds{code=~"2..",job="metrics-service-thanos-receive-default"}[5m]) ))` ),
363
363
Labels : map [string ]string {"job" : "metrics-service-thanos-receive-default" , "slo" : "monitoring-http-latency" },
364
364
}, {
365
365
Record : "http_request_duration_seconds:burnrate30m" ,
366
- Expr : intstr .FromString (`1 - histogram_fraction(0, 1, rate(http_request_duration_seconds{code=~"2..",job="metrics-service-thanos-receive-default"}[30m]))` ),
366
+ Expr : intstr .FromString (`1 - histogram_fraction(0, 1, sum( rate(http_request_duration_seconds{code=~"2..",job="metrics-service-thanos-receive-default"}[30m]) ))` ),
367
367
Labels : map [string ]string {"job" : "metrics-service-thanos-receive-default" , "slo" : "monitoring-http-latency" },
368
368
}, {
369
369
Record : "http_request_duration_seconds:burnrate1h" ,
370
- Expr : intstr .FromString (`1 - histogram_fraction(0, 1, rate(http_request_duration_seconds{code=~"2..",job="metrics-service-thanos-receive-default"}[1h]))` ),
370
+ Expr : intstr .FromString (`1 - histogram_fraction(0, 1, sum( rate(http_request_duration_seconds{code=~"2..",job="metrics-service-thanos-receive-default"}[1h]) ))` ),
371
371
Labels : map [string ]string {"job" : "metrics-service-thanos-receive-default" , "slo" : "monitoring-http-latency" },
372
372
}, {
373
373
Record : "http_request_duration_seconds:burnrate2h" ,
374
- Expr : intstr .FromString (`1 - histogram_fraction(0, 1, rate(http_request_duration_seconds{code=~"2..",job="metrics-service-thanos-receive-default"}[2h]))` ),
374
+ Expr : intstr .FromString (`1 - histogram_fraction(0, 1, sum( rate(http_request_duration_seconds{code=~"2..",job="metrics-service-thanos-receive-default"}[2h]) ))` ),
375
375
Labels : map [string ]string {"job" : "metrics-service-thanos-receive-default" , "slo" : "monitoring-http-latency" },
376
376
}, {
377
377
Record : "http_request_duration_seconds:burnrate6h" ,
378
- Expr : intstr .FromString (`1 - histogram_fraction(0, 1, rate(http_request_duration_seconds{code=~"2..",job="metrics-service-thanos-receive-default"}[6h]))` ),
378
+ Expr : intstr .FromString (`1 - histogram_fraction(0, 1, sum( rate(http_request_duration_seconds{code=~"2..",job="metrics-service-thanos-receive-default"}[6h]) ))` ),
379
379
Labels : map [string ]string {"job" : "metrics-service-thanos-receive-default" , "slo" : "monitoring-http-latency" },
380
380
}, {
381
381
Record : "http_request_duration_seconds:burnrate1d" ,
382
- Expr : intstr .FromString (`1 - histogram_fraction(0, 1, rate(http_request_duration_seconds{code=~"2..",job="metrics-service-thanos-receive-default"}[1d]))` ),
382
+ Expr : intstr .FromString (`1 - histogram_fraction(0, 1, sum( rate(http_request_duration_seconds{code=~"2..",job="metrics-service-thanos-receive-default"}[1d]) ))` ),
383
383
Labels : map [string ]string {"job" : "metrics-service-thanos-receive-default" , "slo" : "monitoring-http-latency" },
384
384
}, {
385
385
Record : "http_request_duration_seconds:burnrate4d" ,
386
- Expr : intstr .FromString (`1 - histogram_fraction(0, 1, rate(http_request_duration_seconds{code=~"2..",job="metrics-service-thanos-receive-default"}[4d]))` ),
386
+ Expr : intstr .FromString (`1 - histogram_fraction(0, 1, sum( rate(http_request_duration_seconds{code=~"2..",job="metrics-service-thanos-receive-default"}[4d]) ))` ),
387
387
Labels : map [string ]string {"job" : "metrics-service-thanos-receive-default" , "slo" : "monitoring-http-latency" },
388
388
}, {
389
389
Alert : "ErrorBudgetBurn" ,
@@ -1369,11 +1369,11 @@ func TestObjective_IncreaseRules(t *testing.T) {
1369
1369
Interval : monitoringDuration ("2m30s" ),
1370
1370
Rules : []monitoringv1.Rule {{
1371
1371
Record : "http_request_duration_seconds:increase4w" ,
1372
- Expr : intstr .FromString (`histogram_count(increase(http_request_duration_seconds{code=~"2..",job="metrics-service-thanos-receive-default"}[4w]))` ),
1372
+ Expr : intstr .FromString (`histogram_count(sum( increase(http_request_duration_seconds{code=~"2..",job="metrics-service-thanos-receive-default"}[4w]) ))` ),
1373
1373
Labels : map [string ]string {"job" : "metrics-service-thanos-receive-default" , "slo" : "monitoring-http-latency" },
1374
1374
}, {
1375
1375
Record : "http_request_duration_seconds:increase4w" ,
1376
- Expr : intstr .FromString (`histogram_fraction(0, 1, increase(http_request_duration_seconds{code=~"2..",job="metrics-service-thanos-receive-default"}[4w])) * histogram_count(increase(http_request_duration_seconds{code=~"2..",job="metrics-service-thanos-receive-default"}[4w]))` ),
1376
+ Expr : intstr .FromString (`histogram_fraction(0, 1, sum( increase(http_request_duration_seconds{code=~"2..",job="metrics-service-thanos-receive-default"}[4w]))) * histogram_count(sum( increase(http_request_duration_seconds{code=~"2..",job="metrics-service-thanos-receive-default"}[4w]) ))` ),
1377
1377
Labels : map [string ]string {"job" : "metrics-service-thanos-receive-default" , "slo" : "monitoring-http-latency" , "le" : "1" },
1378
1378
//}, {
1379
1379
// Alert: "SLOMetricAbsent",
@@ -1774,6 +1774,26 @@ func TestObjective_GrafanaRules(t *testing.T) {
1774
1774
Labels : map [string ]string {"slo" : "monitoring-http-latency" },
1775
1775
}},
1776
1776
},
1777
+ }, {
1778
+ name : "http-latency-native" ,
1779
+ slo : objectiveHTTPNativeLatency (),
1780
+ rules : monitoringv1.RuleGroup {
1781
+ Name : "monitoring-http-latency-generic" ,
1782
+ Interval : monitoringDuration ("30s" ),
1783
+ Rules : []monitoringv1.Rule {{
1784
+ Record : "pyrra_objective" ,
1785
+ Expr : intstr .FromString ("0.995" ),
1786
+ Labels : map [string ]string {"slo" : "monitoring-http-latency" },
1787
+ }, {
1788
+ Record : "pyrra_window" ,
1789
+ Expr : intstr .FromString ("2419200" ),
1790
+ Labels : map [string ]string {"slo" : "monitoring-http-latency" },
1791
+ }, {
1792
+ Record : "pyrra_availability" ,
1793
+ Expr : intstr .FromString (`sum(http_request_duration_seconds:increase4w{code=~"2..",job="metrics-service-thanos-receive-default",le="1",slo="monitoring-http-latency"} or vector(0)) / sum(http_request_duration_seconds:increase4w{code=~"2..",job="metrics-service-thanos-receive-default",le="",slo="monitoring-http-latency"})` ),
1794
+ Labels : map [string ]string {"slo" : "monitoring-http-latency" },
1795
+ }},
1796
+ },
1777
1797
}, {
1778
1798
name : "http-latency-grouping" ,
1779
1799
slo : objectiveHTTPLatencyGrouping (),
@@ -1912,7 +1932,7 @@ func TestObjective_GrafanaRules(t *testing.T) {
1912
1932
err : ErrGroupingUnsupported ,
1913
1933
}}
1914
1934
1915
- require .Len (t , testcases , 16 )
1935
+ require .Len (t , testcases , 17 )
1916
1936
1917
1937
for _ , tc := range testcases {
1918
1938
t .Run (tc .name , func (t * testing.T ) {
0 commit comments