kibana/x-pack/plugins
Georgii Gorbachev 2431a08d2b
[Security Solution][Detections] Reading last 5 failures from Event Log v1 - raw implementation (#115574)
**Ticket:** https://github.com/elastic/kibana/issues/106469, https://github.com/elastic/kibana/issues/101013

## Summary

TL;DR: New internal endpoint for reading data from Event Log (raw version), legacy status SO under the hood.

With this PR we now read the Failure History (last 5 failures) on the Rule Details page from Event Log. We continue getting the Current Status from the legacy `siem-detection-engine-rule-status` saved objects. Rule Management page also gets data from the legacy saved objects.

- [x] Deprecate existing methods for reading data in `IRuleExecutionLogClient`: `.find()` and `.findBulk()`
- [x] Introduce new methods for reading data in IRuleExecutionLogClient:
  - for reading last N execution events for 1 rule from event log
  - for reading current status and metrics for 1 rule from legacy status SOs
  - for reading current statuses and metrics for N rules from legacy status SOs
- [x] New methods should return data in the legacy status SO format.
- [x] Update all the existing endpoints that depend on `IRuleExecutionLogClient` to use the new methods.
- [x] Implement a new internal endpoint for fetching current status of the rule execution and execution events from Event Log for a given rule.
- [x] The API of the new endpoint should be the same as `rules/_find_statuses` to minimise changes in the app.
- [x] Use the new endpoint on the Rule Details page.

## Near-term plan for technical implementation of the Rule Execution Log (https://github.com/elastic/kibana/issues/101013)

**Stage 1. Reading last 5 failures from Event Log v1 - raw implementation** - ✔️ done in this PR

TL;DR: New internal endpoint for reading data from Event Log (raw version), legacy status SO under the hood.

- Deprecate existing methods for reading data in `IRuleExecutionLogClient`: `.find()` and `.findBulk()`
- Introduce new methods for reading data in IRuleExecutionLogClient:
  - for reading last N execution events for 1 rule from event log
  - for reading current status and metrics for 1 rule from legacy status SOs
  - for reading current statuses and metrics for N rules from legacy status SOs
- New methods should return data in the legacy status SO format.
- Update all the existing endpoints that depend on `IRuleExecutionLogClient` to use the new methods.
- Implement a new internal endpoint for fetching current status of the rule execution and execution events from Event Log for a given rule.
- The API of the new endpoint should be the same as `rules/_find_statuses` to minimise changes in the app.
- Use the new endpoint on the Rule Details page.

**Stage 2: Reading last 5 failures from Event Log v2 - clean implementation**

TL;DR: Clean HTTP API, legacy Rule Status SO under the hood.

🚨🚨🚨 Possible breaking changes in Detections API 🚨🚨🚨

- Design a new data model for the Current Rule Execution Info (the TO-BE new SO type and later the TO-BE data in the rule object itself).
- Design a new data model for the Rule Execution Event (read model to be used on the Rule Details page)
- Think over changes in `IRuleExecutionLogClient` to support the new data model.
- Think over changes in all the endpoints that return any data related to rule monitoring (statuses, metrics, etc). Make sure to check our docs to identify what's documented there regarding rule monitoring.
- Update `IRuleExecutionLogClient` to return data in the new format. 
- Update all the endpoints (including the raw new one) to return data in the new format.
- Update Rule Details page to consume data in the new format.
- Update Rule Management page to consume data in the new format.

**Stage 3: Reading last 5 failures from Event Log v3 - new SO**

TL;DR: Clean HTTP API, new Rule Execution Info SO under the hood.

- Implement a new SO type for storing the current rule execution info. Relation type: 1 rule - 1 current execution info.
- Swap the legacy SO with the new SO in the implementation of `IRuleExecutionLogClient`.

**Stage 4: Cleanup and misc**

- Revisit the problem of deterministic ordering ([comment](https://github.com/elastic/kibana/pull/115574#discussion_r735803087))
- Remove rule execution log's glue code: adapters, feature switch.
- Remove the legacy rule status SO.
- Mark the legacy rule status SO as deleted in Kibana Core.
- Encapsulate the current space id in the instance of IRuleExecutionLogClient. Remove it from parameters of its methods.
- Introduce a Rule Execution Logger scoped to a rule instance. For use in rule executors.
- Add test coverage.

### Checklist

Delete any items that are not applicable to this PR.

- [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
2021-11-01 14:40:14 +01:00
..
actions Finalize removal of legacy audit logger (#116282) 2021-10-30 22:33:37 +01:00
alerting Finalize removal of legacy audit logger (#116282) 2021-10-30 22:33:37 +01:00
apm [ML] Fix y axis ticks. (#116670) 2021-10-30 14:51:55 +00:00
banners Removes unused and renamed deprecated core settings and deprecated settings from core plugins (#113653) 2021-10-05 12:30:49 -07:00
canvas remove all references to v7 theme (#113570) 2021-10-29 12:28:42 -05:00
cases [Cases] Do not show deprecated callout on deleted connectors (#116615) 2021-11-01 10:36:53 +02:00
cloud [Bug] fix memory info extraction for fullstory (#115756) 2021-10-20 18:19:53 +03:00
cross_cluster_replication [Stack management apps] Deprecate "enabled" Kibana setting (#114768) 2021-10-19 11:33:57 +01:00
dashboard_enhanced filter types (#111269) 2021-10-06 17:46:54 +02:00
data_enhanced [data.search.session] Use locators instead of URL generators (#115681) 2021-10-26 12:30:11 -07:00
data_visualizer [ES] Upgrade client to v8.0 (#113950) 2021-10-26 14:08:22 +02:00
discover_enhanced filter types (#111269) 2021-10-06 17:46:54 +02:00
drilldowns
embeddable_enhanced
encrypted_saved_objects Finalize removal of legacy audit logger (#116282) 2021-10-30 22:33:37 +01:00
enterprise_search [Workplace Search] Fix early sources logic unmounting (#113023) 2021-10-30 20:48:18 +01:00
event_log Updates Github link references from master to main (#116789) 2021-10-29 09:53:08 -07:00
features [feature branch] index pattern => data view for user facing content (#109821) 2021-10-20 18:53:39 -05:00
file_upload chore(NA): bump version to 8.1.0 (#116429) 2021-10-27 21:24:48 +01:00
fleet [Fleet] Fix pipeline with id [*] does not exists (#116707) 2021-10-29 13:44:24 -04:00
global_search
global_search_bar [Global search] Prevent unnecessary /internal/global_search/find http call at startup (#112535) 2021-10-28 15:26:28 +02:00
global_search_providers
graph chore(NA): bump version to 8.1.0 (#116429) 2021-10-27 21:24:48 +01:00
grokdebugger chore(NA): bump version to 8.1.0 (#116429) 2021-10-27 21:24:48 +01:00
index_lifecycle_management [ILM] Fixed skipped a11y and functional tests (#116207) 2021-10-28 12:54:09 +01:00
index_management chore(NA): bump version to 8.1.0 (#116429) 2021-10-27 21:24:48 +01:00
infra Revert "[Metrics UI] Fix OR logic on redundant groupBy detection (#116695)" (#116820) 2021-10-29 16:48:15 -04:00
ingest_pipelines Updates Github link references from master to main (#116789) 2021-10-29 09:53:08 -07:00
lens remove all references to v7 theme (#113570) 2021-10-29 12:28:42 -05:00
license_api_guard
license_management [ES] Upgrade client to v8.0 (#113950) 2021-10-26 14:08:22 +02:00
licensing [ES] Upgrade client to v8.0 (#113950) 2021-10-26 14:08:22 +02:00
lists [ES] Upgrade client to v8.0 (#113950) 2021-10-26 14:08:22 +02:00
logstash [ES] Upgrade client to v8.0 (#113950) 2021-10-26 14:08:22 +02:00
maps [Maps] fix data-mapping switch enabled for vector tiles (#116366) 2021-10-29 12:47:58 -06:00
metrics_entities Disable the experimental metrics_entities plugin by default. (#115460) 2021-10-19 09:33:46 -04:00
ml [ML] Renaming index patterns for job wizards (#116250) 2021-11-01 12:50:21 +00:00
monitoring [Stack Monitoring] Logstash Functional Tests (#116481) 2021-10-29 13:55:32 -04:00
observability Fix intermitting series state (#115747) 2021-10-29 19:50:14 +02:00
osquery Updates Github link references from master to main (#116789) 2021-10-29 09:53:08 -07:00
painless_lab [Dev Tools] Design fixes for theme v8 (#116236) 2021-10-30 09:34:22 +00:00
remote_clusters chore(NA): bump version to 8.1.0 (#116429) 2021-10-27 21:24:48 +01:00
reporting [Reporting] Remove Boom (#116289) 2021-10-28 14:18:22 +01:00
rollup [8.0] remove kibana.index config property (#112773) 2021-10-25 14:25:24 -07:00
rule_registry [Security Solution] Security RAC migration follow up bug fixes (#116386) 2021-10-28 10:21:51 -04:00
runtime_fields [AppServices] Disallow creating runtime and scripted fields with * in the name (#110081) (#116119) 2021-10-26 16:45:45 +02:00
saved_objects_tagging [8.0] remove kibana.index config property (#112773) 2021-10-25 14:25:24 -07:00
searchprofiler [Dev Tools] Design fixes for theme v8 (#116236) 2021-10-30 09:34:22 +00:00
security Finalize removal of legacy audit logger (#116282) 2021-10-30 22:33:37 +01:00
security_solution [Security Solution][Detections] Reading last 5 failures from Event Log v1 - raw implementation (#115574) 2021-11-01 14:40:14 +01:00
snapshot_restore [ES] Upgrade client to v8.0 (#113950) 2021-10-26 14:08:22 +02:00
spaces [SECURITY] Copy saved object flyout should not allow copying into the active space (#116657) 2021-10-29 13:55:17 -04:00
stack_alerts chore(NA): bump version to 8.1.0 (#116429) 2021-10-27 21:24:48 +01:00
task_manager chore(NA): bump version to 8.1.0 (#116429) 2021-10-27 21:24:48 +01:00
telemetry_collection_xpack Finalize removal of legacy audit logger (#116282) 2021-10-30 22:33:37 +01:00
timelines [RAC][Security Solution] Adds migration to new SecuritySolution rule types (#112113) 2021-10-26 16:56:40 -04:00
transform [ML] Fix Transforms not retaining _meta on clone (#116206) 2021-10-28 12:24:52 +01:00
translations [Security Solutions] Critical bug fix to make error messages about missing connections clearer for the end user. (#116490) 2021-10-29 11:44:38 -06:00
triggers_actions_ui [Cases] Do not show deprecated callout on deleted connectors (#116615) 2021-11-01 10:36:53 +02:00
ui_actions_enhanced
upgrade_assistant [ES] Upgrade client to v8.0 (#113950) 2021-10-26 14:08:22 +02:00
uptime [Uptime] Fix filters in query for fetching monitor attached rules (#115921) 2021-10-29 19:50:47 +02:00
watcher [ES] Upgrade client to v8.0 (#113950) 2021-10-26 14:08:22 +02:00