Skip to content

Commit a733538

Browse files
authored
[SIEM] [Detection Engine] Log time gaps as failures for now (#55515) (#55540)
* log a failure to failure history if time gap is detected. stop-gap solution until a feature is fully fleshed out to report this and future messaging / monitoring. * write date the gap warning occurred in the last_failure_at field, along with the status_date field.
1 parent 4d5cd1d commit a733538

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

x-pack/legacy/plugins/siem/server/lib/detection_engine/signals/signal_rule_alert_type.ts

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,27 @@ export const signalRulesAlertType = ({
134134
logger.warn(
135135
`Signal rule name: "${name}", id: "${alertId}", rule_id: "${ruleId}" has a time gap of ${gap.humanize()} (${gap.asMilliseconds()}ms), and could be missing signals within that time. Consider increasing your look behind time or adding more Kibana instances.`
136136
);
137+
// write a failure status whenever we have a time gap
138+
// this is a temporary solution until general activity
139+
// monitoring is developed as a feature
140+
const gapDate = new Date().toISOString();
141+
await services.savedObjectsClient.create(ruleStatusSavedObjectType, {
142+
alertId,
143+
statusDate: gapDate,
144+
status: 'failed',
145+
lastFailureAt: gapDate,
146+
lastSuccessAt: currentStatusSavedObject.attributes.lastSuccessAt,
147+
lastFailureMessage: `Signal rule name: "${name}", id: "${alertId}", rule_id: "${ruleId}" has a time gap of ${gap.humanize()} (${gap.asMilliseconds()}ms), and could be missing signals within that time. Consider increasing your look behind time or adding more Kibana instances.`,
148+
lastSuccessMessage: currentStatusSavedObject.attributes.lastSuccessMessage,
149+
});
150+
151+
if (ruleStatusSavedObjects.saved_objects.length >= 6) {
152+
// delete fifth status and prepare to insert a newer one.
153+
const toDelete = ruleStatusSavedObjects.saved_objects.slice(5);
154+
await toDelete.forEach(async item =>
155+
services.savedObjectsClient.delete(ruleStatusSavedObjectType, item.id)
156+
);
157+
}
137158
}
138159
// set searchAfter page size to be the lesser of default page size or maxSignals.
139160
const searchAfterSize =

0 commit comments

Comments
 (0)