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

[Monitoring][Alerts] Enable edit/create for Stack Monitoring alerts in Alerts Management #91726

Merged
merged 2 commits into from
Feb 17, 2021
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
5 changes: 5 additions & 0 deletions x-pack/plugins/monitoring/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,11 @@ export const ALERT_ACTION_TYPE_EMAIL = '.email';
*/
export const ALERT_ACTION_TYPE_LOG = '.server-log';

/**
* To enable modifing of alerts in under actions
*/
export const ALERT_REQUIRES_APP_CONTEXT = false;

export const ALERT_EMAIL_SERVICES = ['gmail', 'hotmail', 'icloud', 'outlook365', 'ses', 'yahoo'];

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import React from 'react';
import { i18n } from '@kbn/i18n';
import { Expression, Props } from '../components/param_details_form/expression';
import { AlertTypeModel, ValidationResult } from '../../../../triggers_actions_ui/public';
import { ALERT_CCR_READ_EXCEPTIONS, ALERT_DETAILS } from '../../../common/constants';
import {
ALERT_CCR_READ_EXCEPTIONS,
ALERT_DETAILS,
ALERT_REQUIRES_APP_CONTEXT,
} from '../../../common/constants';
import { AlertTypeParams } from '../../../../alerts/common';

interface ValidateOptions extends AlertTypeParams {
Expand Down Expand Up @@ -45,6 +49,6 @@ export function createCCRReadExceptionsAlertType(): AlertTypeModel<ValidateOptio
),
validate,
defaultActionMessage: '{{context.internalFullMessage}}',
requiresAppContext: true,
requiresAppContext: ALERT_REQUIRES_APP_CONTEXT,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
import React from 'react';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { AlertTypeModel } from '../../../../triggers_actions_ui/public/types';
import { ALERT_CPU_USAGE, ALERT_DETAILS } from '../../../common/constants';
import {
ALERT_CPU_USAGE,
ALERT_DETAILS,
ALERT_REQUIRES_APP_CONTEXT,
} from '../../../common/constants';
import { validate, MonitoringAlertTypeParams } from '../components/param_details_form/validation';
import { Expression, Props } from '../components/param_details_form/expression';

Expand All @@ -25,6 +29,6 @@ export function createCpuUsageAlertType(): AlertTypeModel<MonitoringAlertTypePar
),
validate,
defaultActionMessage: '{{context.internalFullMessage}}',
requiresAppContext: true,
requiresAppContext: ALERT_REQUIRES_APP_CONTEXT,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import { Expression, Props } from '../components/param_details_form/expression';

// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { AlertTypeModel } from '../../../../triggers_actions_ui/public/types';
import { ALERT_DISK_USAGE, ALERT_DETAILS } from '../../../common/constants';
import {
ALERT_DISK_USAGE,
ALERT_DETAILS,
ALERT_REQUIRES_APP_CONTEXT,
} from '../../../common/constants';

export function createDiskUsageAlertType(): AlertTypeModel<MonitoringAlertTypeParams> {
return {
Expand All @@ -26,6 +30,6 @@ export function createDiskUsageAlertType(): AlertTypeModel<MonitoringAlertTypePa
),
validate,
defaultActionMessage: '{{context.internalFullMessage}}',
requiresAppContext: true,
requiresAppContext: ALERT_REQUIRES_APP_CONTEXT,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import React from 'react';
import { i18n } from '@kbn/i18n';
import { Expression, Props } from '../components/param_details_form/expression';
import { AlertTypeModel, ValidationResult } from '../../../../triggers_actions_ui/public';
import { ALERT_LARGE_SHARD_SIZE, ALERT_DETAILS } from '../../../common/constants';
import {
ALERT_LARGE_SHARD_SIZE,
ALERT_DETAILS,
ALERT_REQUIRES_APP_CONTEXT,
} from '../../../common/constants';
import { AlertTypeParams } from '../../../../alerts/common';

interface ValidateOptions extends AlertTypeParams {
Expand Down Expand Up @@ -45,6 +49,6 @@ export function createLargeShardSizeAlertType(): AlertTypeModel<ValidateOptions>
),
validate,
defaultActionMessage: '{{context.internalFullMessage}}',
requiresAppContext: true,
requiresAppContext: ALERT_REQUIRES_APP_CONTEXT,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import { i18n } from '@kbn/i18n';
import { EuiTextColor, EuiSpacer } from '@elastic/eui';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { AlertTypeModel } from '../../../../triggers_actions_ui/public/types';
import { LEGACY_ALERTS, LEGACY_ALERT_DETAILS } from '../../../common/constants';
import {
LEGACY_ALERTS,
LEGACY_ALERT_DETAILS,
ALERT_REQUIRES_APP_CONTEXT,
} from '../../../common/constants';

export function createLegacyAlertTypes(): AlertTypeModel[] {
return LEGACY_ALERTS.map((legacyAlert) => {
Expand All @@ -34,7 +38,7 @@ export function createLegacyAlertTypes(): AlertTypeModel[] {
),
defaultActionMessage: '{{context.internalFullMessage}}',
validate: () => ({ errors: {} }),
requiresAppContext: true,
requiresAppContext: ALERT_REQUIRES_APP_CONTEXT,
};
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import { Expression, Props } from '../components/param_details_form/expression';

// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { AlertTypeModel } from '../../../../triggers_actions_ui/public/types';
import { ALERT_MEMORY_USAGE, ALERT_DETAILS } from '../../../common/constants';
import {
ALERT_MEMORY_USAGE,
ALERT_DETAILS,
ALERT_REQUIRES_APP_CONTEXT,
} from '../../../common/constants';

export function createMemoryUsageAlertType(): AlertTypeModel<MonitoringAlertTypeParams> {
return {
Expand All @@ -26,6 +30,6 @@ export function createMemoryUsageAlertType(): AlertTypeModel<MonitoringAlertType
),
validate,
defaultActionMessage: '{{context.internalFullMessage}}',
requiresAppContext: true,
requiresAppContext: ALERT_REQUIRES_APP_CONTEXT,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,11 @@ import React from 'react';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { AlertTypeModel } from '../../../../triggers_actions_ui/public/types';
import { validate } from './validation';
import { ALERT_MISSING_MONITORING_DATA, ALERT_DETAILS } from '../../../common/constants';
import {
ALERT_MISSING_MONITORING_DATA,
ALERT_DETAILS,
ALERT_REQUIRES_APP_CONTEXT,
} from '../../../common/constants';
import { Expression } from './expression';

export function createMissingMonitoringDataAlertType(): AlertTypeModel {
Expand All @@ -28,6 +32,6 @@ export function createMissingMonitoringDataAlertType(): AlertTypeModel {
),
validate,
defaultActionMessage: '{{context.internalFullMessage}}',
requiresAppContext: true,
requiresAppContext: ALERT_REQUIRES_APP_CONTEXT,
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { Expression, Props } from '../components/param_details_form/expression';
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { AlertTypeModel } from '../../../../triggers_actions_ui/public/types';
import { CommonAlertParamDetails } from '../../../common/types/alerts';
import { ALERT_REQUIRES_APP_CONTEXT } from '../../../common/constants';

interface ThreadPoolTypes {
[key: string]: unknown;
Expand Down Expand Up @@ -60,6 +61,6 @@ export function createThreadPoolRejectionsAlertType(
return { errors };
},
defaultActionMessage: '{{context.internalFullMessage}}',
requiresAppContext: true,
requiresAppContext: ALERT_REQUIRES_APP_CONTEXT,
};
}