-
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.
[Security Solution] Alerts Grouping MVP (#149145)
Current PR introducing the new grouping functionality to the alerts tables: on Alerts and Rule Details pages. The existing grouping design is a technical preview functionality and is a subject of the change. MVP description: 1. Grouping is available only for alerts tables on the Alerts and Rules Details page as selectable dropdown options list in the right top level menu of the alerts table: <img width="1565" alt="Screenshot 2023-01-28 at 2 00 33 PM" src="https://user-images.githubusercontent.com/55110838/215293513-a46e5989-0e49-4b4c-b191-e00d6ef14eff.png"> 2. Default selected option "None" means that the group alerts by is turned off and none of the field is selected. In 8.7 feature has a **technical preview** badge on the right of the select option. <img width="373" alt="Screenshot 2023-01-28 at 2 21 24 PM" src="https://user-images.githubusercontent.com/55110838/215293745-ae232e12-eb92-4429-a667-7b76a2be8c61.png"> 3. The default fields options list is different for Alerts and Rule Details pages and relevant to the page context: <img width="1555" alt="Screenshot 2023-01-28 at 2 30 02 PM" src="https://user-images.githubusercontent.com/55110838/215294128-a0e2a875-088b-446e-ba96-28bcb1d114d0.png"> <img width="1498" alt="Screenshot 2023-01-28 at 2 31 22 PM" src="https://user-images.githubusercontent.com/55110838/215294132-0ca11882-73e9-446c-9e75-112569b9bdc7.png"> 4. Group by custom field is a separate option which allows to group the alerts data by any other index field. <img width="980" alt="Screenshot 2023-01-28 at 2 34 28 PM" src="https://user-images.githubusercontent.com/55110838/215294168-f787093c-72e9-483d-8881-70320b1f4343.png"> 5. Custom field provides a limited to the field value only default rendering for the panel and default set of stats metrics: Rules count and Alerts count. <img width="1209" alt="Screenshot 2023-01-28 at 2 35 47 PM" src="https://user-images.githubusercontent.com/55110838/215294237-17c6105c-d9a3-4ced-be2b-c17ffd181e14.png"> For rule name for example the is also additionally rendered metrics, rule name, rule description and rule tags: <img width="1899" alt="Screenshot 2023-01-28 at 2 40 02 PM" src="https://user-images.githubusercontent.com/55110838/215294351-8935ee93-c416-4357-80cd-ce28c0127993.png"> 6. Each group panel provides the list of bulk actions options which could be applied to the whole group by clicking on the **Take actions** button. For now the list is limited to the three available actions: <img width="1557" alt="Screenshot 2023-01-28 at 2 32 24 PM" src="https://user-images.githubusercontent.com/55110838/215294393-513dc001-be83-4f76-ac09-3a36b2b89e00.png"> 7. Existing technical preview functionality is limited to display only one expanded group at a time. 8. For a big number of groups there is a paging functionality with the ability to define the items per page: <img width="735" alt="Screenshot 2023-01-28 at 2 32 40 PM" src="https://user-images.githubusercontent.com/55110838/215294444-98dfef11-b6b5-413b-b82f-0dcea90f0e65.png"> 9. Grouping setting is stored in the local storage for each page separately and after the hard refresh should be picked up and rendered on the page. --------- Co-authored-by: Steph Milovic <stephanie.milovic@elastic.co> Co-authored-by: Garrett Spong <spong@users.noreply.github.com> Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
- Loading branch information
1 parent
c71725e
commit 705ba7b
Showing
47 changed files
with
3,544 additions
and
63 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
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
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
88 changes: 88 additions & 0 deletions
88
.../security_solution/public/common/components/grouping/accordion_panel/group_stats.test.tsx
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,88 @@ | ||
/* | ||
* 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 React from 'react'; | ||
import { fireEvent, render } from '@testing-library/react'; | ||
import { GroupStats } from './group_stats'; | ||
import { TestProviders } from '../../../mock'; | ||
|
||
const onTakeActionsOpen = jest.fn(); | ||
const testProps = { | ||
badgeMetricStats: [ | ||
{ title: "IP's:", value: 1 }, | ||
{ title: 'Rules:', value: 2 }, | ||
{ title: 'Alerts:', value: 2, width: 50, color: '#a83632' }, | ||
], | ||
bucket: { | ||
key: '9nk5mo2fby', | ||
doc_count: 2, | ||
hostsCountAggregation: { value: 1 }, | ||
ruleTags: { doc_count_error_upper_bound: 0, sum_other_doc_count: 0, buckets: [] }, | ||
alertsCount: { value: 2 }, | ||
rulesCountAggregation: { value: 2 }, | ||
severitiesSubAggregation: { | ||
doc_count_error_upper_bound: 0, | ||
sum_other_doc_count: 0, | ||
buckets: [{ key: 'low', doc_count: 2 }], | ||
}, | ||
countSeveritySubAggregation: { value: 1 }, | ||
usersCountAggregation: { value: 1 }, | ||
}, | ||
onTakeActionsOpen, | ||
customMetricStats: [ | ||
{ | ||
title: 'Severity', | ||
customStatRenderer: <p data-test-subj="customMetricStat" />, | ||
}, | ||
], | ||
takeActionItems: [ | ||
<p data-test-subj="takeActionItem-1" key={1} />, | ||
<p data-test-subj="takeActionItem-2" key={2} />, | ||
], | ||
}; | ||
describe('Group stats', () => { | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
}); | ||
it('renders each stat item', () => { | ||
const { getByTestId } = render( | ||
<TestProviders> | ||
<GroupStats {...testProps} /> | ||
</TestProviders> | ||
); | ||
expect(getByTestId('group-stats')).toBeInTheDocument(); | ||
testProps.badgeMetricStats.forEach(({ title: stat }) => { | ||
expect(getByTestId(`metric-${stat}`)).toBeInTheDocument(); | ||
}); | ||
testProps.customMetricStats.forEach(({ title: stat }) => { | ||
expect(getByTestId(`customMetric-${stat}`)).toBeInTheDocument(); | ||
}); | ||
}); | ||
it('when onTakeActionsOpen is defined, call onTakeActionsOpen on popover click', () => { | ||
const { getByTestId, queryByTestId } = render( | ||
<TestProviders> | ||
<GroupStats {...testProps} /> | ||
</TestProviders> | ||
); | ||
fireEvent.click(getByTestId('take-action-button')); | ||
expect(onTakeActionsOpen).toHaveBeenCalled(); | ||
['takeActionItem-1', 'takeActionItem-2'].forEach((actionItem) => { | ||
expect(queryByTestId(actionItem)).not.toBeInTheDocument(); | ||
}); | ||
}); | ||
it('when onTakeActionsOpen is undefined, render take actions dropdown on popover click', () => { | ||
const { getByTestId } = render( | ||
<TestProviders> | ||
<GroupStats {...testProps} onTakeActionsOpen={undefined} /> | ||
</TestProviders> | ||
); | ||
fireEvent.click(getByTestId('take-action-button')); | ||
['takeActionItem-1', 'takeActionItem-2'].forEach((actionItem) => { | ||
expect(getByTestId(actionItem)).toBeInTheDocument(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.