Skip to content

Commit d19427c

Browse files
committed
- Reorg the alerts menu for different alert types (threshold/anomaly)
- default environment alert settings to the selected filter
1 parent c798812 commit d19427c

File tree

3 files changed

+41
-39
lines changed
  • x-pack/plugins/apm/public/components

3 files changed

+41
-39
lines changed

x-pack/plugins/apm/public/components/app/ServiceDetails/AlertIntegrations/index.tsx

Lines changed: 39 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,28 @@ import { useApmPluginContext } from '../../../../hooks/useApmPluginContext';
1818

1919
const alertLabel = i18n.translate(
2020
'xpack.apm.serviceDetails.alertsMenu.alerts',
21-
{
22-
defaultMessage: 'Alerts',
23-
}
21+
{ defaultMessage: 'Alerts' }
22+
);
23+
const transactionDurationLabel = i18n.translate(
24+
'xpack.apm.serviceDetails.alertsMenu.transactionDuration',
25+
{ defaultMessage: 'Transaction duration' }
26+
);
27+
const errorRateLabel = i18n.translate(
28+
'xpack.apm.serviceDetails.alertsMenu.errorRate',
29+
{ defaultMessage: 'Error rate' }
2430
);
25-
2631
const createThresholdAlertLabel = i18n.translate(
2732
'xpack.apm.serviceDetails.alertsMenu.createThresholdAlert',
28-
{
29-
defaultMessage: 'Create threshold alert',
30-
}
33+
{ defaultMessage: 'Create threshold alert' }
34+
);
35+
const createAnomalyAlertAlertLabel = i18n.translate(
36+
'xpack.apm.serviceDetails.alertsMenu.createAnomalyAlert',
37+
{ defaultMessage: 'Create anomaly alert' }
3138
);
3239

33-
const CREATE_THRESHOLD_ALERT_PANEL_ID = 'create_threshold';
40+
const CREATE_TRANSACTION_DURATION_ALERT_PANEL_ID =
41+
'create_transaction_duration';
42+
const CREATE_ERROR_RATE_ALERT_PANEL_ID = 'create_error_rate';
3443

3544
interface Props {
3645
canReadAlerts: boolean;
@@ -53,9 +62,7 @@ export function AlertIntegrations(props: Props) {
5362
iconSide="right"
5463
onClick={() => setPopoverOpen(true)}
5564
>
56-
{i18n.translate('xpack.apm.serviceDetails.alertsMenu.alerts', {
57-
defaultMessage: 'Alerts',
58-
})}
65+
{alertLabel}
5966
</EuiButtonEmpty>
6067
);
6168

@@ -67,20 +74,18 @@ export function AlertIntegrations(props: Props) {
6774
...(canSaveAlerts
6875
? [
6976
{
70-
name: createThresholdAlertLabel,
71-
panel: CREATE_THRESHOLD_ALERT_PANEL_ID,
72-
icon: 'bell',
77+
name: transactionDurationLabel,
78+
panel: CREATE_TRANSACTION_DURATION_ALERT_PANEL_ID,
7379
},
80+
{ name: errorRateLabel, panel: CREATE_ERROR_RATE_ALERT_PANEL_ID },
7481
]
7582
: []),
7683
...(canReadAlerts
7784
? [
7885
{
7986
name: i18n.translate(
8087
'xpack.apm.serviceDetails.alertsMenu.viewActiveAlerts',
81-
{
82-
defaultMessage: 'View active alerts',
83-
}
88+
{ defaultMessage: 'View active alerts' }
8489
),
8590
href: plugin.core.http.basePath.prepend(
8691
'/app/management/insightsAndAlerting/triggersActions/alerts'
@@ -92,44 +97,41 @@ export function AlertIntegrations(props: Props) {
9297
],
9398
},
9499
{
95-
id: CREATE_THRESHOLD_ALERT_PANEL_ID,
96-
title: createThresholdAlertLabel,
100+
id: CREATE_TRANSACTION_DURATION_ALERT_PANEL_ID,
101+
title: transactionDurationLabel,
97102
items: [
98103
{
99-
name: i18n.translate(
100-
'xpack.apm.serviceDetails.alertsMenu.transactionDuration',
101-
{
102-
defaultMessage: 'Transaction duration',
103-
}
104-
),
104+
icon: 'bell',
105+
name: createThresholdAlertLabel,
105106
onClick: () => {
106107
setAlertType(AlertType.TransactionDuration);
108+
setPopoverOpen(false);
107109
},
108110
},
109111
...(canReadAnomalies
110112
? [
111113
{
112-
name: i18n.translate(
113-
'xpack.apm.serviceDetails.alertsMenu.transactionDurationAnomaly',
114-
{
115-
defaultMessage: 'Transaction duration anomaly',
116-
}
117-
),
114+
icon: 'bell',
115+
name: createAnomalyAlertAlertLabel,
118116
onClick: () => {
119117
setAlertType(AlertType.TransactionDurationAnomaly);
118+
setPopoverOpen(false);
120119
},
121120
},
122121
]
123122
: []),
123+
],
124+
},
125+
{
126+
id: CREATE_ERROR_RATE_ALERT_PANEL_ID,
127+
title: errorRateLabel,
128+
items: [
124129
{
125-
name: i18n.translate(
126-
'xpack.apm.serviceDetails.alertsMenu.errorRate',
127-
{
128-
defaultMessage: 'Error rate',
129-
}
130-
),
130+
icon: 'bell',
131+
name: createThresholdAlertLabel,
131132
onClick: () => {
132133
setAlertType(AlertType.ErrorRate);
134+
setPopoverOpen(false);
133135
},
134136
},
135137
],

x-pack/plugins/apm/public/components/shared/ErrorRateAlertTrigger/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export function ErrorRateAlertTrigger(props: Props) {
4343
threshold: 25,
4444
windowSize: 1,
4545
windowUnit: 'm',
46-
environment: ENVIRONMENT_ALL.value,
46+
environment: urlParams.environment || ENVIRONMENT_ALL.value,
4747
};
4848

4949
const params = {

x-pack/plugins/apm/public/components/shared/TransactionDurationAlertTrigger/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ export function TransactionDurationAlertTrigger(props: Props) {
5858
windowSize: 5,
5959
windowUnit: 'm',
6060
transactionType: transactionTypes[0],
61-
environment: ENVIRONMENT_ALL.value,
61+
environment: urlParams.environment || ENVIRONMENT_ALL.value,
6262
};
6363

6464
const params = {

0 commit comments

Comments
 (0)