-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Backports the following commits to 7.x: [Uptime] Add Alerting UI (#57919)
- Loading branch information
1 parent
77c8de1
commit e302cdc
Showing
59 changed files
with
3,245 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
interface ActionGroupDefinition { | ||
id: string; | ||
name: string; | ||
} | ||
|
||
type ActionGroupDefinitions = Record<string, ActionGroupDefinition>; | ||
|
||
export const ACTION_GROUP_DEFINITIONS: ActionGroupDefinitions = { | ||
MONITOR_STATUS: { | ||
id: 'xpack.uptime.alerts.actionGroups.monitorStatus', | ||
name: 'Uptime Down Monitor', | ||
}, | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,4 @@ | |
|
||
export const INDEX_NAMES = { | ||
HEARTBEAT: 'heartbeat*', | ||
HEARTBEAT_STATES: 'heartbeat-states-7*', | ||
}; |
12 changes: 12 additions & 0 deletions
12
x-pack/legacy/plugins/uptime/common/runtime_types/alerts/index.ts
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,12 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export { | ||
StatusCheckAlertStateType, | ||
StatusCheckAlertState, | ||
StatusCheckExecutorParamsType, | ||
StatusCheckExecutorParams, | ||
} from './status_check'; |
39 changes: 39 additions & 0 deletions
39
x-pack/legacy/plugins/uptime/common/runtime_types/alerts/status_check.ts
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,39 @@ | ||
/* | ||
* 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 * as t from 'io-ts'; | ||
|
||
export const StatusCheckAlertStateType = t.intersection([ | ||
t.partial({ | ||
currentTriggerStarted: t.string, | ||
firstTriggeredAt: t.string, | ||
lastTriggeredAt: t.string, | ||
lastResolvedAt: t.string, | ||
}), | ||
t.type({ | ||
firstCheckedAt: t.string, | ||
lastCheckedAt: t.string, | ||
isTriggered: t.boolean, | ||
}), | ||
]); | ||
|
||
export type StatusCheckAlertState = t.TypeOf<typeof StatusCheckAlertStateType>; | ||
|
||
export const StatusCheckExecutorParamsType = t.intersection([ | ||
t.partial({ | ||
filters: t.string, | ||
}), | ||
t.type({ | ||
locations: t.array(t.string), | ||
numTimes: t.number, | ||
timerange: t.type({ | ||
from: t.string, | ||
to: t.string, | ||
}), | ||
}), | ||
]); | ||
|
||
export type StatusCheckExecutorParams = t.TypeOf<typeof StatusCheckExecutorParamsType>; |
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
43 changes: 43 additions & 0 deletions
43
x-pack/legacy/plugins/uptime/public/components/connected/alerts/alert_monitor_status.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,43 @@ | ||
/* | ||
* 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 { useSelector } from 'react-redux'; | ||
import { DataPublicPluginSetup } from 'src/plugins/data/public'; | ||
import { selectMonitorStatusAlert } from '../../../state/selectors'; | ||
import { AlertMonitorStatusComponent } from '../../functional/alerts/alert_monitor_status'; | ||
|
||
interface Props { | ||
autocomplete: DataPublicPluginSetup['autocomplete']; | ||
enabled: boolean; | ||
numTimes: number; | ||
setAlertParams: (key: string, value: any) => void; | ||
timerange: { | ||
from: string; | ||
to: string; | ||
}; | ||
} | ||
|
||
export const AlertMonitorStatus = ({ | ||
autocomplete, | ||
enabled, | ||
numTimes, | ||
setAlertParams, | ||
timerange, | ||
}: Props) => { | ||
const { filters, locations } = useSelector(selectMonitorStatusAlert); | ||
return ( | ||
<AlertMonitorStatusComponent | ||
autocomplete={autocomplete} | ||
enabled={enabled} | ||
filters={filters} | ||
locations={locations} | ||
numTimes={numTimes} | ||
setAlertParams={setAlertParams} | ||
timerange={timerange} | ||
/> | ||
); | ||
}; |
9 changes: 9 additions & 0 deletions
9
x-pack/legacy/plugins/uptime/public/components/connected/alerts/index.ts
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,9 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export { AlertMonitorStatus } from './alert_monitor_status'; | ||
export { ToggleAlertFlyoutButton } from './toggle_alert_flyout_button'; | ||
export { UptimeAlertsFlyoutWrapper } from './uptime_alerts_flyout_wrapper'; |
19 changes: 19 additions & 0 deletions
19
...k/legacy/plugins/uptime/public/components/connected/alerts/toggle_alert_flyout_button.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,19 @@ | ||
/* | ||
* 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 { useDispatch } from 'react-redux'; | ||
import { ToggleAlertFlyoutButtonComponent } from '../../functional'; | ||
import { setAlertFlyoutVisible } from '../../../state/actions'; | ||
|
||
export const ToggleAlertFlyoutButton = () => { | ||
const dispatch = useDispatch(); | ||
return ( | ||
<ToggleAlertFlyoutButtonComponent | ||
setAlertFlyoutVisible={(value: boolean) => dispatch(setAlertFlyoutVisible(value))} | ||
/> | ||
); | ||
}; |
34 changes: 34 additions & 0 deletions
34
...legacy/plugins/uptime/public/components/connected/alerts/uptime_alerts_flyout_wrapper.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,34 @@ | ||
/* | ||
* 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 { useDispatch, useSelector } from 'react-redux'; | ||
import { UptimeAlertsFlyoutWrapperComponent } from '../../functional'; | ||
import { setAlertFlyoutVisible } from '../../../state/actions'; | ||
import { selectAlertFlyoutVisibility } from '../../../state/selectors'; | ||
|
||
interface Props { | ||
alertTypeId?: string; | ||
canChangeTrigger?: boolean; | ||
} | ||
|
||
export const UptimeAlertsFlyoutWrapper = ({ alertTypeId, canChangeTrigger }: Props) => { | ||
const dispatch = useDispatch(); | ||
const setAddFlyoutVisiblity = (value: React.SetStateAction<boolean>) => | ||
// @ts-ignore the value here is a boolean, and it works with the action creator function | ||
dispatch(setAlertFlyoutVisible(value)); | ||
|
||
const alertFlyoutVisible = useSelector(selectAlertFlyoutVisibility); | ||
|
||
return ( | ||
<UptimeAlertsFlyoutWrapperComponent | ||
alertFlyoutVisible={alertFlyoutVisible} | ||
alertTypeId={alertTypeId} | ||
canChangeTrigger={canChangeTrigger} | ||
setAlertFlyoutVisibility={setAddFlyoutVisiblity} | ||
/> | ||
); | ||
}; |
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.