Skip to content

Commit

Permalink
allow to skip values in alerts checks
Browse files Browse the repository at this point in the history
  • Loading branch information
vpalmisano committed Feb 5, 2024
1 parent 581c493 commit 6b176f9
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/stats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,10 @@ export type AlertRuleValue = {
$lte?: number
$after?: number
$before?: number
$skip_lt?: number
$skip_lte?: number
$skip_gt?: number
$skip_gte?: number
}

const calculateFailAmount = (checkValue: number, ruleValue: number): number => {
Expand Down Expand Up @@ -1459,6 +1463,20 @@ export class Stats extends events.EventEmitter {
const ruleDesc = this.getAlertRuleDesc(ruleKey, ruleValue)
let failed = false
let failAmount = 0

if (
(ruleValue.$skip_lt !== undefined &&
checkValue < ruleValue.$skip_lt) ||
(ruleValue.$skip_lte !== undefined &&
checkValue <= ruleValue.$skip_lte) ||
(ruleValue.$skip_gt !== undefined &&
checkValue > ruleValue.$skip_gt) ||
(ruleValue.$skip_gte !== undefined &&
checkValue >= ruleValue.$skip_gte)
) {
continue
}

if (ruleValue.$eq !== undefined) {
if (checkValue !== ruleValue.$eq) {
failed = true
Expand Down

0 comments on commit 6b176f9

Please sign in to comment.