[ResponseOps][Alerting] Adding back unknown outcome filter (#143546)

* Adding back the unknown filter

* Adding tests
This commit is contained in:
doakalexi 2022-10-19 08:53:10 -04:00 committed by GitHub
parent d897293b1a
commit ae4bda5465
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 0 deletions

View file

@ -0,0 +1,26 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { getFilter } from './get_filter';
describe('getFilter', () => {
test('should return message filter', () => {
expect(getFilter({ message: 'test message' })).toEqual([
'message: "test message" OR error.message: "test message"',
]);
});
test('should return outcome filter', () => {
expect(getFilter({ outcomeFilter: ['failure', 'warning', 'success', 'unknown'] })).toEqual([
'event.outcome: failure OR kibana.alerting.outcome: warning OR kibana.alerting.outcome:success OR (event.outcome: success AND NOT kibana.alerting.outcome:*) OR event.outcome: unknown',
]);
});
test('should return runId filter', () => {
expect(getFilter({ runId: 'test' })).toEqual(['kibana.alert.rule.execution.uuid: test']);
});
});

View file

@ -39,6 +39,7 @@ function getOutcomeFilter(outcomeFilter: string[]) {
warning: 'kibana.alerting.outcome: warning',
success:
'kibana.alerting.outcome:success OR (event.outcome: success AND NOT kibana.alerting.outcome:*)',
unknown: 'event.outcome: unknown',
};
return `${outcomeFilter.map((f) => filterMapping[f]).join(' OR ')}`;
}