Skip to content

[Cases] Register connector adapter#179796

Merged
cnasikas merged 19 commits intoelastic:case_actionfrom
cnasikas:ca_connector_adapter
Apr 4, 2024
Merged

[Cases] Register connector adapter#179796
cnasikas merged 19 commits intoelastic:case_actionfrom
cnasikas:ca_connector_adapter

Conversation

@cnasikas
Copy link
Copy Markdown
Member

@cnasikas cnasikas commented Apr 2, 2024

Summary

Now that the system actions PR is merged (#166267) we can use the connector adapters to transform the case action params. This PR:

  • Registers a connector adapter for the case action.
  • Uses flattened objects in the description and the tags.
  • Change the integration tests to use an internal router to execute system actions. PR [Actions] System actions MVP #166267 disabled execution of system actions through the public execute API.
  • Skip execution of the case action if the grouping did not produce any alerts.
  • Add references to the cases oracle saved objects.
  • Remove the owner from the UI and deduct the owner from the rule's consumer in the connector adapter.

Checklist

Delete any items that are not applicable to this PR.

For maintainers

@cnasikas cnasikas added release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Platform ResponseOps team (formerly the Cases and Alerting teams) t// Feature:Cases Cases feature v8.14.0 labels Apr 2, 2024
@cnasikas cnasikas self-assigned this Apr 2, 2024
@cnasikas cnasikas mentioned this pull request Apr 2, 2024
3 tasks
@cnasikas cnasikas marked this pull request as ready for review April 2, 2024 13:36
@cnasikas cnasikas requested review from a team as code owners April 2, 2024 13:36
@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/response-ops (Team:ResponseOps)

@elasticmachine
Copy link
Copy Markdown
Contributor

Pinging @elastic/response-ops-cases (Feature:Cases)

@cnasikas cnasikas requested review from a team as code owners April 3, 2024 10:43
@cnasikas cnasikas removed request for a team April 3, 2024 10:45
@cnasikas
Copy link
Copy Markdown
Member Author

cnasikas commented Apr 3, 2024

Sorry for the noise!

id: `system-connector-${systemActionType.id}`,
actionTypeId: systemActionType.id,
name: `System action: ${systemActionType.id}`,
name: systemActionType.name,
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name of a system connector will be the same name as the action type name. This change affected some tests.

import { OWNER_INFO } from './owners';

describe('OWNER_INFO', () => {
it('should use all available rule consumers', () => {
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If a new consumer is added the test will fail and we will get notified.

ActionParamsProps<CasesActionParams>
> = ({ actionParams, editAction, errors, index, producerId }) => {
const { appId } = useApplication();
const owner = getCaseOwnerByAppId(appId);
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The owner will be automatically mapped in the connector adapter.

auth?: { user: User; space: string | null };
}): Promise<ActionTypeExecutorResult<unknown>> => {
const { body: res } = await supertest
.post(`${getSpaceUrlPrefix(auth.space)}/api/cases_fixture/${connectorId}/connectors:execute`)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to create a new route for executing system actions only for testing because the public execute API does not allow the execution of system actions.

iconType: 'logoObservability',
appRoute: '/app/observability',
validRuleConsumers: [
// only valid in serverless
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be separate list of validRuleConsumers for serverless and ESS?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In both deployments, a valid consumer will be found in the validRuleConsumers array so there is no need to separate the list. If we separate it into two lists we will have to add logic to check if we are in serverless or ESS which will increase the complexity of the code.

Copy link
Copy Markdown
Contributor

@js-jankisalvi js-jankisalvi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work!! 👍 🎉

"cases"
],
"requiredPlugins": [
"alerting",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohh.. I wonder how UI worked without this 🤔

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The UI is in the triggers_actions_ui plugin. The alerting plugin is used to register the connector adapter.

return validationResult;
},
actionParamsFields: lazy(() => import('./cases_params')),
isSystemActionType: true,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this 🙂

*/
const filteredAlerts = alerts.filter((alert) =>
uniqueGroupingByFields.every((groupingByField) => Object.hasOwn(alert, groupingByField))
uniqueGroupingByFields.every((groupingByField) => Boolean(get(alert, groupingByField, null)))
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use of get 👍

@kibana-ci
Copy link
Copy Markdown

kibana-ci commented Apr 4, 2024

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] Jest Integration Tests #7 / transition from md5 hashes to model versions ensures the hashToVersionMap does not miss any mappings changes
  • [job] [logs] Jest Integration Tests #7 / transition from md5 hashes to model versions ensures the hashToVersionMap does not miss any mappings changes
  • [job] [logs] Jest Tests #9 / unified data table should update row Height correctly

Metrics [docs]

‼️ ERROR: no builds found for mergeBase sha [44b9d94]

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

cc @cnasikas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature:Cases Cases feature release_note:skip Skip the PR/issue when compiling release notes Team:ResponseOps Platform ResponseOps team (formerly the Cases and Alerting teams) t// v8.14.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants