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

Conversation

fkanout
Copy link
Contributor

@fkanout fkanout commented Nov 24, 2023

Summary

Fixes #169524

Fix the painless script that evaluates the IS_NOT_BETWEEN for the Custom Threshold, Metric, Infra rules.

Screenshot 2023-11-24 at 15 03 18

@fkanout fkanout added bug Fixes for quality problems that affect the customer experience Feature:Alerting release_note:skip Skip the PR/issue when compiling release notes backport:skip This commit does not require backporting Team:obs-ux-management Observability Management User Experience Team Feature: Custom threshold Observability custom threshold rule type labels Nov 24, 2023
@fkanout fkanout self-assigned this Nov 24, 2023
@fkanout fkanout requested a review from a team as a code owner November 24, 2023 14:09
@elasticmachine
Copy link
Contributor

Pinging @elastic/obs-ux-management-team (Team:obs-ux-management)

@apmmachine
Copy link
Contributor

🤖 GitHub comments

Expand to view the GitHub comments

Just comment with:

  • /oblt-deploy : Deploy a Kibana instance using the Observability test environments.
  • /oblt-deploy-serverless : Deploy a serverless Kibana instance using the Observability test environments.
  • run elasticsearch-ci/docs : Re-trigger the docs validation. (use unformatted text in the comment!)

@@ -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.

Copy link
Member

@maryam-saeidi maryam-saeidi left a comment

Choose a reason for hiding this comment

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

Worked as expected, just added a comment about testing!

image

@@ -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`,
// 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

@fkanout
Copy link
Contributor Author

fkanout commented Nov 27, 2023

@elasticmachine merge upstream

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

✅ unchanged

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @fkanout

Copy link
Member

@maryam-saeidi maryam-saeidi left a comment

Choose a reason for hiding this comment

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

LGTM! 👍🏻

@fkanout fkanout merged commit 025fb30 into elastic:main Nov 28, 2023
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting bug Fixes for quality problems that affect the customer experience Feature:Alerting Feature: Custom threshold Observability custom threshold rule type release_note:skip Skip the PR/issue when compiling release notes Team:obs-ux-management Observability Management User Experience Team v8.12.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Is not between comparator does not work for the custom threshold rule
6 participants