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.
[Alert details page][Custom threshold] Add group by and tags fields t…
…o the alert details page summary (elastic#174254) Closes elastic#155698 Closes elastic#174236 ## Summary This PR adds group and tag information to the alert details page summary fields for the custom threshold rule: ![image](https://github.com/elastic/kibana/assets/12370520/d93e32bd-99ae-414f-87ed-5ca5884acfa6) ## 🧪 How to test - Enable alert details page config ``` xpack.observability.unsafe.alertDetails.observability.enabled: true ``` - Create a custom threshold rule with a group by and add more than 3 rule tags - After the alert is fired, go to the alert details page (from alert flyout or menu action in the alert table); you should see the group by and tags information there.
- Loading branch information
1 parent
602e8ad
commit 81a5d0c
Showing
7 changed files
with
184 additions
and
30 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
24 changes: 24 additions & 0 deletions
24
...bility/public/components/custom_threshold/components/alert_details_app_section/groups.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,24 @@ | ||
/* | ||
* 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'; | ||
|
||
export function Groups({ groups }: { groups: Array<{ field: string; value: string }> }) { | ||
return ( | ||
<> | ||
{groups && | ||
groups.map((group) => { | ||
return ( | ||
<span key={group.field}> | ||
{group.field}: <strong>{group.value}</strong> | ||
<br /> | ||
</span> | ||
); | ||
})} | ||
</> | ||
); | ||
} |
49 changes: 49 additions & 0 deletions
49
...vability/public/components/custom_threshold/components/alert_details_app_section/tags.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,49 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
import React, { useState } from 'react'; | ||
import { EuiBadge, EuiPopover } from '@elastic/eui'; | ||
import { FormattedMessage } from '@kbn/i18n-react'; | ||
|
||
export function Tags({ tags }: { tags: string[] }) { | ||
const [isMoreTagsOpen, setIsMoreTagsOpen] = useState(false); | ||
const onMoreTagsClick = () => setIsMoreTagsOpen((isPopoverOpen) => !isPopoverOpen); | ||
const closePopover = () => setIsMoreTagsOpen(false); | ||
const moreTags = tags.length > 3 && ( | ||
<EuiBadge | ||
key="more" | ||
onClick={onMoreTagsClick} | ||
onClickAriaLabel={i18n.translate( | ||
'xpack.observability.customThreshold.rule.alertDetailsAppSection.summaryField.moreTags.ariaLabel', | ||
{ | ||
defaultMessage: 'more tags badge', | ||
} | ||
)} | ||
> | ||
<FormattedMessage | ||
id="xpack.observability.customThreshold.rule.alertDetailsAppSection.summaryField.moreTags" | ||
defaultMessage="+{number} more" | ||
values={{ number: tags.length - 3 }} | ||
/> | ||
</EuiBadge> | ||
); | ||
|
||
return ( | ||
<> | ||
{tags.slice(0, 3).map((tag) => ( | ||
<EuiBadge key={tag}>{tag}</EuiBadge> | ||
))} | ||
<br /> | ||
<EuiPopover button={moreTags} isOpen={isMoreTagsOpen} closePopover={closePopover}> | ||
{tags.slice(3).map((tag) => ( | ||
<EuiBadge key={tag}>{tag}</EuiBadge> | ||
))} | ||
</EuiPopover> | ||
</> | ||
); | ||
} |
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