-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
[Response Ops][Alerting] Remove rules client from alerting task runner #194300
Conversation
e288d62
to
6ee8230
Compare
return true; | ||
} | ||
}) | ||
: []; | ||
|
||
if (snoozeSchedule.length === rule.snoozeSchedule?.length) return; | ||
|
||
const updateAttributes = updateMeta(context, { |
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.
This updateMeta
function adds some fields if we're updating the apiKey
or apiKeyOwner
fields, which we're not.
snoozeSchedule, | ||
updatedBy: await context.getUserName(), |
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 it's the alerting framework updating the saved object, we should not need to identify a username for this update, we don't do it when updating the rule SO after each rule execution.
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.
Also removed updatedAt
since we don't update that value when we make other partial updates to the rule during rule execution and this limits the number of fields we allow to update via ES.
x-pack/plugins/alerting/server/task_runner/lib/clear_expired_snoozes.ts
Outdated
Show resolved
Hide resolved
Pinging @elastic/response-ops (Team:ResponseOps) |
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
@elasticmachine merge upstream |
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.
Great improvements!
💛 Build succeeded, but was flaky
Failed CI StepsTest Failures
Metrics [docs]Public APIs missing exports
History
To update your PR or re-run it, just comment with: cc @ymao1 |
Starting backport for target branches: 8.x https://github.com/elastic/kibana/actions/runs/11165341287 |
elastic#194300) ## Summary Initializing the rules client with every rule execution causes 2 requests to Elasticsearch, a `POST /_security/user/_has_privileges` request and a `GET/.kibana_<version>/_doc/space:<spaceId>` request. We only use the rules client to proxy two methods `getAlertFromRaw` and `clearExpiredSnoozes`. Both of these methods can be converted into library functions that can be used without the rules client. This PR makes that conversion. --------- Co-authored-by: Elastic Machine <[email protected]> (cherry picked from commit 326f813)
💚 All backports created successfully
Note: Successful backport PRs will be merged automatically after passing CI. Questions ?Please refer to the Backport tool documentation |
… runner (#194300) (#194858) # Backport This will backport the following commits from `main` to `8.x`: - [[Response Ops][Alerting] Remove rules client from alerting task runner (#194300)](#194300) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Ying Mao","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-03T15:53:06Z","message":"[Response Ops][Alerting] Remove rules client from alerting task runner (#194300)\n\n## Summary\r\n\r\nInitializing the rules client with every rule execution causes 2\r\nrequests to Elasticsearch, a `POST /_security/user/_has_privileges`\r\nrequest and a `GET/.kibana_<version>/_doc/space:<spaceId>` request. We\r\nonly use the rules client to proxy two methods `getAlertFromRaw` and\r\n`clearExpiredSnoozes`. Both of these methods can be converted into\r\nlibrary functions that can be used without the rules client. This PR\r\nmakes that conversion.\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <[email protected]>","sha":"326f81398472e160fec254c05541aa2a588a7f70","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Alerting","release_note:skip","Team:ResponseOps","v9.0.0","backport:prev-minor","v8.16.0"],"title":"[Response Ops][Alerting] Remove rules client from alerting task runner","number":194300,"url":"https://github.com/elastic/kibana/pull/194300","mergeCommit":{"message":"[Response Ops][Alerting] Remove rules client from alerting task runner (#194300)\n\n## Summary\r\n\r\nInitializing the rules client with every rule execution causes 2\r\nrequests to Elasticsearch, a `POST /_security/user/_has_privileges`\r\nrequest and a `GET/.kibana_<version>/_doc/space:<spaceId>` request. We\r\nonly use the rules client to proxy two methods `getAlertFromRaw` and\r\n`clearExpiredSnoozes`. Both of these methods can be converted into\r\nlibrary functions that can be used without the rules client. This PR\r\nmakes that conversion.\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <[email protected]>","sha":"326f81398472e160fec254c05541aa2a588a7f70"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/194300","number":194300,"mergeCommit":{"message":"[Response Ops][Alerting] Remove rules client from alerting task runner (#194300)\n\n## Summary\r\n\r\nInitializing the rules client with every rule execution causes 2\r\nrequests to Elasticsearch, a `POST /_security/user/_has_privileges`\r\nrequest and a `GET/.kibana_<version>/_doc/space:<spaceId>` request. We\r\nonly use the rules client to proxy two methods `getAlertFromRaw` and\r\n`clearExpiredSnoozes`. Both of these methods can be converted into\r\nlibrary functions that can be used without the rules client. This PR\r\nmakes that conversion.\r\n\r\n---------\r\n\r\nCo-authored-by: Elastic Machine <[email protected]>","sha":"326f81398472e160fec254c05541aa2a588a7f70"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Ying Mao <[email protected]>
elastic#194300) ## Summary Initializing the rules client with every rule execution causes 2 requests to Elasticsearch, a `POST /_security/user/_has_privileges` request and a `GET/.kibana_<version>/_doc/space:<spaceId>` request. We only use the rules client to proxy two methods `getAlertFromRaw` and `clearExpiredSnoozes`. Both of these methods can be converted into library functions that can be used without the rules client. This PR makes that conversion. --------- Co-authored-by: Elastic Machine <[email protected]>
elastic#194300) ## Summary Initializing the rules client with every rule execution causes 2 requests to Elasticsearch, a `POST /_security/user/_has_privileges` request and a `GET/.kibana_<version>/_doc/space:<spaceId>` request. We only use the rules client to proxy two methods `getAlertFromRaw` and `clearExpiredSnoozes`. Both of these methods can be converted into library functions that can be used without the rules client. This PR makes that conversion. --------- Co-authored-by: Elastic Machine <[email protected]>
Summary
Initializing the rules client with every rule execution causes 2 requests to Elasticsearch, a
POST /_security/user/_has_privileges
request and aGET/.kibana_<version>/_doc/space:<spaceId>
request. We only use the rules client to proxy two methodsgetAlertFromRaw
andclearExpiredSnoozes
. Both of these methods can be converted into library functions that can be used without the rules client. This PR makes that conversion.