-
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
[Response Ops][Alerting] Reusable functions for FAAD resource installation #152849
Conversation
…in resource installer
9cf3a9e
to
60ef606
Compare
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.
Hey @ymao1,
I'm using a CCS setup. I've attempted to follow the testing instructions provided. I have added xpack.alerting.enableFrameworkAlerts: true
to kibana.dev.yml
.
I then proceeded to create an APM Latency Threshold rule, which I have configured like this:
When I clicked save, I got an error:
[2023-03-10T11:16:09.488+01:00][ERROR][plugins.alerting.apm.transaction_duration] Executing Rule default:apm.transaction_duration:8433ce40-bf2b-11ed-a8ca-e57eefdc2c75 has resulted in Error: Alert instance execution has already been scheduled, cannot schedule twice - Error: Alert instance execution has already been scheduled, cannot schedule twice
at Alert.ensureHasNoScheduledActions (alert.ts:174:13)
at Alert.scheduleActions (alert.ts:157:10)
at executor (register_transaction_duration_rule_type.ts:281:12)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Object.executor (create_lifecycle_executor.ts:215:35)
at task_runner.ts:340:28
at TaskRunnerTimer.runWithTimer (task_runner_timer.ts:49:20)
at TaskRunner.runRule (task_runner.ts:304:38)
at TaskRunner.run (task_runner.ts:671:31)
at TaskManagerRunner.run (task_runner.ts:304:22)
I am unsure if this relates to your PR or not, but as it stands I couldn't successfully test your PR.
@CoenWarmer, thanks for taking a look. That error looks to be unrelated to this PR as it's coming from the APM transaction duration rule executor. The framework throws that error if an alert with the same ID is reported twice during the same execution. Looking at the coding inside Lines 224 to 231 in e8a251a
However inside the for loop, you are creating and reporting an alertId based only on the environment value:
This means if you have buckets with the same value for environment but different values for serviceName or transactionType (which seems likely because of the multi-terms aggregation being performed), they will get reported back to the framework with the same alertID, causing this error. This seems like a bug within the rule type executor, would you like me to open an issue for this? |
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.
Changes LGTM! Tested locally and worked as expected 👍
@elasticmachine merge upstream |
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
Public APIs missing exports
Unknown metric groupsAPI count
ESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @ymao1 |
Tested and works as expected! LGTM! |
…loy-my-kibana-oblt * upstream/main: (727 commits) Upgrade caniuse-lite db (elastic#153318) [Security Solution] expanded flyout - right section - json tab implementation (elastic#152935) chore(slo): Make APM indicator's index required (elastic#153311) skip failing test suite (elastic#136688) [Security Solution] Fix security-solution storybook package codeowners (elastic#153307) [EUI] Add `scrollLock` workaround CSS to Kibana's `body` (elastic#153227) [Cloud Security] Show coming soon deployments of vulnerability management (elastic#153249) [Cloud Security] fixed onboarding link directs to cspm integration (elastic#153268) [Response Ops][Alerting] Reusable functions for FAAD resource installation (elastic#152849) remove geohash_grid aggregation support (elastic#152952) [Tech Debt] Reorder Rules page (elastic#152897) [Saved Object Finder] Add help text & left button (elastic#152742) [Transform] Replace SavedObjectsFinder component (elastic#153128) Make pipeline creation endpoint accept a full pipeline definition (elastic#153133) [Fleet] Displaying policy changes in Agent activity (elastic#153237) skip flaky suite (elastic#152852) [Security Solution][Endpoint] Add tests to cover RBAC entries in the Role Kibana Privileges flyout (elastic#153068) [Security Solution][Endpoint] Additional tests for Response Console History Log page (covers TestRail manual tests) (elastic#153042) [Monitoring] Display node roles in Nodes table (elastic#152127) Rename getEditAlertFlyout to getEditRuleFlyout (elastic#153243) ...
Resolves #152490
Summary
This PR refactors the resource installation methods in
AlertsService
to be reusable library functions. It exports them from the alerting plugin and changes the rule registry resource installer to use them as well.To Verify
enableFrameworkAlerts: true
. Verify that we can create a detection rule in the default space & a different space and generate a rule preview. The logs should show that the rule registry creates the resources for the preview indices and for indices in the non-default space.main
or a previous version, the rules continue to run successfully.