Skip to content

[Cases] Custom fields in case actions#177033

Merged
adcoelho merged 10 commits intoelastic:case_actionfrom
adcoelho:case-action-custom-fields
Feb 21, 2024
Merged

[Cases] Custom fields in case actions#177033
adcoelho merged 10 commits intoelastic:case_actionfrom
adcoelho:case-action-custom-fields

Conversation

@adcoelho
Copy link
Copy Markdown
Contributor

@adcoelho adcoelho commented Feb 15, 2024

Fixes #177032

Summary

A case may have required custom fields.

If a required custom field is missing when trying to create a case the API will throw an error.

To avoid case action failures we have to populate the custom fields with default values when creating cases.

If a default value is configured we use it, otherwise, we use the following values:

  • Text field: N/A
  • Toggle: false

Related: #168369

@adcoelho adcoelho 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 Feb 15, 2024
@adcoelho adcoelho self-assigned this Feb 15, 2024
@adcoelho adcoelho requested a review from a team as a code owner February 15, 2024 15:33
@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)

@adcoelho adcoelho requested review from doakalexi and ersin-erdal and removed request for ersin-erdal February 15, 2024 15:50
@adcoelho adcoelho requested a review from a team as a code owner February 15, 2024 16:33
@adcoelho adcoelho force-pushed the case-action-custom-fields branch from 0e74d2d to 78202b9 Compare February 15, 2024 16:46
@doakalexi
Copy link
Copy Markdown
Contributor

I’m not very familiar with this feature, can you provide steps to verify this PR pls

@cnasikas cnasikas mentioned this pull request Feb 17, 2024
3 tasks
@adcoelho
Copy link
Copy Markdown
Contributor Author

@doakalexi Since this is part of ongoing work on a feature branch, there isn't much that can be tested here for now besides making sure the unit tests cover the changes. 😞 If you want I can elaborate a bit offline.

@adcoelho
Copy link
Copy Markdown
Contributor Author

/ci

Copy link
Copy Markdown
Member

@cnasikas cnasikas left a comment

Choose a reason for hiding this comment

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

Great work! I left some comments. Could you please add some this.logger.debug messages about the custom fields?

Copy link
Copy Markdown
Contributor

@doakalexi doakalexi left a comment

Choose a reason for hiding this comment

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

LGTM

@kibana-ci
Copy link
Copy Markdown

kibana-ci commented Feb 21, 2024

💔 Build Failed

Failed CI Steps

Test Failures

  • [job] [logs] Jest Integration Tests #7 / Connector type config checks ensure connector types list up to date
  • [job] [logs] Jest Integration Tests #7 / Connector type config checks ensure connector types list up to date

Metrics [docs]

‼️ ERROR: no builds found for mergeBase sha [39afa54]

History

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

cc @adcoelho

@adcoelho adcoelho merged commit d1031ac into elastic:case_action Feb 21, 2024
cnasikas added a commit that referenced this pull request Apr 12, 2024
## Summary

Depends on: #166267,
#170326,
#169484,
#173740,
#173763,
#178068,
#178307,
#178600,
#180437

PRs:
- #168370
- #169229
- #171754
- #172709
- #173012
- #175107
- #175452
- #175505
- #177033
- #178277
- #177139
- #179796

Fixes: #153837

## Testing

Run Kibana with `--run-examples` if you want to use the "Always firing"
rule.

Create a rule with a case action in observability and the stack. The
security solution is not supported. You should not be able to assign a
case action in a security solution rule.

1. Test the "Reopen closed cases" configuration.
2. Test the "Grouping by" configuration. Only one field is allowed. Not
all fields are persisted in alerts. If you select a field not part of
the alert the case action will create a case where the grouping value is
set to `unknow`.
3. Test the "Time window" feature. You can comment out the validation to
test for shorter times.
4. Verify that the case action is experimental.
5. Verify that based on the rule type the case is created in the correct
solution.
6. Verify that you cannot create a rule with the case action on the
basic license.
7. Verify that the execution of the case action fails if you do not have
permission for cases. Pending work on the system actions framework level
to not allow users to create rules with system actions where they do not
have permission.
8. Stress test the case action by creating multiple rules.

### Checklist

Delete any items that are not applicable to this PR.

- [x]
[Documentation](https://www.elastic.co/guide/en/kibana/master/development-documentation.html)
was added for features that require explanation or tutorials
- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios

### For maintainers

- [x] This was checked for breaking API changes and was [labeled
appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)

## Release notes

Automatically create cases when an alert is triggered.

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
Co-authored-by: adcoelho <antonio.coelho@elastic.co>
Co-authored-by: Janki Salvi <117571355+js-jankisalvi@users.noreply.github.com>
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.

7 participants