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.
[APM] Threshold alerts (elastic#59566)
* Add alerting/actions permissions for APM * Export TIME_UNITS, getTimeUnitLabel from triggers actions UI plugin * Add APM alert types and UI * Review feedback * Use Expression components for triggers * Update alert name for transaction duration * Change defaults for error rate trigger
- Loading branch information
1 parent
ff4ef4a
commit 8603f2b
Showing
45 changed files
with
1,199 additions
and
182 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
7 changes: 0 additions & 7 deletions
7
x-pack/legacy/plugins/apm/public/components/app/ErrorGroupOverview/List/__test__/props.json
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
30 changes: 30 additions & 0 deletions
30
...ugins/apm/public/components/app/ServiceDetails/AlertIntegrations/AlertingFlyout/index.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,30 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
import React from 'react'; | ||
import { AlertType } from '../../../../../../../../../plugins/apm/common/alert_types'; | ||
import { AlertAdd } from '../../../../../../../../../plugins/triggers_actions_ui/public'; | ||
|
||
type AlertAddProps = React.ComponentProps<typeof AlertAdd>; | ||
|
||
interface Props { | ||
addFlyoutVisible: AlertAddProps['addFlyoutVisible']; | ||
setAddFlyoutVisibility: AlertAddProps['setAddFlyoutVisibility']; | ||
alertType: AlertType | null; | ||
} | ||
|
||
export function AlertingFlyout(props: Props) { | ||
const { addFlyoutVisible, setAddFlyoutVisibility, alertType } = props; | ||
|
||
return alertType ? ( | ||
<AlertAdd | ||
addFlyoutVisible={addFlyoutVisible} | ||
setAddFlyoutVisibility={setAddFlyoutVisibility} | ||
consumer="apm" | ||
alertTypeId={alertType} | ||
canChangeTrigger={false} | ||
/> | ||
) : null; | ||
} |
146 changes: 146 additions & 0 deletions
146
x-pack/legacy/plugins/apm/public/components/app/ServiceDetails/AlertIntegrations/index.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,146 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License; | ||
* you may not use this file except in compliance with the Elastic License. | ||
*/ | ||
|
||
import { | ||
EuiButtonEmpty, | ||
EuiContextMenu, | ||
EuiPopover, | ||
EuiContextMenuPanelDescriptor | ||
} from '@elastic/eui'; | ||
import { i18n } from '@kbn/i18n'; | ||
import React, { useState } from 'react'; | ||
import { AlertType } from '../../../../../../../../plugins/apm/common/alert_types'; | ||
import { AlertingFlyout } from './AlertingFlyout'; | ||
import { useApmPluginContext } from '../../../../hooks/useApmPluginContext'; | ||
|
||
const alertLabel = i18n.translate( | ||
'xpack.apm.serviceDetails.alertsMenu.alerts', | ||
{ | ||
defaultMessage: 'Alerts' | ||
} | ||
); | ||
|
||
const createThresholdAlertLabel = i18n.translate( | ||
'xpack.apm.serviceDetails.alertsMenu.createThresholdAlert', | ||
{ | ||
defaultMessage: 'Create threshold alert' | ||
} | ||
); | ||
|
||
const CREATE_THRESHOLD_ALERT_PANEL_ID = 'create_threshold'; | ||
|
||
interface Props { | ||
canReadAlerts: boolean; | ||
canSaveAlerts: boolean; | ||
} | ||
|
||
export function AlertIntegrations(props: Props) { | ||
const { canSaveAlerts, canReadAlerts } = props; | ||
|
||
const plugin = useApmPluginContext(); | ||
|
||
const [popoverOpen, setPopoverOpen] = useState(false); | ||
|
||
const [alertType, setAlertType] = useState<AlertType | null>(null); | ||
|
||
const button = ( | ||
<EuiButtonEmpty | ||
iconType="arrowDown" | ||
iconSide="right" | ||
onClick={() => setPopoverOpen(true)} | ||
> | ||
{i18n.translate('xpack.apm.serviceDetails.alertsMenu.alerts', { | ||
defaultMessage: 'Alerts' | ||
})} | ||
</EuiButtonEmpty> | ||
); | ||
|
||
const panels: EuiContextMenuPanelDescriptor[] = [ | ||
{ | ||
id: 0, | ||
title: alertLabel, | ||
items: [ | ||
...(canSaveAlerts | ||
? [ | ||
{ | ||
name: createThresholdAlertLabel, | ||
panel: CREATE_THRESHOLD_ALERT_PANEL_ID, | ||
icon: 'bell' | ||
} | ||
] | ||
: []), | ||
...(canReadAlerts | ||
? [ | ||
{ | ||
name: i18n.translate( | ||
'xpack.apm.serviceDetails.alertsMenu.viewActiveAlerts', | ||
{ | ||
defaultMessage: 'View active alerts' | ||
} | ||
), | ||
href: plugin.core.http.basePath.prepend( | ||
'/app/kibana#/management/kibana/triggersActions/alerts' | ||
), | ||
icon: 'tableOfContents' | ||
} | ||
] | ||
: []) | ||
] | ||
}, | ||
{ | ||
id: CREATE_THRESHOLD_ALERT_PANEL_ID, | ||
title: createThresholdAlertLabel, | ||
items: [ | ||
{ | ||
name: i18n.translate( | ||
'xpack.apm.serviceDetails.alertsMenu.transactionDuration', | ||
{ | ||
defaultMessage: 'Transaction duration' | ||
} | ||
), | ||
onClick: () => { | ||
setAlertType(AlertType.TransactionDuration); | ||
} | ||
}, | ||
{ | ||
name: i18n.translate( | ||
'xpack.apm.serviceDetails.alertsMenu.errorRate', | ||
{ | ||
defaultMessage: 'Error rate' | ||
} | ||
), | ||
onClick: () => { | ||
setAlertType(AlertType.ErrorRate); | ||
} | ||
} | ||
] | ||
} | ||
]; | ||
|
||
return ( | ||
<> | ||
<EuiPopover | ||
id="integrations-menu" | ||
button={button} | ||
isOpen={popoverOpen} | ||
closePopover={() => setPopoverOpen(false)} | ||
panelPaddingSize="none" | ||
anchorPosition="downRight" | ||
> | ||
<EuiContextMenu initialPanelId={0} panels={panels} /> | ||
</EuiPopover> | ||
<AlertingFlyout | ||
alertType={alertType} | ||
addFlyoutVisible={!!alertType} | ||
setAddFlyoutVisibility={visible => { | ||
if (!visible) { | ||
setAlertType(null); | ||
} | ||
}} | ||
/> | ||
</> | ||
); | ||
} |
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
Oops, something went wrong.