Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG][OBX-UX-MNGMT] Fix IS_NOT_BETWEEN comparator for the custom threshold, Infra, Metric rules #171925

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ export const createConditionScript = (
}
if (comparator === Comparator.OUTSIDE_RANGE && threshold.length === 2) {
return {
source: `params.value < params.threshold0 && params.value > params.threshold1 ? 1 : 0`,
// OUTSIDE_RANGE/NOT BETWEEN is the opposite of BETWEEN. Use the BETWEEN condition and switch the 1 and 0
source: `params.value > params.threshold0 && params.value < params.threshold1 ? 0 : 1`,
params: {
threshold0: threshold[0],
threshold1: threshold[1],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export const createConditionScript = (threshold: number[], comparator: Comparato
}
if (comparator === Comparator.OUTSIDE_RANGE && threshold.length === 2) {
return {
source: `params.value < params.threshold0 && params.value > params.threshold1 ? 1 : 0`,
// OUTSIDE_RANGE/NOT BETWEEN is the opposite of BETWEEN. Use the BETWEEN condition and switch the 1 and 0
source: `params.value > params.threshold0 && params.value < params.threshold1 ? 0 : 1`,
params: {
threshold0: threshold[0],
threshold1: threshold[1],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ export const createConditionScript = (threshold: number[], comparator: Comparato
}
if (comparator === Comparator.OUTSIDE_RANGE && threshold.length === 2) {
return {
source: `params.value < params.threshold0 && params.value > params.threshold1 ? 1 : 0`,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also fix it by using || instead of &&, and it will give exactly the same outcomes.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would it work then, with threshold0 being the start of the range?

Copy link
Contributor Author

@fkanout fkanout Nov 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will work as expected and as the current solution. Whoever comes to true first, params.value < params.threshold0 or params.value > params.threshold1, the rule will trigger an alert.

// OUTSIDE_RANGE/NOT BETWEEN is the opposite of BETWEEN. Use the BETWEEN condition and switch the 1 and 0
source: `params.value > params.threshold0 && params.value < params.threshold1 ? 0 : 1`,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shall we change one of the API integration tests to is not between?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, @maryam-saeidi. I was thinking about adding a new test case for it. I will give it a try in the PR

params: {
threshold0: threshold[0],
threshold1: threshold[1],
Expand Down