Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
patrykkopycinski committed Mar 9, 2020
1 parent eafd39b commit 9c3445e
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 33 deletions.
7 changes: 0 additions & 7 deletions src/legacy/ui/public/new_platform/new_platform.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -76,7 +71,6 @@ export interface PluginsSetup {
management: ManagementSetup;
visTypeVega: VisTypeVegaSetup;
telemetry?: TelemetryPluginSetup;
triggers_actions_ui: TriggersAndActionsUIPublicPluginSetup;
}

export interface PluginsStart {
Expand All @@ -94,7 +88,6 @@ export interface PluginsStart {
management: ManagementStart;
advancedSettings: AdvancedSettingsStart;
telemetry?: TelemetryPluginStart;
triggers_actions_ui: TriggersAndActionsUIPublicPluginStart;
}

export const npSetup = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<AlertAttributes>('alert', alertId);
// if (savedObject.attributes.name === 'Query with a rule id') {
// console.log('saved', savedObject);
// }
const ruleStatusSavedObjects = await services.savedObjectsClient.find<
IRuleSavedAttributesSavedObjectAttributes
>({
Expand Down Expand Up @@ -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') {
Expand All @@ -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(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/alerting/server/alerts_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ interface UpdateOptions {
tags: string[];
schedule: IntervalSchedule;
actions: NormalizedAlertAction[];
throttle: string | null;
params: Record<string, any>;
throttle: string | null;
};
Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/alerting/server/task_runner/task_runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,9 @@ export class TaskRunner {
alertInstance: AlertInstance,
executionHandler: ReturnType<typeof createExecutionHandler>
) {
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 });
}

Expand Down
3 changes: 1 addition & 2 deletions x-pack/plugins/siem/kibana.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,5 @@
"kibanaVersion": "kibana",
"configPath": ["xpack", "siem"],
"server": true,
"ui": false,
"requiredPlugins": ["triggers_actions_ui"]
"ui": false
}

0 comments on commit 9c3445e

Please sign in to comment.