forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Security Solution] Fix topN grouping when field type is boolean (ela…
…stic#131958) (elastic#132273) * fix grouping * [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' * fix grouping * unit tests * fix types * update comment Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> (cherry picked from commit 3f5197a) Co-authored-by: Angela Chuang <6295984+angorayc@users.noreply.github.com>
- Loading branch information
1 parent
ae54add
commit 3165cb4
Showing
9 changed files
with
186 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
...ity_solution/public/detections/components/alerts_kpis/alerts_histogram_panel/mock_data.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
/* | ||
* 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. | ||
*/ | ||
export const stackedByBooleanField = { | ||
took: 1, | ||
timed_out: false, | ||
_shards: { total: 1, successful: 1, skipped: 0, failed: 0 }, | ||
hits: { | ||
total: { | ||
value: 3, | ||
relation: 'eq', | ||
}, | ||
hits: [], | ||
}, | ||
timeout: false, | ||
aggregations: { | ||
alertsByGrouping: { | ||
doc_count_error_upper_bound: 0, | ||
sum_other_doc_count: 0, | ||
buckets: [ | ||
{ | ||
key: 1, | ||
key_as_string: 'true', | ||
doc_count: 2683, | ||
alerts: { | ||
buckets: [ | ||
{ key_as_string: '2022-05-10T15:34:48.075Z', key: 1652196888075, doc_count: 0 }, | ||
{ key_as_string: '2022-05-10T16:19:48.074Z', key: 1652199588074, doc_count: 0 }, | ||
{ key_as_string: '2022-05-10T17:04:48.073Z', key: 1652202288073, doc_count: 0 }, | ||
], | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
}; | ||
|
||
export const result = [ | ||
{ x: 1652196888075, y: 0, g: 'true' }, | ||
{ x: 1652199588074, y: 0, g: 'true' }, | ||
{ x: 1652202288073, y: 0, g: 'true' }, | ||
]; | ||
|
||
export const stackedByTextField = { | ||
took: 1, | ||
timeout: false, | ||
_shards: { total: 1, successful: 1, skipped: 0, failed: 0 }, | ||
hits: { | ||
total: { | ||
value: 3, | ||
relation: 'eq', | ||
}, | ||
hits: [], | ||
}, | ||
aggregations: { | ||
alertsByGrouping: { | ||
doc_count_error_upper_bound: 0, | ||
sum_other_doc_count: 0, | ||
buckets: [ | ||
{ | ||
key: 'MacBook-Pro.local', | ||
doc_count: 2706, | ||
alerts: { | ||
buckets: [ | ||
{ key_as_string: '2022-05-10T15:34:48.075Z', key: 1652196888075, doc_count: 0 }, | ||
{ key_as_string: '2022-05-10T16:19:48.074Z', key: 1652199588074, doc_count: 0 }, | ||
{ key_as_string: '2022-05-10T17:04:48.073Z', key: 1652202288073, doc_count: 0 }, | ||
], | ||
}, | ||
}, | ||
], | ||
}, | ||
}, | ||
}; | ||
|
||
export const textResult = [ | ||
{ x: 1652196888075, y: 0, g: 'MacBook-Pro.local' }, | ||
{ x: 1652199588074, y: 0, g: 'MacBook-Pro.local' }, | ||
{ x: 1652202288073, y: 0, g: 'MacBook-Pro.local' }, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...olution/server/search_strategy/security_solution/factory/matrix_histogram/helpers.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* 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 { MatrixHistogramType } from '../../../../../common/search_strategy'; | ||
import { getGenericData } from './helpers'; | ||
import { stackedByBooleanField, stackedByTextField, result, textResult } from './mock_data'; | ||
|
||
describe('getGenericData', () => { | ||
test('stack by a boolean field', () => { | ||
const res = getGenericData<MatrixHistogramType.events>(stackedByBooleanField, 'events.bucket'); | ||
expect(res).toEqual(result); | ||
}); | ||
|
||
test('stack by a text field', () => { | ||
const res = getGenericData<MatrixHistogramType.events>(stackedByTextField, 'events.bucket'); | ||
expect(res).toEqual(textResult); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
...y_solution/server/search_strategy/security_solution/factory/matrix_histogram/mock_data.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export const stackedByBooleanField = [ | ||
{ | ||
key: 1, | ||
key_as_string: 'true', | ||
doc_count: 7125, | ||
events: { | ||
bucket: [ | ||
{ key_as_string: '2022-05-10T15:34:48.075Z', key: 1652196888075, doc_count: 0 }, | ||
{ key_as_string: '2022-05-10T16:19:48.074Z', key: 1652199588074, doc_count: 774 }, | ||
{ key_as_string: '2022-05-10T17:04:48.073Z', key: 1652202288073, doc_count: 415 }, | ||
], | ||
}, | ||
}, | ||
]; | ||
export const result = [ | ||
{ x: 1652196888075, y: 0, g: 'true' }, | ||
{ x: 1652199588074, y: 774, g: 'true' }, | ||
{ x: 1652202288073, y: 415, g: 'true' }, | ||
]; | ||
|
||
export const stackedByTextField = [ | ||
{ | ||
key: 'MacBook-Pro.local', | ||
doc_count: 7103, | ||
events: { | ||
bucket: [ | ||
{ key_as_string: '2022-05-10T15:34:48.075Z', key: 1652196888075, doc_count: 0 }, | ||
{ key_as_string: '2022-05-10T16:19:48.074Z', key: 1652199588074, doc_count: 774 }, | ||
{ key_as_string: '2022-05-10T17:04:48.073Z', key: 1652202288073, doc_count: 415 }, | ||
], | ||
}, | ||
}, | ||
]; | ||
|
||
export const textResult = [ | ||
{ x: 1652196888075, y: 0, g: 'MacBook-Pro.local' }, | ||
{ x: 1652199588074, y: 774, g: 'MacBook-Pro.local' }, | ||
{ x: 1652202288073, y: 415, g: 'MacBook-Pro.local' }, | ||
]; |