Skip to content

Fix: denominator_corrected_rules/v1 (complex queries + negative SLIs) - #846

Open
r3code wants to merge 2 commits into
slok:mainfrom
vseinstrumentiru:fix/denominator-corrected-rules
Open

Fix: denominator_corrected_rules/v1 (complex queries + negative SLIs)#846
r3code wants to merge 2 commits into
slok:mainfrom
vseinstrumentiru:fix/denominator-corrected-rules

Conversation

@r3code

@r3code r3code commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

r3code and others added 2 commits September 8, 2026 13:02
Closes slok#804

Signed-off-by: Dmitriy S. Sinyavskiy <contact@r3code.ru>
On services with historically low or absent traffic that suddenly start
receiving load, the SLI calculation produced negative values (in practice,
values around ~-52000% were observed).

Root cause: the denominator_corrected_rules_v1 plugin computes the
correction factor as k = rate(5m) / rate(30d). When rate_30d is close to
zero (e.g. 0.0001 req/s) and a traffic spike brings rate_5m up to
1.0 req/s, k skyrockets to ~10000, which overflows the SLI formula
(1 - k * bad/total).

The fix caps the correction factor at 1.0 by wrapping the ratio in
clamp_max(..., 1.0), so the plugin only lowers the significance of
errors during anomalously low traffic and can no longer amplify them
during spikes after idle periods.
@r3code
r3code requested a review from slok as a code owner September 8, 2026 14:59
@r3code r3code changed the title Fix: denominator_corrected_rules/v1 (complex queries + clamp max SLI) Fix: denominator_corrected_rules/v1 (complex queries + negative SLIs) Sep 8, 2026
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 31.30%. Comparing base (8a3be4f) to head (173bff0).

Files with missing lines Patch % Lines
...o/contrib/denominator_corrected_rules_v1/plugin.go 0.00% 2 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main     #846   +/-   ##
=======================================
  Coverage   31.30%   31.30%           
=======================================
  Files         149      149           
  Lines        9228     9228           
=======================================
  Hits         2889     2889           
  Misses       6088     6088           
  Partials      251      251           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants