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

Deprecate xpack:defaultAdminEmail for monitoring alerts #22195

Merged

Conversation

legrego
Copy link
Member

@legrego legrego commented Aug 20, 2018

This PR introduces a new kibana.yml setting to allow users to set the email address used to receive cluster alert notifications:

xpack.monitoring.cluster_alerts.email_notifications.email_address

If this is not set, then a deprecation warning will be logged warning that it will be required for Kibana 7.0. For the remainder of 6.x, Kibana will fallback to using the xpack:defaultAdminEmail setting from the advanced settings. When Spaces is enabled, then the setting will be retrieved from the Default Space's advanced settings.

Fixes #22146

"Release note: The xpack:defaultAdminEmail UI Setting is deprecated for Monitoring, but is still fully supported for the Watcher UI. Users who wish to receive cluster alert notification emails should configure xpack.monitoring.cluster_alerts.email_notifications.email_address in kibana.yml instead."

@legrego legrego added the WIP Work in progress label Aug 20, 2018
@elasticmachine
Copy link
Contributor

💚 Build Succeeded


let loggedDeprecationWarning = false;

export function resetDeprecationWarning() {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only exists to enable test cases to reset the module state. I realize how ugly this is, but I was weighing the tradeoff of this vs a larger, more complex solution. I chose this because it is a short-lived feature that we will remove with 7.0

@legrego legrego added v6.5.0 v7.0.0 Team:Monitoring Stack Monitoring team labels Aug 22, 2018
@elastic elastic deleted a comment from elasticmachine Aug 22, 2018
@legrego legrego changed the title [WIP] Deprecate xpack:defaultAdminEmail for monitoring alerts Deprecate xpack:defaultAdminEmail for monitoring alerts Aug 22, 2018
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@legrego legrego added review and removed WIP Work in progress labels Aug 23, 2018
@legrego
Copy link
Member Author

legrego commented Aug 23, 2018

@tsullivan @pickypg
GH suggests the two of you as reviewers on this PR. Would one or both of you be available for a review, or do you know someone better suited for this?

@legrego legrego requested a review from pickypg August 27, 2018 14:22
@tsullivan tsullivan self-requested a review August 27, 2018 18:03
* you may not use this file except in compliance with the Elastic License.
*/

export const CLUSTER_ALERTS_ADDRESS_CONFIG_KEY = 'cluster_alerts.email_notifications.email_address';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be better to put this in x-pack/plugins/monitoring/common/constants.js

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@@ -49,7 +49,8 @@ export const config = (Joi) => {
enabled: boolean().default(true),
index: string().default('.monitoring-alerts-6'),
email_notifications: object({
enabled: boolean().default(true)
enabled: boolean().default(true),
email_address: string().email(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably want to keep a similar name as the setting getting deprecated. Maybe default_admin_email

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I considered default_admin_email, but to me, that implies that the email address can be overridden somewhere else. If I understand it correctly, Monitoring doesn't allow the email address to be changed for cluster alerts.

The xpack:defaultAdminEmail advanced setting makes sense as a default option when creating new watcher jobs through the UI, because it really is the default setting, which the user can change.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The xpack:defaultAdminEmail advanced setting makes sense as a default option when creating new watcher jobs through the UI, because it really is the default setting, which the user can change.

Interesting, I didn't realize Watcher UI uses this setting!

I'm OK with how you had it.

@tsullivan
Copy link
Member

I still need to look through in more depth, but one thing I want to test is that https://github.com/elastic/kibana/pull/22220/files isn't affected. I think this will need to get the master branch merged in

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

// DEPRECATED (Remove below in 7.0): If an email address is not configured in kibana.yml, then fallback to xpack:defaultAdminEmail
if (!loggedDeprecationWarning) {
const message = (
`Monitoring is using ${XPACK_DEFAULT_ADMIN_EMAIL_UI_SETTING} for cluster alert notifications,` +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need a space at end end of this line's string, so notifications, which has a space between

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."`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm running this PR branch and trying to get this log to show up, but I'm not seeing it. I see undefined for clusterAlertsEnabled, emailNotificationsEnabled. I have a trial license and cluster alerts are enabled

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I discovered while putting this PR together that the depreciation system only passes through the settings that are explicitly defined in your kibana.yml. Settings that are defaulted via the plugin schema are not provided.

To say another way, you'll see this warning if and only if you define the following in your kibana.yml:

xpack.monitoring.cluster_alerts.enabled: true
xpack.monitoring.cluster_alerts.email_notifications.enabled: true

This is what led me to implement the other deprecation warning, so that it would be more obvious/helpful to ordinary installations that don't redefine default configuration settings.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know, thanks!

Copy link
Member

@tsullivan tsullivan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comma thing should be fixed. It looks like the deprecation log does too, but that might be an external issue

@elasticmachine
Copy link
Contributor

💔 Build Failed

@legrego
Copy link
Member Author

legrego commented Aug 28, 2018

Seemingly unrelated viz test failure.
Jenkins, test this please

@elasticmachine
Copy link
Contributor

💚 Build Succeeded

@legrego
Copy link
Member Author

legrego commented Sep 4, 2018

@tsullivan do you have any other feedback for this PR? If not, are you available to give it a LGTM?

Copy link
Member

@tsullivan tsullivan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@legrego legrego removed the request for review from pickypg September 4, 2018 16:19
@elasticmachine
Copy link
Contributor

💚 Build Succeeded

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants