Skip to content

Commit

Permalink
Merge pull request #677 from HO-CTO/feature/sw-adjust-sli-protect-fro…
Browse files Browse the repository at this point in the history
…m-division-by-0

fix: Generate correct value for SLI even if there are no metrics available (div/0)
  • Loading branch information
sponte authored Oct 4, 2024
2 parents 585094e + 08036c8 commit c188ed8
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ local createSliValueRule(sliSpec, sliMetadata, config) =
expr: |||
sum without (%(selectorLabels)s) (label_replace(label_replace(
(
sum by(%(selectorLabels)s) (avg_over_time(%(failureMetric)s{%(selectors)s}[%(evalInterval)s])>=0)
/
sum by(%(selectorLabels)s) (avg_over_time(%(totalMetric)s{%(selectors)s}[%(evalInterval)s])>=0)
(
sum by(%(selectorLabels)s) (avg_over_time(%(failureMetric)s{%(selectors)s}[%(evalInterval)s])>=0)
/
sum by(%(selectorLabels)s) (avg_over_time(%(totalMetric)s{%(selectors)s}[%(evalInterval)s])>=0)
) > 0 or on() vector(0)
),
"sli_environment", "$1", "%(environmentSelectorLabel)s", "(.*)"), "sli_product", "$1", "%(productSelectorLabel)s", "(.*)"))
||| % {
Expand Down Expand Up @@ -94,9 +96,11 @@ local createGraphPanel(sliSpec) =
).addTarget(
prometheus.target(
|||
(
sum(avg_over_time(%(failureMetric)s{%(selectors)s}[%(evalInterval)s]) >=0 or vector(0))
/
sum(avg_over_time(%(totalMetric)s{%(selectors)s}[%(evalInterval)s]) >=0 or vector(0))
) > 0 or on() vector(0)
||| % {
failureMetric: targetMetrics.failure,
totalMetric: targetMetrics.total,
Expand Down

0 comments on commit c188ed8

Please sign in to comment.