-
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
Allow usage of saved object references in alerts #87992
Comments
Pinging @elastic/kibana-alerting-services (Team:Alerting Services) |
Relates to: #85173 |
Another use case from @spong (#85173)
|
Another feature that may require the usage of references is the import/export of alerts (#50266). We may need to link alerts to another saved object to properly support import/export functionality (ex: creating new ids on import). |
Thinking through what we need here. If we just wanted to extend the existing APIs, it would be something like this:
There's a bit of a collision in that we currently already use SO refs for actions. So we'll need to make sure that when we create the names of the SO refs for the actions, they don't collide with whatever names are being passed for the new SO refs params. We have a simplistic scheme for it now where the name is Or we could say if you are going to add SO refs, you should follow a pattern of using a unique prefix, and I'm wondering if we will have any issues with multiple clients trying to manage these. I guess given the current requirements, we'll have Discover (and other Kibana apps) adding SO refs, and also RAC and Security adding SO refs. Will this get cumbersome for clients to search for and update the SO refs they are interested in? Could one client inadvertently delete an SO ref another client needs? And I wonder if we should expose the current action SO refs in the same fashion. I think not, but then we'll have a weird disconnect that looking at the SO refs in the alert objects at the client level won't show the actions, but they are actually there in the raw SO's. Also wondering if this is something we'd expose at the API client level but not the HTTP level. At least the create/update - I suspect returning them on get/find is fine for HTTP. Keeping them out of the HTTP API means less of chance of a customer accidentally deleting critical SO refs. |
Yeah, in theory, the alert type will know how to extract the references from the
Since we have control over this, we could catch the collision between the rule type / API-provided references and our "reserved" reference names and return an error. |
The above implementation sounds good to me @pmuellr, with the note that we could also add items to the references array during an SO migration as well (covering the case here #85173 where we would move over the exceptions reference from a dedicated field when migrating the security rule type). @mikecote and I spoke about this earlier today with regards to being able to use the SO Management UI to export Security Rules and all associated Exceptions and Value lists. We're planning to do the rule migration in |
Currently working on this issue and am taking the approach of providing 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.
Then in the Example hooks implementation:
|
There are two approaches we can take with migrations: Approach 1 - Framework handles migrationsAlerting framework detects whether Pros
Cons
Approach 2 - Rule types handle migrationsWhen a rule type producer implements the Pros
Cons
I am thinking we should go with Approach 2 since we currently have two downstream solutions that would use these saved object reference hooks and one of them has not yet implemented their rule type (meaning they won't need a migration). We can make sure to work closely with security when they implement these hooks to make sure the correct migrations are written. Interested in other opinions if there are any. |
Heya @ymao1, so all of the above sounds good to me from the Security Solution perspective, but let experiment a little bit tomorrow just to make sure there aren't any corner cases I'm missing. I think we should be good with Approach 2 as outlined for migrations as well. For some context from the migration perspective, I'm thinking we can just add the associated SO references during the migration from the single |
I'm +1 on Approach 2. To mitigate the cons of this approach, we could make our documentation clear not to forget about migration in such use cases. |
So I think we're good here @ymao1! Chatted a little with @mikecote today as well and the only extra item that came up was if the SO References[] would also be exposed via the Rules API. We were both along the lines of keeping access server side and Security can add any additional specific API's it needs for linking/unlinking any associated Exception Lists to Rules as we develop features that require this behavior. Please ping me on the PR for this when ready and I'll check it out and create some test migrations to ensure everything is good to go from the security side. Thanks for your efforts here! 🙂 |
Just a note on prefixing the "alerting internal" references with |
@timroes Thanks Tim! That sounds like a good idea! |
I didn't quite follow approach 1, but it sounds like approach 2 is closer to what we do with other persistable state situations. We don't have documentation yet, but until then, I recommend syncing with @ppisljar on the App Services team to help you work through how to use the persistable state interfaces. One thing that is confusing me is this part:
In other cases of persistable state, a producer may not implement As for how to make producers aware about the need for writing migrations, this is indeed a weak spot in the architecture, but one we don't have a good idea to work around it right now. We are thinking through improvements. |
@stacey-gammon This comment is specific to this issue, which will allow producers of existing rule types to update their rule type with a |
take a look at https://github.com/elastic/kibana/blob/master/src/plugins/kibana_utils/common/persistable_state/index.ts and please ping me on slack as this is probably not clear enough and docs are still missing. If alert type implements PersistableState interface it can provide inject and extract functions which should inject/extract SO references as well as object of versioned migrate functions. the plugin providing specific alert type definition (persistable state definition) is (should be) the only one with internal knowledge of shared state to perform migration or other manipulations on it. the migration then should be handled by SO migration system (as each alert is represented by SO ?) |
When storing alerts at the moment there is no way (as far as I could tell) for the alert type (implementation) to make use of saved object references if the alert itself needs to reference other saved objects.
As an example the discover alert will serialize a search source and thus have a reference onto an index pattern saved object stored inside the alert. If this is not properly put into the saved object references when storing, this would break sharing between spaces (and other security related efforts) again. As soon as you'd share an index pattern now with another space its id will be changed and all existing alerts on that index pattern would be broken, since they reference a now non existing id.
Thus an alert need to be able to emit SavedObjectReferences besides it's params when saving and needs to get the parameters and saved object references back for injection in all places the alert is "loaded"/"used" again (like the
executor
).This is blocking building any alerts that would make use/reference any other saved object (like index pattern).
cc @legrego
The text was updated successfully, but these errors were encountered: