Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ResponseOps] experiment: make all alert doc updates partial #165275

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions x-pack/plugins/alerting/server/alerts_client/alerts_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ export class AlertsClient<
this.fetchedAlerts.primaryTerm[alert.kibana.alert.uuid],
this.isUsingDataStreams()
),
alert,
getBulkDocument(this.fetchedAlerts.indices[alert.kibana.alert.uuid], alert),
])
);

Expand Down Expand Up @@ -419,6 +419,12 @@ export class AlertsClient<
}
}

function getBulkDocument(index: string | null | undefined, alert: Alert & AlertData) {
// if index provided, must be an update, so wrap in a { doc: {} }
if (index) return { doc: alert };
return alert;
}

function getBulkMeta(
uuid: string,
index: string | undefined,
Expand All @@ -428,11 +434,10 @@ export class AlertsClient<
) {
if (index && seqNo != null && primaryTerm != null) {
return {
index: {
// this code will change to use update, and not the if_* fields
update: {
_id: uuid,
_index: index,
if_seq_no: seqNo,
if_primary_term: primaryTerm,
require_alias: false,
},
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -353,11 +353,10 @@ export const createLifecycleExecutor =
body: allEventsToIndex.flatMap(({ event, indexName, seqNo, primaryTerm }) => [
indexName
? {
index: {
// this code will change to use update, and not the if_* fields
update: {
_id: event[ALERT_UUID]!,
_index: indexName,
if_seq_no: seqNo,
if_primary_term: primaryTerm,
require_alias: false,
},
}
Expand All @@ -366,7 +365,8 @@ export const createLifecycleExecutor =
_id: event[ALERT_UUID]!,
},
},
event,
// if index provided, must be an update, so wrap in a { doc: {} }
indexName ? { doc: event } : event,
]),
refresh: 'wait_for',
});
Expand Down