-
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
[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 #101896
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
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! I tested locally with the index threshold rule type, I was able to see it work as expected 👍
@@ -146,6 +152,10 @@ export interface AlertType< | |||
params?: ActionVariable[]; | |||
}; | |||
minimumLicenseRequired: LicenseType; | |||
useSavedObjectReferences?: { | |||
extractReferences: (params: Params) => RuleParamsAndRefs<ExtractedParams>; | |||
injectReferences: (params: SavedObjectAttributes, references: SavedObjectReference[]) => Params; |
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.
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; |
@@ -183,6 +184,8 @@ export interface GetAlertInstanceSummaryParams { | |||
dateStart?: string; | |||
} | |||
|
|||
const extractedSavedObjectParamReferenceNamePrefix = 'param:'; |
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.
optional nit: should we add a comment about modifying this value will require a migration for existing SOs with references?
@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.
Maps team owned file updates lgtm!
@elasticmachine merge upstream |
@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 |
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! 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 <[email protected]>
💚 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 <[email protected]> Co-authored-by: ymao1 <[email protected]>
…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 <[email protected]>
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
AlertType
interface has been updated to include a newExtractedParams
template type and optionaluseSavedObjectReferences
functions. BothuseSavedObjectReferences.extractReferences
anduseSavedObjectReferences.injectReferences
must be defined if one is defined.Updated `AlertType` interface
In the
alerts_client
, theextractReferences
hook would be called (if defined) oncreate
andupdate
and theinjectReferences
hook would be called (if defined) onget
andfind
. 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.