Skip to content

Commit

Permalink
Added flag to change the alerts app context requirment (#91726)
Browse files Browse the repository at this point in the history
  • Loading branch information
igoristic authored Feb 17, 2021
1 parent da780f5 commit 31810c6
Show file tree
Hide file tree
Showing 9 changed files with 49 additions and 15 deletions.
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,
};
}

0 comments on commit 31810c6

Please sign in to comment.