Skip to content

Commit a358c57

Browse files
[Uptime] One click simple monitor down alert (#73835)
* WIP * added anomaly alert * update types * update types * update * types * types * update ML part * update ML part * update ML part * unnecessary change * icon for disable * update test * update api * update labels * resolve conflicts * fix types * fix editing alert * fix types * added actions column * added code to add alert * update anomaly message * added anomaly alert test * update * update type * fix ml legacy scoped client * update * WIP * fix conflict * added aria label * Added deleteion loading * fix type * update * update tests * update * update type * fix types * WIP * added enabled alerts section * add data * update * update tests * fix test * update i18n * update i18n * update i18n * fix * update message * update * update * update * revert * update types * added component * update test * incorporate PR feedback * fix focus * update drawer * handle edge case * improve btn text * improve btn text * use switch instead of icons * update snapshot * use compressed form * fix type * update snapshot * update snapshot * update test * update test * PR feedback * fix test and type * remove delete action * remove unnecessary function Co-authored-by: Elastic Machine <[email protected]>
1 parent 4294232 commit a358c57

File tree

93 files changed

+1828
-265
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+1828
-265
lines changed

x-pack/plugins/triggers_actions_ui/public/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export {
2121
AlertTypeParamsExpressionProps,
2222
ValidationResult,
2323
ActionVariable,
24+
ActionConnector,
2425
} from './types';
2526
export {
2627
ConnectorAddFlyout,

x-pack/plugins/uptime/common/constants/rest_api.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ export enum API_URLS {
2424
ML_DELETE_JOB = `/api/ml/jobs/delete_jobs`,
2525
ML_CAPABILITIES = '/api/ml/ml_capabilities',
2626
ML_ANOMALIES_RESULT = `/api/ml/results/anomalies_table_data`,
27+
28+
ALERT_ACTIONS = '/api/actions',
29+
CREATE_ALERT = '/api/alerts/alert',
2730
ALERT = '/api/alerts/alert/',
2831
ALERTS_FIND = '/api/alerts/_find',
2932
}

x-pack/plugins/uptime/common/constants/settings_defaults.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,5 @@ export const DYNAMIC_SETTINGS_DEFAULTS: DynamicSettings = {
1010
heartbeatIndices: 'heartbeat-8*',
1111
certAgeThreshold: 730,
1212
certExpirationThreshold: 30,
13+
defaultConnectors: [],
1314
};

x-pack/plugins/uptime/common/runtime_types/alerts/status_check.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export const AtomicStatusCheckParamsType = t.intersection([
2525
search: t.string,
2626
filters: StatusCheckFiltersType,
2727
shouldCheckStatus: t.boolean,
28+
isAutoGenerated: t.boolean,
2829
}),
2930
]);
3031

@@ -34,6 +35,7 @@ export const StatusCheckParamsType = t.intersection([
3435
t.partial({
3536
filters: t.string,
3637
shouldCheckStatus: t.boolean,
38+
isAutoGenerated: t.boolean,
3739
}),
3840
t.type({
3941
locations: t.array(t.string),

x-pack/plugins/uptime/common/runtime_types/dynamic_settings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export const DynamicSettingsType = t.type({
1010
heartbeatIndices: t.string,
1111
certAgeThreshold: t.number,
1212
certExpirationThreshold: t.number,
13+
defaultConnectors: t.array(t.string),
1314
});
1415

1516
export const DynamicSettingsSaveType = t.intersection([

x-pack/plugins/uptime/common/runtime_types/monitor/details.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export type MonitorError = t.TypeOf<typeof MonitorErrorType>;
1818

1919
export const MonitorDetailsType = t.intersection([
2020
t.type({ monitorId: t.string }),
21-
t.partial({ error: MonitorErrorType }),
22-
t.partial({ timestamp: t.string }),
21+
t.partial({ error: MonitorErrorType, timestamp: t.string, alerts: t.unknown }),
2322
]);
2423
export type MonitorDetails = t.TypeOf<typeof MonitorDetailsType>;

x-pack/plugins/uptime/public/components/common/react_router_helpers/__tests__/link_for_eui.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@ import React from 'react';
88
import { shallow, mount } from 'enzyme';
99
import { EuiLink, EuiButton } from '@elastic/eui';
1010

11-
import '../../../../lib/__mocks__/react_router_history.mock';
11+
import '../../../../lib/__mocks__/ut_router_history.mock';
1212

1313
import { ReactRouterEuiLink, ReactRouterEuiButton } from '../link_for_eui';
14-
import { mockHistory } from '../../../../lib/__mocks__';
14+
import { mockHistory } from '../../../../lib/__mocks__/ut_router_history.mock';
1515

1616
describe('EUI & React Router Component Helpers', () => {
1717
beforeEach(() => {

x-pack/plugins/uptime/public/components/monitor/ml/manage_ml_job.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { useMonitorId } from '../../../hooks';
2222
import { setAlertFlyoutType, setAlertFlyoutVisible } from '../../../state/actions';
2323
import { useAnomalyAlert } from './use_anomaly_alert';
2424
import { ConfirmAlertDeletion } from './confirm_alert_delete';
25-
import { deleteAlertAction } from '../../../state/actions/alerts';
25+
import { deleteAnomalyAlertAction } from '../../../state/alerts/alerts';
2626

2727
interface Props {
2828
hasMLJob: boolean;
@@ -52,7 +52,7 @@ export const ManageMLJobComponent = ({ hasMLJob, onEnableJob, onJobDelete }: Pro
5252
const [isConfirmAlertDeleteOpen, setIsConfirmAlertDeleteOpen] = useState(false);
5353

5454
const deleteAnomalyAlert = () =>
55-
dispatch(deleteAlertAction.get({ alertId: anomalyAlert?.id as string }));
55+
dispatch(deleteAnomalyAlertAction.get({ alertId: anomalyAlert?.id as string }));
5656

5757
const showLoading = isMLJobCreating || isMLJobLoading;
5858

x-pack/plugins/uptime/public/components/monitor/ml/use_anomaly_alert.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66

77
import { useContext, useEffect } from 'react';
88
import { useDispatch, useSelector } from 'react-redux';
9-
import { getExistingAlertAction } from '../../../state/actions/alerts';
10-
import { alertSelector, selectAlertFlyoutVisibility } from '../../../state/selectors';
9+
import { selectAlertFlyoutVisibility } from '../../../state/selectors';
1110
import { UptimeRefreshContext } from '../../../contexts';
1211
import { useMonitorId } from '../../../hooks';
12+
import { anomalyAlertSelector, getAnomalyAlertAction } from '../../../state/alerts/alerts';
1313

1414
export const useAnomalyAlert = () => {
1515
const { lastRefresh } = useContext(UptimeRefreshContext);
@@ -18,12 +18,12 @@ export const useAnomalyAlert = () => {
1818

1919
const monitorId = useMonitorId();
2020

21-
const { data: anomalyAlert } = useSelector(alertSelector);
21+
const { data: anomalyAlert } = useSelector(anomalyAlertSelector);
2222

2323
const alertFlyoutVisible = useSelector(selectAlertFlyoutVisibility);
2424

2525
useEffect(() => {
26-
dispatch(getExistingAlertAction.get({ monitorId }));
26+
dispatch(getAnomalyAlertAction.get({ monitorId }));
2727
}, [monitorId, lastRefresh, dispatch, alertFlyoutVisible]);
2828

2929
return anomalyAlert;

0 commit comments

Comments
 (0)