[Alerting] Allow rule types to extract/inject saved object references on rule CRU#101896
[Alerting] Allow rule types to extract/inject saved object references on rule CRU#101896ymao1 merged 37 commits intoelastic:masterfrom
Conversation
…ding extractReferences to create and update workflow
…ing/saved-object-references
…/ymao1/kibana into alerting/saved-object-references
…r create and update
…ing/saved-object-references
…ing/saved-object-references
|
@elasticmachine merge upstream |
…/ymao1/kibana into alerting/saved-object-references
…ing/saved-object-references
…ing/saved-object-references
…ing/saved-object-references
There was a problem hiding this comment.
LGTM
I did this:
- Reading through the description and the example.
- Making sure I understood the example.
- In the example I saw that you can remove params as well as add them back if you only want to store them in the saved references which is 👍 great.
- Read through the two changes in files changed
I did not do this:
- I did not try to create a function that exercises this functionality and ensure it works. Assuming someone from kibana-alerting will do this part and/or a e2e test at some point from kibana-alerting.
I assume once approved we will then implement this for exception lists and then write a SO migration to upgrade existing exception lists. These two PR's could be separate from our end.
mikecote
left a comment
There was a problem hiding this comment.
Changes LGTM! I tested locally with the index threshold rule type, I was able to see it work as expected 👍
| minimumLicenseRequired: LicenseType; | ||
| useSavedObjectReferences?: { | ||
| extractReferences: (params: Params) => RuleParamsAndRefs<ExtractedParams>; | ||
| injectReferences: (params: SavedObjectAttributes, references: SavedObjectReference[]) => Params; |
There was a problem hiding this comment.
I'm thinking there's a reason for it to be SavedObjectAttributes but I figured I'd ask, should this be ExtractedParams?
| injectReferences: (params: SavedObjectAttributes, references: SavedObjectReference[]) => Params; | |
| injectReferences: (params: ExtractedParams, references: SavedObjectReference[]) => Params; |
| dateStart?: string; | ||
| } | ||
|
|
||
| const extractedSavedObjectParamReferenceNamePrefix = 'param:'; |
There was a problem hiding this comment.
optional nit: should we add a comment about modifying this value will require a migration for existing SOs with references?
|
@elasticmachine merge upstream |
|
@elasticmachine merge upstream |
…/ymao1/kibana into alerting/saved-object-references
|
@elasticmachine merge upstream |
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
History
To update your PR or re-run it, just comment with: cc @ymao1 |
YulNaumenko
left a comment
There was a problem hiding this comment.
LGTM! Awesome new capabilities for the rule types. Tested this manually on the extending Index Threshold with the new hooks - it works!
… on rule CRU (elastic#101896) * Adding function hooks into rule type definition and call extract fn on rule create * Adding hooks for extracting and injecting saved object references. Adding extractReferences to create and update workflow * Adding type template for extracted params * Adding type template for extracted params * Adding type template for extracted params * Adding type template for extracted params * Calling injectReferences function if defined. Finishing unit tests for create and update * Adding tests for get * Adding tests for find * Cleanup * Fixing types check * Fixing functional tests * Fixing functional tests * Fixing tests * Updating README * Throwing boom error instead of normal error * Adding framework level prefix to extracted saved object reference names * Fixing types * Fixing types * PR fixes Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
💚 Backport successful
This backport PR will be merged automatically after passing CI. |
… on rule CRU (#101896) (#106333) * Adding function hooks into rule type definition and call extract fn on rule create * Adding hooks for extracting and injecting saved object references. Adding extractReferences to create and update workflow * Adding type template for extracted params * Adding type template for extracted params * Adding type template for extracted params * Adding type template for extracted params * Calling injectReferences function if defined. Finishing unit tests for create and update * Adding tests for get * Adding tests for find * Cleanup * Fixing types check * Fixing functional tests * Fixing functional tests * Fixing tests * Updating README * Throwing boom error instead of normal error * Adding framework level prefix to extracted saved object reference names * Fixing types * Fixing types * PR fixes Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Co-authored-by: ymao1 <ying.mao@elastic.co>
…y-show-migrate-to-authzd-users * 'master' of github.com:elastic/kibana: (48 commits) [Canvas] Expression shape (elastic#103219) [FTR] Skips Vega tests [Sample data] Use Lens in ecommerce data (elastic#106039) [APM] Backends inventory & overview page routes (elastic#106223) [TSVB] Add more functional tests for Gauge and TopN (elastic#105361) Add toggle to enable/disable rule install from SOs (elastic#106189) Improve unit test coverage of FS API calls (elastic#106242) Remove recursive plugin status in meta field (elastic#106286) [Ingest pipelines] add community id processor (elastic#103863) [XY axis] Fixes the values inside bar charts (elastic#106198) [data.search] Set default expiration to 1m if search sessions are disabled (elastic#105329) set the doc title when navigating to reporting and unset when navigating away (elastic#106253) [Lens] Display legend inside chart (elastic#105571) [RAC] [TGrid] Migrate the TGrid's rendering to `EuiDataGrid` (elastic#106199) [Security Solutions] Removes the elastic legacy client from lists and security_solution plugins (elastic#106130) [Enterprise Search] Require security plugin in 8.0 (elastic#106307) [DOCS] Updates screenshots in Dev Tools docs (elastic#105859) [DOCS] Updates text and screenshots in tags doc (elastic#105853) [Alerting] Allow rule types to extract/inject saved object references on rule CRU (elastic#101896) Jest and Storybook fixes (elastic#104991) ... # Conflicts: # x-pack/plugins/reporting/public/plugin.ts
… on rule CRU (elastic#101896) * Adding function hooks into rule type definition and call extract fn on rule create * Adding hooks for extracting and injecting saved object references. Adding extractReferences to create and update workflow * Adding type template for extracted params * Adding type template for extracted params * Adding type template for extracted params * Adding type template for extracted params * Calling injectReferences function if defined. Finishing unit tests for create and update * Adding tests for get * Adding tests for find * Cleanup * Fixing types check * Fixing functional tests * Fixing functional tests * Fixing tests * Updating README * Throwing boom error instead of normal error * Adding framework level prefix to extracted saved object reference names * Fixing types * Fixing types * PR fixes Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Resolves #87992
Summary
This PR provides a framework level hook to allow individual rule types to register functions for extracting/injecting saved object references from and into a rule's parameters.
The
AlertTypeinterface has been updated to include a newExtractedParamstemplate type and optionaluseSavedObjectReferencesfunctions. BothuseSavedObjectReferences.extractReferencesanduseSavedObjectReferences.injectReferencesmust be defined if one is defined.Updated `AlertType` interface
In the
alerts_client, theextractReferenceshook would be called (if defined) oncreateandupdateand theinjectReferenceshook would be called (if defined) ongetandfind. The framework will prefix any extracted SO reference names with a framework level prefix (currentlyparam:) to delineate between framework level SO references and references extracted by the rule type.Example hooks implementation:
Checklist
Delete any items that are not applicable to this PR.