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

[Infrastructure UI][Rules] Change bucket_scripts to use params for thresholds #133214

Merged

Conversation

simianhacker
Copy link
Member

@simianhacker simianhacker commented May 31, 2022

Summary

This PR fixes #133210 by changing the Metric Threshold Rule and Inventory Threshold Rule to use params for the thresholds instead of hard coding them.

Before:

"shouldTrigger": {
  "bucket_script": {
    "buckets_path": {
      "value": "rx"
    },
      "script": "params.value > 107374182400 ? 1 : 0"
  }
}

After:

"shouldTrigger": {
  "bucket_script": {
    "buckets_path": {
      "value": "rx"
    },
      "script": {
        "source":"params.value > params.threshold ? 1 : 0",
        "params": {
          "threshold": 107374182400
        }
      }
  }
}

Checklist

Note to Reviewers

I'm aware that there is duplicate code between these two rules, specifically the create_condition_script.ts. When these two rules were written, they were developed simultaneously; both PRs sat in review for a while. The plan is to refactor both of these rules to remove the duplication while implementing #131205 Please consider "deduplicating code" out of scope for this PR.

@simianhacker simianhacker added bug Fixes for quality problems that affect the customer experience release_note:fix Feature:Metrics UI Metrics UI feature Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services Team: Actionable Observability - DEPRECATED For Observability Alerting and SLOs use "Team:obs-ux-management", for AIops "Team:obs-knowledge" v8.3.0 labels May 31, 2022
@simianhacker simianhacker requested a review from a team as a code owner May 31, 2022 12:53
@elasticmachine
Copy link
Contributor

Pinging @elastic/infra-monitoring-ui (Team:Infra Monitoring UI)

@elasticmachine
Copy link
Contributor

Pinging @elastic/actionable-observability (Team: Actionable Observability)

@simianhacker simianhacker changed the title [Infrastructure UI][Rules] Change bucket_scripts to use params for threshlds [Infrastructure UI][Rules] Change bucket_scripts to use params for thresholds May 31, 2022
@fkanout fkanout self-requested a review May 31, 2022 14:06
Copy link
Contributor

@fkanout fkanout left a comment

Choose a reason for hiding this comment

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

LGTM. Tested and the rule is executed with no issue after the fix.
Screenshot 2022-05-31 at 16 09 18

@simianhacker simianhacker added auto-backport Deprecated - use backport:version if exact versions are needed v8.4.0 labels May 31, 2022
@simianhacker simianhacker enabled auto-merge (squash) May 31, 2022 15:27
Copy link
Member

@jasonrhodes jasonrhodes left a comment

Choose a reason for hiding this comment

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

@simianhacker so this looks like it's pulling two items off an existing array and storing them as numbered values? Can you help me understand what this actually changes?

@simianhacker
Copy link
Member Author

@jasonrhodes This changes the format of the script so instead of writing the values as Painless constants, params.value > ${threshold[0]} ? 1 : 0 which would end up looking like params.value > 107374182400 ? 1 : 0, it uses script parameters. The primary issue with using constants is that for numbers larger than the max integer (32bit), you would have to properly cast them like (Long)107374182400 where when you use script parameters, Painless automatically cast them.

Functionality wise, it's the same but without the Painless casting error.

Copy link
Member

@jasonrhodes jasonrhodes left a comment

Choose a reason for hiding this comment

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

Ah ok, thanks for the explanation. These changes LGTM in general. I'll defer to you and @fkanout for the more complete testing but from our end, :shipit:

@simianhacker
Copy link
Member Author

@elasticmachine merge upstream

@simianhacker simianhacker merged commit b237814 into elastic:main Jun 2, 2022
@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

@kibanamachine
Copy link
Contributor

💚 All backports created successfully

Status Branch Result
8.3

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

kibanamachine added a commit that referenced this pull request Jun 2, 2022
…resholds (#133214) (#133414)

(cherry picked from commit b237814)

Co-authored-by: Chris Cowan <chris@elastic.co>
@simianhacker simianhacker deleted the issue-133210-use-params-for-thresholds branch April 17, 2024 15:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
auto-backport Deprecated - use backport:version if exact versions are needed bug Fixes for quality problems that affect the customer experience Feature:Metrics UI Metrics UI feature release_note:fix Team: Actionable Observability - DEPRECATED For Observability Alerting and SLOs use "Team:obs-ux-management", for AIops "Team:obs-knowledge" Team:Infra Monitoring UI - DEPRECATED DEPRECATED - Label for the Infra Monitoring UI team. Use Team:obs-ux-infra_services v8.3.0 v8.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Infrastructure UI][Rules] Bucket scripts should use params for thresholds
6 participants