-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[Stack Monitoring] Prevent exceptions in rule when no data present #131332
[Stack Monitoring] Prevent exceptions in rule when no data present #131332
Conversation
Pinging @elastic/infra-monitoring-ui (Team:Infra Monitoring UI) |
if (!response.aggregations) { | ||
return stats; | ||
} | ||
|
||
// @ts-expect-error declare aggegations type explicitly | ||
const { buckets: remoteClusterBuckets = [] } = response.aggregations?.remote_clusters; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since we have that new check above, do we still need to keep the question mark here response.aggregations?
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, will change that!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🙌
LGTM : ! Better even would be if response could be properly typed in the future |
@elasticmachine merge upstream |
💚 Build SucceededMetrics [docs]
History
To update your PR or re-run it, just comment with: |
…lastic#131332) * [Stack Monitoring] Prevent exceptions in rule when no data present (elastic#120111) * Remove optional chaining Co-authored-by: Kibana Machine <[email protected]>
Fixes #120111
When there is no data, the aggregations property of the ES response is omitted. When we then try to destructure that to get the buckets we run into a null pointer exception.
This PR simply adds a check to each affected rule to see if there are aggregations on the response object, if not we return early.
As a follow up we need decide how to inform the user that these rules are doing nothing (just eating CPU) until some data is present or they are disabled.