所以这里的秘密是,我想把一个范围向量转换成一个范围向量。这个
isn't possible in Prometheus, but the workaround is to use a recording rule
.
所以,需要做的是:
groups:
- name: SLOs
- rules:
- record: slo:api_response_duration_seconds:failing
expr: histogram_quantile(0.95, sum(increase(api_response_duration_seconds_bucket[1m])) by (le)) > 0.5
- record: slo:api_response_duration_seconds:all
expr: histogram_quantile(0.95, sum(increase(api_response_duration_seconds_bucket[1m])) by (le))
然后查询错误预算为
count_over_time(slo:api_response_duration_seconds:failing[28d])
/
count_over_time(slo:api_response_duration_seconds:all[28d])