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

[7.x] [Monitoring] Migrate license expiration alert to Kibana alerting (#54306) #56677

Merged
merged 3 commits into from
Feb 4, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,45 @@ export const REPORTING_SYSTEM_ID = 'reporting';
* @type {Number}
*/
export const TELEMETRY_COLLECTION_INTERVAL = 86400000;

/**
* We want to slowly rollout the migration from watcher-based cluster alerts to
* kibana alerts and we only want to enable the kibana alerts once all
* watcher-based cluster alerts have been migrated so this flag will serve
* as the only way to see the new UI and actually run Kibana alerts. It will
* be false until all alerts have been migrated, then it will be removed
*/
export const KIBANA_ALERTING_ENABLED = false;

/**
* The prefix for all alert types used by monitoring
*/
export const ALERT_TYPE_PREFIX = 'monitoring_';

/**
* This is the alert type id for the license expiration alert
*/
export const ALERT_TYPE_LICENSE_EXPIRATION = `${ALERT_TYPE_PREFIX}alert_type_license_expiration`;

/**
* A listing of all alert types
*/
export const ALERT_TYPES = [ALERT_TYPE_LICENSE_EXPIRATION];

/**
* Matches the id for the built-in in email action type
* See x-pack/legacy/plugins/actions/server/builtin_action_types/email.ts
*/
export const ALERT_ACTION_TYPE_EMAIL = '.email';

/**
* The number of alerts that have been migrated
*/
export const NUMBER_OF_MIGRATED_ALERTS = 1;

/**
* The advanced settings config name for the email address
*/
export const MONITORING_CONFIG_ALERTING_EMAIL_ADDRESS = 'monitoring:alertingEmailAddress';

export const ALERT_EMAIL_SERVICES = ['gmail', 'hotmail', 'icloud', 'outlook365', 'ses', 'yahoo'];
20 changes: 15 additions & 5 deletions x-pack/legacy/plugins/monitoring/deprecations.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import { get } from 'lodash';
import { CLUSTER_ALERTS_ADDRESS_CONFIG_KEY } from './common/constants';
import { CLUSTER_ALERTS_ADDRESS_CONFIG_KEY, KIBANA_ALERTING_ENABLED } from './common/constants';

/**
* Re-writes deprecated user-defined config settings and logs warnings as a
Expand All @@ -21,10 +21,20 @@ export const deprecations = () => {
const clusterAlertsEnabled = get(settings, 'cluster_alerts.enabled');
const emailNotificationsEnabled =
clusterAlertsEnabled && get(settings, 'cluster_alerts.email_notifications.enabled');
if (emailNotificationsEnabled && !get(settings, CLUSTER_ALERTS_ADDRESS_CONFIG_KEY)) {
log(
`Config key "${CLUSTER_ALERTS_ADDRESS_CONFIG_KEY}" will be required for email notifications to work in 7.0."`
);
if (emailNotificationsEnabled) {
if (KIBANA_ALERTING_ENABLED) {
if (get(settings, CLUSTER_ALERTS_ADDRESS_CONFIG_KEY)) {
log(
`Config key "${CLUSTER_ALERTS_ADDRESS_CONFIG_KEY}" is deprecated. Please configure the email adddress through the Stack Monitoring UI instead."`
);
}
} else {
if (!get(settings, CLUSTER_ALERTS_ADDRESS_CONFIG_KEY)) {
log(
`Config key "${CLUSTER_ALERTS_ADDRESS_CONFIG_KEY}" will be required for email notifications to work in 7.0."`
);
}
}
}
},
(settings, log) => {
Expand Down
12 changes: 10 additions & 2 deletions x-pack/legacy/plugins/monitoring/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,20 @@ import { deprecations } from './deprecations';
import { getUiExports } from './ui_exports';
import { Plugin } from './server/plugin';
import { initInfraSource } from './server/lib/logs/init_infra_source';
import { KIBANA_ALERTING_ENABLED } from './common/constants';

/**
* Invokes plugin modules to instantiate the Monitoring plugin for Kibana
* @param kibana {Object} Kibana plugin instance
* @return {Object} Monitoring UI Kibana plugin object
*/
const deps = ['kibana', 'elasticsearch', 'xpack_main'];
if (KIBANA_ALERTING_ENABLED) {
deps.push(...['alerting', 'actions']);
}
export const monitoring = kibana =>
new kibana.Plugin({
require: ['kibana', 'elasticsearch', 'xpack_main'],
require: deps,
id: 'monitoring',
configPrefix: 'monitoring',
publicDir: resolve(__dirname, 'public'),
Expand Down Expand Up @@ -60,6 +65,7 @@ export const monitoring = kibana =>
}),
injectUiAppVars: server.injectUiAppVars,
log: (...args) => server.log(...args),
logger: server.newPlatform.coreContext.logger,
getOSInfo: server.getOSInfo,
events: {
on: (...args) => server.events.on(...args),
Expand All @@ -74,11 +80,13 @@ export const monitoring = kibana =>
xpack_main: server.plugins.xpack_main,
elasticsearch: server.plugins.elasticsearch,
infra: server.plugins.infra,
alerting: server.plugins.alerting,
usageCollection,
licensing,
};

new Plugin().setup(serverFacade, plugins);
const plugin = new Plugin();
plugin.setup(serverFacade, plugins);
},
config,
deprecations,
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading