Skip to content

Commit dc59e31

Browse files
committed
test: account for pdb and Prometheus' staleness period
Problem: We recently introduced pod disruption budgets and improved availability on Prometheus. This is reflected in the up metric for Prometheus. By virtue of Prometheus staleness mechanism (it will return samples up to 5m old for a series) the old query can appear to see 4 Prometheus instances. Solution: Use the last_over_time aggregation with a 2m interval to only look at the last sample in that interval. This effectively adjusts Prometheus staleness period to 2m. Signed-off-by: Jan Fajerski <[email protected]>
1 parent 650c320 commit dc59e31

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

test/e2e/main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ func testMain(m *testing.M) error {
8484
body []byte
8585
v int
8686
)
87-
body, loopErr = f.ThanosQuerierClient.PrometheusQuery("count(up{job=\"prometheus-k8s\"})")
87+
body, loopErr = f.ThanosQuerierClient.PrometheusQuery("count(last_over_time(up{job=\"prometheus-k8s\"}[2m]))")
8888
if loopErr != nil {
8989
loopErr = errors.Wrap(loopErr, "error executing prometheus query")
9090
return false, nil

0 commit comments

Comments
 (0)