Skip to content

Commit

Permalink
fixes merge conflicts and updates logging, defaults to always writing…
Browse files Browse the repository at this point in the history
… alerts to an index
  • Loading branch information
dhurley14 committed May 12, 2021
1 parent 87ac3e9 commit 350aa97
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion x-pack/plugins/rule_registry/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export class RuleRegistryPlugin implements Plugin<RuleRegistryPluginSetupContrac
kibanaVersion: this.initContext.env.packageInfo.version,
logger: logger.get('root'),
alertingPluginSetupContract: plugins.alerting,
writeEnabled: this.config.writeEnabled,
writeEnabled: true, // this.config.writeEnabled,
});

// ALERTS ROUTES
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ export function createScopedRuleRegistryClient<TFieldMap extends BaseRuleFieldMa
});
},
bulkIndex: (docs) => {
logger.debug(`indexAliasName: ${indexAliasName}`);
const validations = docs.map((doc) => {
return fieldmapType.decode({
...doc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export function createLifecycleRuleTypeFactory(): CreateLifecycleRuleType<BaseRu
rule.uuid
);

console.error('RULE REGISTRY CONSUMER', so.attributes.consumer);
logger.debug(`RULE REGISTRY CONSUMER ${so.attributes.consumer}`);

const decodedState = wrappedStateRt.decode(previousState);

Expand Down Expand Up @@ -157,6 +157,8 @@ export function createLifecycleRuleTypeFactory(): CreateLifecycleRuleType<BaseRu
},
});

console.error('EVENTS????', JSON.stringify(events, null, 2));

events.forEach((event) => {
const alertId = event['kibana.rac.alert.id']!;
alertsDataMap[alertId] = event;
Expand Down Expand Up @@ -218,7 +220,10 @@ export function createLifecycleRuleTypeFactory(): CreateLifecycleRuleType<BaseRu
}
);

logger.debug(`EVENTSTOINDEX: ${JSON.stringify(eventsToIndex, null, 2)}`);

if (eventsToIndex.length && scopedRuleRegistryClient) {
logger.debug('ABOUT TO INDEX ALERTS');
await scopedRuleRegistryClient.bulkIndex(eventsToIndex);
}

Expand Down
4 changes: 3 additions & 1 deletion x-pack/plugins/security_solution/server/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,7 @@ export class Plugin implements IPlugin<PluginSetup, PluginStart, SetupPlugins, S
private readonly config: ConfigType;
private context: PluginInitializerContext;
private appClientFactory: AppClientFactory;
private setupPlugins?: SetupPlugins;
private readonly endpointAppContextService = new EndpointAppContextService();
private readonly telemetryEventsSender: TelemetryEventsSender;

Expand All @@ -165,6 +166,7 @@ export class Plugin implements IPlugin<PluginSetup, PluginStart, SetupPlugins, S

public setup(core: CoreSetup<StartPlugins, PluginStart>, plugins: SetupPlugins) {
this.logger.debug('plugin setup');
this.setupPlugins = plugins;

const config = this.config;
const globalConfig = this.context.config.legacy.get();
Expand Down Expand Up @@ -355,7 +357,7 @@ export class Plugin implements IPlugin<PluginSetup, PluginStart, SetupPlugins, S

// Create rule-registry scoped to security-solution (APP_ID uses caps, not supported)
this.setupPlugins.ruleRegistry = plugins.ruleRegistry.create({
namespace: 'security-solution',
name: 'security-solution',
fieldMap: {
...pickWithPatterns(ecsFieldMap, 'host.name', 'service.name'),
},
Expand Down

0 comments on commit 350aa97

Please sign in to comment.