Skip to content

Commit

Permalink
[ResponseOps] use Data Streams for AAD indices in serverless
Browse files Browse the repository at this point in the history
resolves elastic#154266

Changes the way the alerts-as-data (AAD) indices are created and
written to, to allow them to be built as they have been in the past
(alias and backing indices created manually) OR as an ES Data Stream.

Serverless will use Data Streams, other environments will use the
existing alias and backing indices.  The determination is made by
optionally including the `serverless` plugin, and determining if it's
available.
  • Loading branch information
pmuellr committed Aug 16, 2023
1 parent 0d74544 commit 091fa61
Show file tree
Hide file tree
Showing 36 changed files with 3,329 additions and 2,380 deletions.
3 changes: 2 additions & 1 deletion x-pack/plugins/alerting/kibana.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"usageCollection",
"security",
"monitoringCollection",
"spaces"
"spaces",
"serverless",
],
"extraPublicDirs": [
"common",
Expand Down
3,772 changes: 2,065 additions & 1,707 deletions x-pack/plugins/alerting/server/alerts_service/alerts_service.test.ts

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
getIndexTemplateAndPattern,
} from './resource_installer_utils';
import { AlertInstanceContext, AlertInstanceState, IRuleTypeAlerts, RuleAlertData } from '../types';
import { DataStreamAdapter } from './lib/data_stream_adapter';
import {
createResourceInstallationHelper,
errorResult,
Expand Down Expand Up @@ -49,6 +50,7 @@ interface AlertsServiceParams {
kibanaVersion: string;
elasticsearchClientPromise: Promise<ElasticsearchClient>;
timeoutMs?: number;
dataStreamAdapter: DataStreamAdapter;
}

export interface CreateAlertsClientParams extends LegacyAlertsClientParams {
Expand Down Expand Up @@ -114,10 +116,13 @@ export class AlertsService implements IAlertsService {
private resourceInitializationHelper: ResourceInstallationHelper;
private registeredContexts: Map<string, IRuleTypeAlerts> = new Map();
private commonInitPromise: Promise<InitializationPromise>;
private dataStreamAdapter: DataStreamAdapter;

constructor(private readonly options: AlertsServiceParams) {
this.initialized = false;

this.dataStreamAdapter = options.dataStreamAdapter;

// Kick off initialization of common assets and save the promise
this.commonInitPromise = this.initializeCommon(this.options.timeoutMs);

Expand Down Expand Up @@ -296,6 +301,7 @@ export class AlertsService implements IAlertsService {
esClient,
name: DEFAULT_ALERTS_ILM_POLICY_NAME,
policy: DEFAULT_ALERTS_ILM_POLICY,
dataStreamAdapter: this.dataStreamAdapter,
}),
() =>
createOrUpdateComponentTemplate({
Expand Down Expand Up @@ -421,6 +427,7 @@ export class AlertsService implements IAlertsService {
kibanaVersion: this.options.kibanaVersion,
namespace,
totalFieldsLimit: TOTAL_FIELDS_LIMIT,
dataStreamAdapter: this.dataStreamAdapter,
}),
}),
async () =>
Expand All @@ -429,6 +436,7 @@ export class AlertsService implements IAlertsService {
esClient,
totalFieldsLimit: TOTAL_FIELDS_LIMIT,
indexPatterns: indexTemplateAndPattern,
dataStreamAdapter: this.dataStreamAdapter,
}),
]);

Expand Down
Loading

0 comments on commit 091fa61

Please sign in to comment.