-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix user authentication area chart (#146783)
## Summary Original issue: #131791 Before: No area chart displayed for user authentications: <img width="1505" alt="Screenshot 2022-12-01 at 13 02 17" src="https://user-images.githubusercontent.com/6295984/205059727-2be51425-9b61-4595-8ad6-9a80b4a4bea5.png"> <img width="1101" alt="Screenshot 2022-12-01 at 12 55 42" src="https://user-images.githubusercontent.com/6295984/205058753-1f97cca1-b3b8-4b58-ae8a-9e5ada107e9f.png"> Most of the data of area charts look like: ``` [ { "key_as_string": "2022-12-01T00:00:00.000Z", "key": 1669852800000, // x "doc_count": 12, "count": { "value": 0 // y } } ] ``` but user authentications' data looks like: ``` [ { "key_as_string": "2022-12-01T00:00:00.000Z", "key": 1669852800000, // x "doc_count": 12, "count": { "doc_count": 0 // y } } ] ``` The parser (formatGeneralHistogramData) picked up only count.value and ignored count.doc_count. Therefore y value for user authentication was not picked up and no data for rendering the area chart. After: User authentication area chart should be displayed properly. <img width="1505" alt="Screenshot 2022-12-01 at 13 07 21" src="https://user-images.githubusercontent.com/6295984/205060657-a9fbfa42-5ae5-449d-84d5-6df3f97d2464.png"> ### Checklist Delete any items that are not applicable to this PR. - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios
- Loading branch information
Showing
13 changed files
with
89 additions
and
42 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
13 changes: 0 additions & 13 deletions
13
...gins/security_solution/common/search_strategy/security_solution/users/kpi/common/index.ts
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -5,5 +5,4 @@ | |
* 2.0. | ||
*/ | ||
|
||
export * from './common'; | ||
export * from './total_users'; |
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
57 changes: 57 additions & 0 deletions
57
...er/search_strategy/security_solution/factory/common/format_general_histogram_data.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,57 @@ | ||
/* | ||
* 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 type { KpiGeneralHistogramCount, KpiHistogram } from '../../../../../common/search_strategy'; | ||
import { formatGeneralHistogramData } from './format_general_histogram_data'; | ||
|
||
describe('formatGeneralHistogramData', () => { | ||
test('Picks up data from count.value', () => { | ||
const mockHistogramData = [ | ||
{ | ||
key_as_string: '2022-12-01T00:00:00.000Z', | ||
key: 1669852800000, | ||
doc_count: 4, | ||
count: { | ||
doc_count: 4, | ||
}, | ||
} as KpiHistogram<KpiGeneralHistogramCount>, | ||
]; | ||
const result = formatGeneralHistogramData(mockHistogramData); | ||
|
||
expect(result).toMatchInlineSnapshot(` | ||
Array [ | ||
Object { | ||
"x": 1669852800000, | ||
"y": 4, | ||
}, | ||
] | ||
`); | ||
}); | ||
|
||
test('Picks up data from count.doc_count - userAuthentications', () => { | ||
const mockUserAuthentications = [ | ||
{ | ||
key_as_string: '2022-12-01T04:00:00.000Z', | ||
key: 1669867200000, | ||
doc_count: 4, | ||
count: { | ||
value: 1, | ||
}, | ||
}, | ||
]; | ||
const result = formatGeneralHistogramData(mockUserAuthentications); | ||
|
||
expect(result).toMatchInlineSnapshot(` | ||
Array [ | ||
Object { | ||
"x": 1669867200000, | ||
"y": 1, | ||
}, | ||
] | ||
`); | ||
}); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,5 @@ | |
* 2.0. | ||
*/ | ||
|
||
export * from './common'; | ||
export * from './hosts'; | ||
export * from './unique_ips'; |
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