kibana/x-pack/plugins
Ryland Herrick 8b31ce0a89
[SIEM] Check ML Job status on ML Rule execution (#61715)
* Move isMlRule helper to a more general location

And use it during rule execution as well.

* Add error message back to rule error status

This was unintentionally removed in a previous merge commit.

* Expose mlClient as part of ML's Setup contract

This allows dependent plugins to leverage the exposed services without
having to define their own ml paths, e.g. "ml.jobs"

* Move ML Job predicates to common folder

These are pure functions and used on both the client and server.

* WIP: Check ML Job status on ML Rule execution

This works, but unfortunately it pushes this executor function to a
complexity of 25. We're gonna refactor this next.

* Move isMlRule and RuleType to common

These are used on both the frontend and the backend, and can be shared.

* Refactor Signal Rule executor to use RuleStatusService

RuleStatusService holds the logic for updating the current status as
well as adding an error status. It leverages a simple
RuleStatusSavedObjectClient to handle the communication with
SavedObjects.

This removes the need for our specialized 'writeError', 'writeGap', and
'writeSuccess' functions, which duplicated much of the rule status
logic and code. It also fixes a bug with gap failures, with should have
been treated the same as other failures.

NB that an error does not necessarily prevent the rule from running, as
in the case of a gap or an ML Job not running.

This also adds a buildRuleMessage helper to reduce the noise of
generating logs/messages, and to make them more consistent.

* Remove unneeded 'async' keywords

We're not awaiting here, so we can just return the promise.

* Make buildRuleStatusAttributes synchronous

We weren't doing anything async here, and in fact the returning of a
promise was causing a bug when we tried to spread it into our attributes
object.

* Fix incorrectly-named RuleStatus attributes

This mapping could be done within the ruleStatusService, but it
lives outside it for now.

Also renames the object holding these values to the more general
'result,' as creationSuccess implies it always succeeds.

* Move our rule message helpers to a separate file

Adds some tests, as well.

* Refactor how rule status objects interact

Only ruleStatusSavedObjectsClient receives a savedObjectsClient, the
other functions receive the ruleStatusSavedObjectsClient

* pluralizes savedObjects in ruleStatusSavedObjectsClient
* Backfills tests

* Handle adding multiple errors during a single rule execution

We were storing state in our RuleStatusClient, and consequently could
get into a situation where that state did not reflect reality, and we
would incorrectly try to delete a SavedObject that had already been
deleted.

Rather than try to store the _correct_ state in the service, we remove
state entirely and just fetch our statuses on each action.

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
2020-03-30 16:35:38 -05:00
..
actions [SIEM][CASE] Fix dates when updating (#61603) 2020-03-27 20:50:12 +02:00
advanced_ui_actions Fix plugin enabled config options (#60998) 2020-03-25 15:09:04 -06:00
alerting Fix alert and action telemetry reporting to stop sending data that contains dot in the name (#61389) 2020-03-26 16:49:07 -07:00
alerting_builtins Fix plugin enabled config options (#60998) 2020-03-25 15:09:04 -06:00
apm [APM] Fix deduplication for focused service maps (#61580) 2020-03-28 22:32:38 +01:00
canvas Support for sub-feature privileges (#60563) 2020-03-24 11:12:49 -04:00
case [SIEM][CASE] Delete endpoints return noContent (#61721) 2020-03-28 19:01:29 +02:00
cloud
code Remove experimental code app (#49404) 2019-10-28 11:40:27 -04:00
console_extensions [Console] Clean up after initial 7.7.0 spec definitions update (#61227) 2020-03-26 10:13:09 +01:00
data_enhanced Temporarily remove wait_for_completion (#61677) 2020-03-30 07:13:59 -07:00
drilldowns Fix plugin enabled config options (#60998) 2020-03-25 15:09:04 -06:00
encrypted_saved_objects Fixed EncryptedSavedObjectsClientWrapper to not fails with trying to stripEncryptedAttributes if attributes is undefined in saved object response - in case of a type related error (#61385) 2020-03-26 08:45:10 -07:00
endpoint [Endpoint] Get current host info when retrieving alert details (#60906) 2020-03-26 17:30:41 -04:00
es_ui_shared/console_lang
event_log [alerting] change eventLog schema to use dynamic false (#61633) 2020-03-27 18:15:59 -04:00
features Fix plugin enabled config options (#60998) 2020-03-25 15:09:04 -06:00
file_upload Use renamed @mapbox/geojson-rewind instead of geojson-rewind module (#61139) 2020-03-25 17:11:53 +01:00
graph Graph: Migrate feature registration (#61419) 2020-03-30 11:11:00 +02:00
index_management [Index management] Re-enable index template tests (#60780) 2020-03-21 17:01:01 +01:00
infra [Logs UI] Add context fields to /log_entries/entries API (#60759) 2020-03-30 13:28:25 +02:00
ingest_manager [EPM] update registry path structure (#61621) 2020-03-30 15:00:50 -04:00
lens Fix plugin enabled config options (#60998) 2020-03-25 15:09:04 -06:00
license_management [ML] Disabling start trial option when license management ui is disabled (#60987) 2020-03-25 10:39:13 +00:00
licensing Make context.core required argument to context providers (#59996) 2020-03-12 20:39:29 +01:00
maps Typescript map embeddable (#61264) 2020-03-26 16:14:23 -04:00
ml [SIEM] Check ML Job status on ML Rule execution (#61715) 2020-03-30 16:35:38 -05:00
monitoring Add plugin start contract to getStartServices return value (#61216) 2020-03-26 10:49:05 +01:00
observability Fix plugin enabled config options (#60998) 2020-03-25 15:09:04 -06:00
oss_telemetry Fix plugin enabled config options (#60998) 2020-03-25 15:09:04 -06:00
painless_lab Fix padding around Painless Lab left pane. (#61373) 2020-03-26 10:34:21 -07:00
remote_clusters [Remote clusters] Add cloud-specific logic to remote clusters (#61639) 2020-03-29 17:44:12 -04:00
reporting Fix plugin enabled config options (#60998) 2020-03-25 15:09:04 -06:00
rollup [Rollups] Server NP migration (#55606) 2020-02-07 10:00:58 -05:00
searchprofiler [SearchProfiler] Set the agg treeRoot value (#61591) 2020-03-27 13:17:42 +01:00
security Add username/password validation to login form (#60681) 2020-03-30 12:15:11 -04:00
siem [SIEM] Final Shimming/Prep for Server NP Migration (#56814) 2020-02-13 22:10:27 -06:00
snapshot_restore [Snapshot Restore] Fix doc links (#61331) 2020-03-30 09:14:01 -04:00
spaces Migrate savedObjectManagementActionRegistry to NP plugin (#60481) 2020-03-26 17:25:27 +01:00
task_manager force savedObject API consumers to define SO type explicitly (#58022) 2020-02-21 22:11:05 +01:00
telemetry_collection_xpack [Telemetry] Server-side Migration to NP (#60485) 2020-03-23 18:49:38 +00:00
transform [ML] Data Visualizer, Explorer, Transform wizard: Ensure query bar syntax errors are shown (#61333) 2020-03-26 14:41:51 -04:00
translations [ML] Data Visualizer, Explorer, Transform wizard: Ensure query bar syntax errors are shown (#61333) 2020-03-26 14:41:51 -04:00
triggers_actions_ui Add close button to expression popovers (#61352) 2020-03-27 13:37:22 -04:00
upgrade_assistant [UA] Upgrade assistant migration meta data can become stale (#60789) 2020-03-23 13:35:27 -04:00
uptime Fix some null reference issues. (#61465) 2020-03-27 12:53:35 -04:00
watcher Fix plugin enabled config options (#60998) 2020-03-25 15:09:04 -06:00