-
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
[RAM] Add example log system action type #175057
[RAM] Add example log system action type #175057
Conversation
Towards elastic/response-ops-team#164 Registering alerting example rules with framework AAD. This creates a new alerts index `.alerts-default.alerts-default` that will eventually hold alerts for all rules that have not customized their registration. This index contains only the mappings for the basic alerts as data documents, no custom context or payload fields. Run kibana using `--run-examples` flag. Create one of the example rule types and let it alert and then resolve and see an alert document get created in the `.alerts-default.alerts-default` index. --------- Co-authored-by: Kibana Machine <[email protected]>
Pinging @elastic/response-ops (Team:ResponseOps) |
🤖 GitHub commentsExpand to view the GitHub comments
Just comment with:
|
...s_actions_ui_example/public/connector_types/system_log_example/system_log_example_params.tsx
Show resolved
Hide resolved
body: transformResolveResponseV1<RuleParamsV1>(rule), | ||
}; | ||
return res.ok(response); | ||
try { |
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.
why did we have to add the try/catch?
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 route was failing because some schemas were missing system actions support so I added this for debugging, but it's not needed anymore. I'll remove.
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.
Cool!
frequency: DEFAULT_FREQUENCY, | ||
uuid: uuidv4(), | ||
}); | ||
actions.push( |
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.
can we create a function to avoid duplication code?
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.
Pushing a simplified version of this control flow
I looked into the git blame to find out why DEFAULT_FREQUENCY
was being set sometimes, and defaultRuleFrequency
was being set other times, and it turns out it's due to a bad merge, so I'm just setting defaultRuleFrequency
no matter what going forward. This may end up fixing a bug that we haven't yet detected.
x-pack/plugins/triggers_actions_ui/public/application/sections/rule_form/rule_edit.tsx
Outdated
Show resolved
Hide resolved
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.
Not really sure how I should go about testing this (looks like I might need to pull the entire feature branch?). But generally I think we should make sure the modifications we're making to non-example code is well tested.
x-pack/plugins/actions/server/routes/connector/get_all/get_all.ts
Outdated
Show resolved
Hide resolved
clonedRule.actions = clonedRule.actions.map((action: SanitizedRuleAction) => { | ||
if (actionHasDefinedGroup(action as SanitizedRuleAction)) { | ||
return { | ||
...action, | ||
frequency, | ||
} as SanitizedRuleAction; | ||
} | ||
return action as SanitizedRuleAction; |
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.
Let's add some jest tests to this as well, also curious to know why we have to cast the types so often, maybe worth trying to fix them, unless we're migrating types like we were the the http versioning stuff
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 migration code is for pre-8.6 rules, note the if (hasRuleLevelNotifyWhen || hasRuleLevelThrottle)
check.
Adding this change here covers the highly unlikely edge case where a system action somehow gets added to a pre-8.6 rule that still has global frequency params before it's ever opened in the UI and migrated, and even then whatever frequency
param we add would get stripped on rewrite. This was just to cover our bases in case something unexpected happens but I'm 99% sure the UI will function without problems if we don't push this. Happy to revert this code if it's a blocker.
...lugins/triggers_actions_ui/public/application/sections/action_connector_form/action_form.tsx
Show resolved
Hide resolved
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.
@XavierM For which API are you referring to? The connectors' APIs (Get all connectors API, Get connector API, List connector types API) do not return system actions. |
@cnasikas I think in this PR, we are using the Get all connectors API to get the system actions on the UI with a new query param to include them. I feel like we should have a different APIs for getting all or the detail of the system action. |
You are right @XavierM. You can see in the System Actions doc that this was the decision we took. We should not expose system actions to any of the connector's APIs and we should use separate internal APIs dedicated to system actions. |
I missed that in the doc, I just realized when reviewing the PR! |
@cnasikas I was reading over the System Actions doc and discussion but it was never clear where in the UI system actions actually do show up. Only that they're not supposed to be in the connectors list. I didn't have anywhere to put this example action except in the connectors list with everything else. I combined fetching system actions with the |
⏳ Build in-progress, with failuresFailed CI Steps
Test Failures
History
To update your PR or re-run it, just comment with: |
@XavierM Yea I was actually thinking something like this while reviewing this PR, it seems like the checks to determine whether or not its system action is going to be added everywhere. |
Pushed the following changes:
|
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!
Summary
This adds an example action type called System Log, which is enabled when running Kibana with the
--run-examples
flag.This action will log out to Kibana at the same rate as summarized alerts.
Please only refer to 29fa70d when reviewing. Other code changes were cherry-picked from
main