chore(alerting): add default message templates (#14988)

* chore(alerts): add message defaults to check and endpoint creation

* chore(alerts): time machine is two words :)
pull/14994/head
Andrew Watkins 2019-09-05 15:50:34 -07:00 committed by GitHub
commit e616e0fee4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 17 additions and 10 deletions

View File

@ -24,6 +24,9 @@ type RuleVariantFields =
| PagerDutyNotificationRuleBase
| HTTPNotificationRuleBase
const defaultMessage =
'Notification Rule: ${ r._notification_rule_name } triggered by check: ${ r._check_name }'
export const getRuleVariantDefaults = (
endpoints: NotificationEndpoint[],
id: string
@ -32,11 +35,11 @@ export const getRuleVariantDefaults = (
switch (endpoint.type) {
case 'slack': {
return {messageTemplate: '', channel: '', type: 'slack'}
return {messageTemplate: defaultMessage, channel: '', type: 'slack'}
}
case 'pagerduty': {
return {messageTemplate: '', type: 'pagerduty'}
return {messageTemplate: defaultMessage, type: 'pagerduty'}
}
case 'http': {

View File

@ -18,6 +18,8 @@ export const DEFAULT_CHECK_EVERY = '5m'
export const DEFAULT_CHECK_OFFSET = '0s'
export const DEFAULT_CHECK_REPORT_ZERO = false
export const DEFAULT_DEADMAN_LEVEL: CheckStatusLevel = 'CRIT'
export const DEFAULT_STATUS_MESSAGE =
'Check: ${ r._check_name }\n\nIs at level: ${ r._level }'
export const CHECK_EVERY_OPTIONS = DURATIONS
@ -58,6 +60,7 @@ export const DEFAULT_THRESHOLD_CHECK: Partial<ThresholdCheck> = {
thresholds: [],
every: DEFAULT_CHECK_EVERY,
offset: DEFAULT_CHECK_OFFSET,
statusMessageTemplate: DEFAULT_STATUS_MESSAGE,
}
export const DEFAULT_DEADMAN_CHECK: Partial<DeadmanCheck> = {
@ -68,6 +71,7 @@ export const DEFAULT_DEADMAN_CHECK: Partial<DeadmanCheck> = {
offset: DEFAULT_CHECK_OFFSET,
reportZero: DEFAULT_CHECK_REPORT_ZERO,
level: DEFAULT_DEADMAN_LEVEL,
statusMessageTemplate: DEFAULT_STATUS_MESSAGE,
}
export const CHECK_QUERY_FIXTURE: DashboardQuery = {

View File

@ -611,7 +611,7 @@ export const setXAxisLabel = (xAxisLabel: string): SetXAxisLabelAction => ({
})
export const setCheckStatus = (checkStatus: RemoteDataState) => ({
type: 'SET_TIMEMACHINE_CHECK_STATUS' as 'SET_TIMEMACHINE_CHECK_STATUS',
type: 'SET_TIME_MACHINE_CHECK_STATUS' as 'SET_TIME_MACHINE_CHECK_STATUS',
payload: {checkStatus},
})
@ -619,17 +619,17 @@ export const setTimeMachineCheck = (
checkStatus: RemoteDataState,
check: Partial<Check>
) => ({
type: 'SET_TIMEMACHINE_CHECK' as 'SET_TIMEMACHINE_CHECK',
type: 'SET_TIME_MACHINE_CHECK' as 'SET_TIME_MACHINE_CHECK',
payload: {checkStatus, check},
})
export const updateTimeMachineCheck = (checkUpdate: Partial<Check>) => ({
type: 'UPDATE_TIMEMACHINE_CHECK' as 'UPDATE_TIMEMACHINE_CHECK',
type: 'UPDATE_TIME_MACHINE_CHECK' as 'UPDATE_TIME_MACHINE_CHECK',
payload: {checkUpdate},
})
export const changeCheckType = (toType: CheckType) => ({
type: 'CHANGE_TIMEMACHINE_CHECK_TYPE' as 'CHANGE_TIMEMACHINE_CHECK_TYPE',
type: 'CHANGE_TIME_MACHINE_CHECK_TYPE' as 'CHANGE_TIME_MACHINE_CHECK_TYPE',
payload: {toType},
})

View File

@ -829,20 +829,20 @@ export const timeMachineReducer = (
})
}
case 'SET_TIMEMACHINE_CHECK_STATUS': {
case 'SET_TIME_MACHINE_CHECK_STATUS': {
const {checkStatus} = action.payload
return {...state, alerting: {...state.alerting, checkStatus}}
}
case 'SET_TIMEMACHINE_CHECK':
case 'SET_TIME_MACHINE_CHECK':
const alerting = {
check: action.payload.check,
checkStatus: action.payload.checkStatus,
}
return {...state, alerting}
case 'UPDATE_TIMEMACHINE_CHECK':
case 'UPDATE_TIME_MACHINE_CHECK':
return produce(state, draftState => {
draftState.alerting.check = {
...draftState.alerting.check,
@ -862,7 +862,7 @@ export const timeMachineReducer = (
}
})
case 'CHANGE_TIMEMACHINE_CHECK_TYPE':
case 'CHANGE_TIME_MACHINE_CHECK_TYPE':
return produce(state, draftState => {
const exCheck = draftState.alerting.check