From 9c3445e929c78bd93cd3bf97408b305e410504af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patryk=20Kopycin=CC=81ski?= Date: Mon, 9 Mar 2020 11:18:10 +0100 Subject: [PATCH] WIP --- .../ui/public/new_platform/new_platform.ts | 7 ----- .../signals/signal_rule_alert_type.ts | 26 +++++-------------- .../server/alert_instance/alert_instance.ts | 4 +-- .../plugins/alerting/server/alerts_client.ts | 1 - .../server/task_runner/task_runner.ts | 3 +-- x-pack/plugins/siem/kibana.json | 3 +-- 6 files changed, 11 insertions(+), 33 deletions(-) diff --git a/src/legacy/ui/public/new_platform/new_platform.ts b/src/legacy/ui/public/new_platform/new_platform.ts index 89649da8927da..c5369b00f9f76 100644 --- a/src/legacy/ui/public/new_platform/new_platform.ts +++ b/src/legacy/ui/public/new_platform/new_platform.ts @@ -52,11 +52,6 @@ import { NavigationPublicPluginStart, } from '../../../../plugins/navigation/public'; import { VisTypeVegaSetup } from '../../../../plugins/vis_type_vega/public'; -import { - TriggersAndActionsUIPublicPluginSetup, - TriggersAndActionsUIPublicPluginStart, - // eslint-disable-next-line @kbn/eslint/no-restricted-paths -} from '../../../../../x-pack/plugins/triggers_actions_ui/public'; export interface PluginsSetup { bfetch: BfetchPublicSetup; @@ -76,7 +71,6 @@ export interface PluginsSetup { management: ManagementSetup; visTypeVega: VisTypeVegaSetup; telemetry?: TelemetryPluginSetup; - triggers_actions_ui: TriggersAndActionsUIPublicPluginSetup; } export interface PluginsStart { @@ -94,7 +88,6 @@ export interface PluginsStart { management: ManagementStart; advancedSettings: AdvancedSettingsStart; telemetry?: TelemetryPluginStart; - triggers_actions_ui: TriggersAndActionsUIPublicPluginStart; } export const npSetup = { diff --git a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/signal_rule_alert_type.ts b/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/signal_rule_alert_type.ts index 826221d931120..b3f6cb7269587 100644 --- a/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/signal_rule_alert_type.ts +++ b/x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/signal_rule_alert_type.ts @@ -83,7 +83,6 @@ export const signalRulesAlertType = ({ }, // fun fact: previousStartedAt is not actually a Date but a String of a date async executor({ previousStartedAt, alertId, services, params }) { - // console.log('params', params); const { from, ruleId, @@ -99,9 +98,6 @@ export const signalRulesAlertType = ({ } = params; // TODO: Remove this hard extraction of name once this is fixed: https://github.com/elastic/kibana/issues/50522 const savedObject = await services.savedObjectsClient.get('alert', alertId); - // if (savedObject.attributes.name === 'Query with a rule id') { - // console.log('saved', savedObject); - // } const ruleStatusSavedObjects = await services.savedObjectsClient.find< IRuleSavedAttributesSavedObjectAttributes >({ @@ -219,10 +215,6 @@ export const signalRulesAlertType = ({ const noReIndexResult = await services.callCluster('search', noReIndex); if (noReIndexResult.hits.total.value !== 0) { - // if (savedObject.attributes.name === 'Query with a rule id') { - // console.log('noReIndexResult', noReIndexResult.hits.hits[0]); - // } - const inputIndexes = inputIndex.join(', '); if (throttle && throttle !== 'no_actions') { @@ -236,17 +228,13 @@ export const signalRulesAlertType = ({ .replaceState({ signalsCount, }) - .scheduleActions( - 'default', - { - inputIndexes, - outputIndex, - name, - alertId, - ruleId, - }, - true // clears state after the throttled rule has been executed - ); + .scheduleActions('default', { + inputIndexes, + outputIndex, + name, + alertId, + ruleId, + }); } logger.info( diff --git a/x-pack/plugins/alerting/server/alert_instance/alert_instance.ts b/x-pack/plugins/alerting/server/alert_instance/alert_instance.ts index 50f80a42edac3..d6c870146e9e4 100644 --- a/x-pack/plugins/alerting/server/alert_instance/alert_instance.ts +++ b/x-pack/plugins/alerting/server/alert_instance/alert_instance.ts @@ -63,11 +63,11 @@ export class AlertInstance { return this.state; } - scheduleActions(actionGroup: string, context: Context = {}, clearState: boolean = false) { + scheduleActions(actionGroup: string, context: Context = {}) { if (this.hasScheduledActions()) { throw new Error('Alert instance execution has already been scheduled, cannot schedule twice'); } - this.scheduledExecutionOptions = { actionGroup, context, state: this.state, clearState }; + this.scheduledExecutionOptions = { actionGroup, context, state: this.state }; return this; } diff --git a/x-pack/plugins/alerting/server/alerts_client.ts b/x-pack/plugins/alerting/server/alerts_client.ts index f85ea0c98c64d..49c80af0072c9 100644 --- a/x-pack/plugins/alerting/server/alerts_client.ts +++ b/x-pack/plugins/alerting/server/alerts_client.ts @@ -106,7 +106,6 @@ interface UpdateOptions { tags: string[]; schedule: IntervalSchedule; actions: NormalizedAlertAction[]; - throttle: string | null; params: Record; throttle: string | null; }; diff --git a/x-pack/plugins/alerting/server/task_runner/task_runner.ts b/x-pack/plugins/alerting/server/task_runner/task_runner.ts index 3cb95303956cd..c2a3fbcf38069 100644 --- a/x-pack/plugins/alerting/server/task_runner/task_runner.ts +++ b/x-pack/plugins/alerting/server/task_runner/task_runner.ts @@ -128,10 +128,9 @@ export class TaskRunner { alertInstance: AlertInstance, executionHandler: ReturnType ) { - const { actionGroup, context, state, clearState } = alertInstance.getScheduledActionOptions()!; + const { actionGroup, context, state } = alertInstance.getScheduledActionOptions()!; alertInstance.updateLastScheduledActions(actionGroup); alertInstance.unscheduleActions(); - if (clearState) alertInstance.replaceState({}); return executionHandler({ actionGroup, context, state, alertInstanceId }); } diff --git a/x-pack/plugins/siem/kibana.json b/x-pack/plugins/siem/kibana.json index 68bd2752eaaf1..2bc33b87a1b43 100644 --- a/x-pack/plugins/siem/kibana.json +++ b/x-pack/plugins/siem/kibana.json @@ -4,6 +4,5 @@ "kibanaVersion": "kibana", "configPath": ["xpack", "siem"], "server": true, - "ui": false, - "requiredPlugins": ["triggers_actions_ui"] + "ui": false }