-
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.
[Monitoring] Disk usage alerting (#75419)
* Disk usage alert draft * Fixed typings and defaults * Fixed tests * Fixed tests * Addressed code feedback * Fixed disk and cpu usage states * Fixed resolve state and throttle * CR feedback * Fixed links
- Loading branch information
Showing
39 changed files
with
1,076 additions
and
706 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
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
29 changes: 29 additions & 0 deletions
29
x-pack/plugins/monitoring/public/alerts/disk_usage_alert/index.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,29 @@ | ||
/* | ||
* 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 { validate } from '../components/duration/validation'; | ||
import { Expression, Props } from '../components/duration/expression'; | ||
|
||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths | ||
import { AlertTypeModel } from '../../../../triggers_actions_ui/public/types'; | ||
|
||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths | ||
import { DiskUsageAlert } from '../../../server/alerts'; | ||
|
||
export function createDiskUsageAlertType(): AlertTypeModel { | ||
return { | ||
id: DiskUsageAlert.TYPE, | ||
name: DiskUsageAlert.LABEL, | ||
iconClass: 'bell', | ||
alertParamsExpression: (props: Props) => ( | ||
<Expression {...props} paramDetails={DiskUsageAlert.PARAM_DETAILS} /> | ||
), | ||
validate, | ||
defaultActionMessage: '{{context.internalFullMessage}}', | ||
requiresAppContext: true, | ||
}; | ||
} |
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
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,82 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
import { AlertMessageDocLinkToken } from './types'; | ||
import { AlertMessageTokenType } from '../../common/enums'; | ||
|
||
export class AlertingDefaults { | ||
public static readonly ALERT_STATE = { | ||
resolved: i18n.translate('xpack.monitoring.alerts.state.resolved', { | ||
defaultMessage: 'resolved', | ||
}), | ||
firing: i18n.translate('xpack.monitoring.alerts.state.firing', { | ||
defaultMessage: 'firing', | ||
}), | ||
}; | ||
public static readonly ALERT_TYPE = { | ||
context: { | ||
internalShortMessage: { | ||
name: 'internalShortMessage', | ||
description: i18n.translate( | ||
'xpack.monitoring.alerts.actionVariables.internalShortMessage', | ||
{ | ||
defaultMessage: 'The short internal message generated by Elastic.', | ||
} | ||
), | ||
}, | ||
internalFullMessage: { | ||
name: 'internalFullMessage', | ||
description: i18n.translate('xpack.monitoring.alerts.actionVariables.internalFullMessage', { | ||
defaultMessage: 'The full internal message generated by Elastic.', | ||
}), | ||
}, | ||
state: { | ||
name: 'state', | ||
description: i18n.translate('xpack.monitoring.alerts.actionVariables.state', { | ||
defaultMessage: 'The current state of the alert.', | ||
}), | ||
}, | ||
clusterName: { | ||
name: 'clusterName', | ||
description: i18n.translate('xpack.monitoring.alerts.actionVariables.clusterName', { | ||
defaultMessage: 'The cluster to which the nodes belong.', | ||
}), | ||
}, | ||
action: { | ||
name: 'action', | ||
description: i18n.translate('xpack.monitoring.alerts.actionVariables.action', { | ||
defaultMessage: 'The recommended action for this alert.', | ||
}), | ||
}, | ||
actionPlain: { | ||
name: 'actionPlain', | ||
description: i18n.translate('xpack.monitoring.alerts.actionVariables.actionPlain', { | ||
defaultMessage: 'The recommended action for this alert, without any markdown.', | ||
}), | ||
}, | ||
}, | ||
}; | ||
} | ||
|
||
export const createLink = ( | ||
linkText: string, | ||
linkURL: string, | ||
type: AlertMessageTokenType = AlertMessageTokenType.DocLink | ||
) => { | ||
const link = type === AlertMessageTokenType.DocLink ? { partialUrl: linkURL } : { url: linkURL }; | ||
return { | ||
text: linkText, | ||
tokens: [ | ||
{ | ||
...link, | ||
startToken: '#start_link', | ||
endToken: '#end_link', | ||
type, | ||
} as AlertMessageDocLinkToken, | ||
], | ||
}; | ||
}; |
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
Oops, something went wrong.