Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] [Uptime] One click simple monitor down alert (#73835) #76403

Merged
merged 4 commits into from
Sep 2, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions x-pack/plugins/triggers_actions_ui/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export {
AlertTypeParamsExpressionProps,
ValidationResult,
ActionVariable,
ActionConnector,
} from './types';
export {
ConnectorAddFlyout,
Expand Down
3 changes: 3 additions & 0 deletions x-pack/plugins/uptime/common/constants/rest_api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export enum API_URLS {
ML_DELETE_JOB = `/api/ml/jobs/delete_jobs`,
ML_CAPABILITIES = '/api/ml/ml_capabilities',
ML_ANOMALIES_RESULT = `/api/ml/results/anomalies_table_data`,

ALERT_ACTIONS = '/api/actions',
CREATE_ALERT = '/api/alerts/alert',
ALERT = '/api/alerts/alert/',
ALERTS_FIND = '/api/alerts/_find',
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ export const DYNAMIC_SETTINGS_DEFAULTS: DynamicSettings = {
heartbeatIndices: 'heartbeat-7*',
certAgeThreshold: 730,
certExpirationThreshold: 30,
defaultConnectors: [],
};
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export const AtomicStatusCheckParamsType = t.intersection([
search: t.string,
filters: StatusCheckFiltersType,
shouldCheckStatus: t.boolean,
isAutoGenerated: t.boolean,
}),
]);

Expand All @@ -34,6 +35,7 @@ export const StatusCheckParamsType = t.intersection([
t.partial({
filters: t.string,
shouldCheckStatus: t.boolean,
isAutoGenerated: t.boolean,
}),
t.type({
locations: t.array(t.string),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const DynamicSettingsType = t.type({
heartbeatIndices: t.string,
certAgeThreshold: t.number,
certExpirationThreshold: t.number,
defaultConnectors: t.array(t.string),
});

export const DynamicSettingsSaveType = t.intersection([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ export type MonitorError = t.TypeOf<typeof MonitorErrorType>;

export const MonitorDetailsType = t.intersection([
t.type({ monitorId: t.string }),
t.partial({ error: MonitorErrorType }),
t.partial({ timestamp: t.string }),
t.partial({ error: MonitorErrorType, timestamp: t.string, alerts: t.unknown }),
]);
export type MonitorDetails = t.TypeOf<typeof MonitorDetailsType>;
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import React from 'react';
import { shallow, mount } from 'enzyme';
import { EuiLink, EuiButton } from '@elastic/eui';

import '../../../../lib/__mocks__/react_router_history.mock';
import '../../../../lib/__mocks__/ut_router_history.mock';

import { ReactRouterEuiLink, ReactRouterEuiButton } from '../link_for_eui';
import { mockHistory } from '../../../../lib/__mocks__';
import { mockHistory } from '../../../../lib/__mocks__/ut_router_history.mock';

describe('EUI & React Router Component Helpers', () => {
beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { useMonitorId } from '../../../hooks';
import { setAlertFlyoutType, setAlertFlyoutVisible } from '../../../state/actions';
import { useAnomalyAlert } from './use_anomaly_alert';
import { ConfirmAlertDeletion } from './confirm_alert_delete';
import { deleteAlertAction } from '../../../state/actions/alerts';
import { deleteAnomalyAlertAction } from '../../../state/alerts/alerts';

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

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

const showLoading = isMLJobCreating || isMLJobLoading;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

import { useContext, useEffect } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { getExistingAlertAction } from '../../../state/actions/alerts';
import { alertSelector, selectAlertFlyoutVisibility } from '../../../state/selectors';
import { selectAlertFlyoutVisibility } from '../../../state/selectors';
import { UptimeRefreshContext } from '../../../contexts';
import { useMonitorId } from '../../../hooks';
import { anomalyAlertSelector, getAnomalyAlertAction } from '../../../state/alerts/alerts';

export const useAnomalyAlert = () => {
const { lastRefresh } = useContext(UptimeRefreshContext);
Expand All @@ -18,12 +18,12 @@ export const useAnomalyAlert = () => {

const monitorId = useMonitorId();

const { data: anomalyAlert } = useSelector(alertSelector);
const { data: anomalyAlert } = useSelector(anomalyAlertSelector);

const alertFlyoutVisible = useSelector(selectAlertFlyoutVisibility);

useEffect(() => {
dispatch(getExistingAlertAction.get({ monitorId }));
dispatch(getAnomalyAlertAction.get({ monitorId }));
}, [monitorId, lastRefresh, dispatch, alertFlyoutVisible]);

return anomalyAlert;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { getLayerList } from '../map_config';
import { mockLayerList } from './__mocks__/mock';
import { mockLayerList } from './__mocks__/poly_layer_mock';
import { LocationPoint } from '../embedded_map';
import { UptimeAppColors } from '../../../../../../apps/uptime_app';

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading