From d3ad6613d2521b70d40efcad481dd9cbb1d4d78b Mon Sep 17 00:00:00 2001 From: Kerry Gallagher Date: Tue, 26 Jan 2021 12:13:49 +0000 Subject: [PATCH] Handle rare but possible situation where by_field_value can be stored as a -1 --- .../server/lib/log_analysis/log_entry_anomalies.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/x-pack/plugins/infra/server/lib/log_analysis/log_entry_anomalies.ts b/x-pack/plugins/infra/server/lib/log_analysis/log_entry_anomalies.ts index 1457b26f91b33..fbcc3671f08a2 100644 --- a/x-pack/plugins/infra/server/lib/log_analysis/log_entry_anomalies.ts +++ b/x-pack/plugins/infra/server/lib/log_analysis/log_entry_anomalies.ts @@ -158,10 +158,14 @@ export async function getLogEntryAnomalies( const parsedAnomaliesWithExpandedCategoryInformation = parsedAnomalies.map((anomaly) => { if (isCategoryAnomaly(anomaly)) { - const { - _source: { regex, terms }, - } = logEntryCategoriesById[parseInt(anomaly.categoryId, 10)]; - return { ...anomaly, ...{ categoryRegex: regex, categoryTerms: terms } }; + if (logEntryCategoriesById[parseInt(anomaly.categoryId, 10)]) { + const { + _source: { regex, terms }, + } = logEntryCategoriesById[parseInt(anomaly.categoryId, 10)]; + return { ...anomaly, ...{ categoryRegex: regex, categoryTerms: terms } }; + } else { + return { ...anomaly, ...{ categoryRegex: '', categoryTerms: '' } }; + } } else { return anomaly; }