From 46402538d2771b2a448e1c9a71e306e72af86fb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ester=20Mart=C3=AD=20Vilaseca?= Date: Tue, 29 Jun 2021 17:35:37 +0200 Subject: [PATCH] [Monitoring] Enable out of the box alerts modal (#101565) * Remove api call to create alerts * Add enable alerts modal * Update modal title * Add simple alerts dropdown * change alerts modal design * refactor alerts modal provider * Add alerts dropdown * Show toast after alert creation and add error handling * Do not show alerts modal if alerts already exist * Fix stack monitoring test * Fix more stack monitoring tests and types * Fix tests after merge * Attempt to fix stack monitoring tests * remove console.log * Change text * Remove commented comment * Update docs for stack monitoring alerts * Fix docs Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> --- docs/user/monitoring/kibana-alerts.asciidoc | 12 +- .../public/alerts/alerts_dropdown.tsx | 77 +++++++++ .../public/alerts/enable_alerts_modal.tsx | 148 ++++++++++++++++++ .../monitoring/public/angular/app_modules.ts | 5 + .../monitoring/public/angular/index.ts | 2 + .../plugins/monitoring/public/legacy_shims.ts | 13 +- x-pack/plugins/monitoring/public/plugin.ts | 1 + .../monitoring/public/services/clusters.js | 14 +- .../public/services/enable_alerts_modal.js | 53 +++++++ x-pack/plugins/monitoring/public/types.ts | 3 +- .../public/views/base_controller.js | 7 + .../public/views/cluster/overview/index.js | 2 + .../apps/monitoring/beats/beat_detail.js | 2 + .../apps/monitoring/beats/cluster.js | 2 + .../apps/monitoring/beats/listing.js | 2 + .../apps/monitoring/beats/overview.js | 2 + .../apps/monitoring/cluster/list.js | 1 + .../apps/monitoring/cluster/overview.js | 6 + .../monitoring/elasticsearch/index_detail.js | 2 + .../elasticsearch/index_detail_mb.js | 2 + .../apps/monitoring/elasticsearch/indices.js | 2 + .../monitoring/elasticsearch/indices_mb.js | 2 + .../monitoring/elasticsearch/node_detail.js | 6 + .../elasticsearch/node_detail_mb.js | 6 + .../apps/monitoring/elasticsearch/nodes.js | 2 + .../apps/monitoring/elasticsearch/nodes_mb.js | 4 + .../apps/monitoring/elasticsearch/overview.js | 2 + .../monitoring/elasticsearch/overview_mb.js | 2 + .../monitoring/enable_monitoring/index.js | 1 + .../apps/monitoring/kibana/instance.js | 2 + .../apps/monitoring/kibana/instance_mb.js | 2 + .../apps/monitoring/kibana/instances.js | 2 + .../apps/monitoring/kibana/instances_mb.js | 2 + .../apps/monitoring/kibana/overview.js | 2 + .../apps/monitoring/kibana/overview_mb.js | 2 + .../apps/monitoring/logstash/pipelines.js | 2 + .../apps/monitoring/logstash/pipelines_mb.js | 2 + .../page_objects/monitoring_page.ts | 4 + .../services/monitoring/cluster_overview.js | 4 + 39 files changed, 389 insertions(+), 18 deletions(-) create mode 100644 x-pack/plugins/monitoring/public/alerts/alerts_dropdown.tsx create mode 100644 x-pack/plugins/monitoring/public/alerts/enable_alerts_modal.tsx create mode 100644 x-pack/plugins/monitoring/public/services/enable_alerts_modal.js diff --git a/docs/user/monitoring/kibana-alerts.asciidoc b/docs/user/monitoring/kibana-alerts.asciidoc index ccd023f180c99b..67e4520f5c70c3 100644 --- a/docs/user/monitoring/kibana-alerts.asciidoc +++ b/docs/user/monitoring/kibana-alerts.asciidoc @@ -11,8 +11,8 @@ specific needs. [role="screenshot"] image::user/monitoring/images/monitoring-kibana-alerting-notification.png["{kib} alerting notifications in {stack-monitor-app}"] -When you open *{stack-monitor-app}*, the preconfigured rules are created -automatically. They are initially configured to detect and notify on various +When you open *{stack-monitor-app}*, you will be ask to create these rules +They are initially configured to detect and notify on various conditions across your monitored clusters. You can view notifications for: *Cluster health*, *Resource utilization*, and *Errors and exceptions* for {es} in real time. @@ -131,6 +131,14 @@ soon the expiration date is: The 60-day and 30-day thresholds are skipped for Trial licenses, which are only valid for 30 days. +[discrete] +== Alerts and rules +[discrete] +=== Create default rules +This option can be used to create default rules in this kibana spaces. This is +useful for scenarios when you didn't choose to create these default rules initially +or anytime later if the rules were accidentally deleted. + NOTE: Some action types are subscription features, while others are free. For a comparison of the Elastic subscription levels, see the alerting section of the {subscriptions}[Subscriptions page]. diff --git a/x-pack/plugins/monitoring/public/alerts/alerts_dropdown.tsx b/x-pack/plugins/monitoring/public/alerts/alerts_dropdown.tsx new file mode 100644 index 00000000000000..df0cbb43f85695 --- /dev/null +++ b/x-pack/plugins/monitoring/public/alerts/alerts_dropdown.tsx @@ -0,0 +1,77 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import { + EuiButtonEmpty, + EuiContextMenu, + EuiContextMenuPanelDescriptor, + EuiPopover, +} from '@elastic/eui'; +import { i18n } from '@kbn/i18n'; +import React, { useState } from 'react'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { Legacy } from '../legacy_shims'; + +export const AlertsDropdown: React.FC<{}> = () => { + const $injector = Legacy.shims.getAngularInjector(); + const alertsEnableModalProvider: any = $injector.get('enableAlertsModal'); + + const [isPopoverOpen, setIsPopoverOpen] = useState(false); + + const closePopover = () => { + alertsEnableModalProvider.enableAlerts(); + setIsPopoverOpen(false); + }; + + const togglePopoverVisibility = () => { + setIsPopoverOpen(!isPopoverOpen); + }; + + const createDefaultRules = () => { + closePopover(); + }; + + const button = ( + + + + ); + + const items = [ + { + name: i18n.translate('xpack.monitoring.alerts.dropdown.createAlerts', { + defaultMessage: 'Create default rules', + }), + onClick: createDefaultRules, + }, + ]; + + const panels: EuiContextMenuPanelDescriptor[] = [ + { + id: 0, + title: i18n.translate('xpack.monitoring.alerts.dropdown.title', { + defaultMessage: 'Alerts and rules', + }), + items, + }, + ]; + + return ( + + + + ); +}; diff --git a/x-pack/plugins/monitoring/public/alerts/enable_alerts_modal.tsx b/x-pack/plugins/monitoring/public/alerts/enable_alerts_modal.tsx new file mode 100644 index 00000000000000..914446c42aaa79 --- /dev/null +++ b/x-pack/plugins/monitoring/public/alerts/enable_alerts_modal.tsx @@ -0,0 +1,148 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ + +import React, { useEffect, useState, useContext } from 'react'; + +import { + EuiButton, + EuiModal, + EuiModalBody, + EuiModalFooter, + EuiModalHeader, + EuiModalHeaderTitle, + EuiButtonEmpty, + EuiText, + EuiLink, + EuiRadioGroup, + EuiSpacer, +} from '@elastic/eui'; +import { FormattedMessage } from '@kbn/i18n/react'; +import { i18n } from '@kbn/i18n'; +import { AlertsContext } from './context'; +import { Legacy } from '../legacy_shims'; + +export const EnableAlertsModal: React.FC<{}> = () => { + const [isModalVisible, setIsModalVisible] = useState(false); + const $injector = Legacy.shims.getAngularInjector(); + const alertsEnableModalProvider: any = $injector.get('enableAlertsModal'); + const alertsContext = useContext(AlertsContext); + + const closeModal = () => { + setIsModalVisible(false); + alertsEnableModalProvider.hideModalForSession(); + }; + + const radios = [ + { + id: 'create-alerts', + label: i18n.translate('xpack.monitoring.alerts.modal.yesOption', { + defaultMessage: 'Yes (Recommended - create default rules in this kibana spaces)', + }), + }, + { + id: 'not-create-alerts', + label: i18n.translate('xpack.monitoring.alerts.modal.noOption', { + defaultMessage: 'No', + }), + }, + ]; + + const [radioIdSelected, setRadioIdSelected] = useState('create-alerts'); + + const onChange = (optionId: string) => { + setRadioIdSelected(optionId); + }; + + useEffect(() => { + if (alertsEnableModalProvider.shouldShowAlertsModal(alertsContext)) { + setIsModalVisible(true); + } + }, [alertsEnableModalProvider, alertsContext]); + + const confirmButtonClick = () => { + if (radioIdSelected === 'create-alerts') { + alertsEnableModalProvider.enableAlerts(); + } else { + alertsEnableModalProvider.notAskAgain(); + } + + closeModal(); + }; + + const remindLaterClick = () => { + alertsEnableModalProvider.hideModalForSession(); + closeModal(); + }; + + return isModalVisible ? ( + + + +

+ +

+
+
+ + + +

+ + + + ), + }} + /> +

+
+ + + + + onChange(id)} + name="radio group" + /> +
+
+
+ + + + + + + + + + +
+ ) : null; +}; diff --git a/x-pack/plugins/monitoring/public/angular/app_modules.ts b/x-pack/plugins/monitoring/public/angular/app_modules.ts index 71dc4919237e5f..e7b2f7a5370009 100644 --- a/x-pack/plugins/monitoring/public/angular/app_modules.ts +++ b/x-pack/plugins/monitoring/public/angular/app_modules.ts @@ -42,6 +42,8 @@ import { licenseProvider } from '../services/license'; // @ts-ignore import { titleProvider } from '../services/title'; // @ts-ignore +import { enableAlertsModalProvider } from '../services/enable_alerts_modal'; +// @ts-ignore import { monitoringMlListingProvider } from '../directives/elasticsearch/ml_job_listing'; // @ts-ignore import { monitoringMainProvider } from '../directives/main'; @@ -142,6 +144,9 @@ function createMonitoringAppServices() { .service('features', function (Private: IPrivate) { return Private(featuresProvider); }) + .service('enableAlertsModal', function (Private: IPrivate) { + return Private(enableAlertsModalProvider); + }) .service('license', function (Private: IPrivate) { return Private(licenseProvider); }) diff --git a/x-pack/plugins/monitoring/public/angular/index.ts b/x-pack/plugins/monitoring/public/angular/index.ts index 0c605abb828bd3..de52b714a7241c 100644 --- a/x-pack/plugins/monitoring/public/angular/index.ts +++ b/x-pack/plugins/monitoring/public/angular/index.ts @@ -29,6 +29,7 @@ export class AngularApp { triggersActionsUi, usageCollection, kibanaLegacy, + appMountParameters, } = deps; const app: IModule = localAppModule(deps); app.run(($injector: angular.auto.IInjectorService) => { @@ -45,6 +46,7 @@ export class AngularApp { kibanaLegacy, triggersActionsUi, usageCollection, + appMountParameters, }, this.injector ); diff --git a/x-pack/plugins/monitoring/public/legacy_shims.ts b/x-pack/plugins/monitoring/public/legacy_shims.ts index 7da0f8590a8962..a723eea8b6d653 100644 --- a/x-pack/plugins/monitoring/public/legacy_shims.ts +++ b/x-pack/plugins/monitoring/public/legacy_shims.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { CoreStart, HttpSetup, IUiSettingsClient } from 'kibana/public'; +import { CoreStart, HttpSetup, IUiSettingsClient, AppMountParameters } from 'kibana/public'; import { Observable } from 'rxjs'; import { HttpRequestInit } from '../../../../src/core/public'; import { MonitoringStartPluginDependencies } from './types'; @@ -63,13 +63,21 @@ export interface IShims { triggersActionsUi: TriggersAndActionsUIPublicPluginStart; usageCollection: UsageCollectionSetup; kibanaServices: CoreStart & { usageCollection: UsageCollectionSetup }; + appMountParameters: AppMountParameters; } export class Legacy { private static _shims: IShims; public static init( - { core, data, isCloud, triggersActionsUi, usageCollection }: MonitoringStartPluginDependencies, + { + core, + data, + isCloud, + triggersActionsUi, + usageCollection, + appMountParameters, + }: MonitoringStartPluginDependencies, ngInjector: angular.auto.IInjectorService ) { this._shims = { @@ -129,6 +137,7 @@ export class Legacy { ...core, usageCollection, }, + appMountParameters, }; } diff --git a/x-pack/plugins/monitoring/public/plugin.ts b/x-pack/plugins/monitoring/public/plugin.ts index a597754d6c4099..a5b7d4906b5869 100644 --- a/x-pack/plugins/monitoring/public/plugin.ts +++ b/x-pack/plugins/monitoring/public/plugin.ts @@ -105,6 +105,7 @@ export class MonitoringPlugin externalConfig: this.getExternalConfig(), triggersActionsUi: pluginsStart.triggersActionsUi, usageCollection: plugins.usageCollection, + appMountParameters: params, }; const monitoringApp = new AngularApp(deps); diff --git a/x-pack/plugins/monitoring/public/services/clusters.js b/x-pack/plugins/monitoring/public/services/clusters.js index 71ae128072b7fa..937a69cbbc32d5 100644 --- a/x-pack/plugins/monitoring/public/services/clusters.js +++ b/x-pack/plugins/monitoring/public/services/clusters.js @@ -9,7 +9,6 @@ import { ajaxErrorHandlersProvider } from '../lib/ajax_error_handler'; import { Legacy } from '../legacy_shims'; import { STANDALONE_CLUSTER_CLUSTER_UUID } from '../../common/constants'; import { showInternalMonitoringToast } from '../lib/internal_monitoring_toasts'; -import { showAlertsToast } from '../alerts/lib/alerts_toast'; function formatClusters(clusters) { return clusters.map(formatCluster); @@ -58,16 +57,6 @@ export function monitoringClustersProvider($injector) { } } - async function ensureAlertsEnabled() { - try { - return $http.post('../api/monitoring/v1/alerts/enable', {}); - } catch (err) { - const Private = $injector.get('Private'); - const ajaxErrorHandlers = Private(ajaxErrorHandlersProvider); - return ajaxErrorHandlers(err); - } - } - async function ensureMetricbeatEnabled() { if (Legacy.shims.isCloud) { return; @@ -97,8 +86,7 @@ export function monitoringClustersProvider($injector) { const clusters = await getClusters(); if (clusters.length) { try { - const [{ data }] = await Promise.all([ensureAlertsEnabled(), ensureMetricbeatEnabled()]); - showAlertsToast(data); + await ensureMetricbeatEnabled(); } catch (_err) { // Intentionally swallow the error as this will retry the next page load } diff --git a/x-pack/plugins/monitoring/public/services/enable_alerts_modal.js b/x-pack/plugins/monitoring/public/services/enable_alerts_modal.js new file mode 100644 index 00000000000000..0232e302517afa --- /dev/null +++ b/x-pack/plugins/monitoring/public/services/enable_alerts_modal.js @@ -0,0 +1,53 @@ +/* + * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one + * or more contributor license agreements. Licensed under the Elastic License + * 2.0; you may not use this file except in compliance with the Elastic License + * 2.0. + */ +import { ajaxErrorHandlersProvider } from '../lib/ajax_error_handler'; +import { showAlertsToast } from '../alerts/lib/alerts_toast'; + +export function enableAlertsModalProvider($http, $window, $injector) { + function shouldShowAlertsModal(alerts) { + const modalHasBeenShown = $window.sessionStorage.getItem('ALERTS_MODAL_HAS_BEEN_SHOWN'); + const decisionMade = $window.localStorage.getItem('ALERTS_MODAL_DECISION_MADE'); + + if (Object.keys(alerts.allAlerts).length > 0) { + $window.localStorage.setItem('ALERTS_MODAL_DECISION_MADE', true); + return false; + } + + if (!modalHasBeenShown && !decisionMade) { + return true; + } + + return false; + } + + async function enableAlerts() { + try { + const { data } = await $http.post('../api/monitoring/v1/alerts/enable', {}); + $window.localStorage.setItem('ALERTS_MODAL_DECISION_MADE', true); + showAlertsToast(data); + } catch (err) { + const Private = $injector.get('Private'); + const ajaxErrorHandlers = Private(ajaxErrorHandlersProvider); + return ajaxErrorHandlers(err); + } + } + + function notAskAgain() { + $window.localStorage.setItem('ALERTS_MODAL_DECISION_MADE', true); + } + + function hideModalForSession() { + $window.sessionStorage.setItem('ALERTS_MODAL_HAS_BEEN_SHOWN', true); + } + + return { + shouldShowAlertsModal, + enableAlerts, + notAskAgain, + hideModalForSession, + }; +} diff --git a/x-pack/plugins/monitoring/public/types.ts b/x-pack/plugins/monitoring/public/types.ts index f722a08be3866b..da65a3a3d64f16 100644 --- a/x-pack/plugins/monitoring/public/types.ts +++ b/x-pack/plugins/monitoring/public/types.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { PluginInitializerContext, CoreStart } from 'kibana/public'; +import { PluginInitializerContext, CoreStart, AppMountParameters } from 'kibana/public'; import { NavigationPublicPluginStart as NavigationStart } from '../../../../src/plugins/navigation/public'; import { DataPublicPluginStart } from '../../../../src/plugins/data/public'; import { TriggersAndActionsUIPublicPluginStart } from '../../triggers_actions_ui/public'; @@ -26,4 +26,5 @@ export interface MonitoringStartPluginDependencies { externalConfig: Array | Array>; triggersActionsUi: TriggersAndActionsUIPublicPluginStart; usageCollection: UsageCollectionSetup; + appMountParameters: AppMountParameters; } diff --git a/x-pack/plugins/monitoring/public/views/base_controller.js b/x-pack/plugins/monitoring/public/views/base_controller.js index ce541a1806e55e..dd9898a6e195c2 100644 --- a/x-pack/plugins/monitoring/public/views/base_controller.js +++ b/x-pack/plugins/monitoring/public/views/base_controller.js @@ -16,6 +16,8 @@ import { SetupModeFeature } from '../../common/enums'; import { updateSetupModeData, isSetupModeFeatureEnabled } from '../lib/setup_mode'; import { AlertsContext } from '../alerts/context'; import { KibanaContextProvider } from '../../../../../src/plugins/kibana_react/public'; +import { AlertsDropdown } from '../alerts/alerts_dropdown'; +import { HeaderMenuPortal } from '../../../observability/public'; /** * Given a timezone, this function will calculate the offset in milliseconds @@ -246,6 +248,11 @@ export class MonitoringViewBaseController { + + + {!this._isDataInitialized ? ( ) : ( diff --git a/x-pack/plugins/monitoring/public/views/cluster/overview/index.js b/x-pack/plugins/monitoring/public/views/cluster/overview/index.js index 9fc9dd1c6f685b..bf34650bdb700d 100644 --- a/x-pack/plugins/monitoring/public/views/cluster/overview/index.js +++ b/x-pack/plugins/monitoring/public/views/cluster/overview/index.js @@ -16,6 +16,7 @@ import { Overview } from '../../../components/cluster/overview'; import { SetupModeRenderer } from '../../../components/renderers'; import { SetupModeContext } from '../../../components/setup_mode/setup_mode_context'; import { CODE_PATH_ALL } from '../../../../common/constants'; +import { EnableAlertsModal } from '../../../alerts/enable_alerts_modal.tsx'; const CODE_PATHS = [CODE_PATH_ALL]; @@ -82,6 +83,7 @@ uiRoutes.when('/overview', { setupMode={setupMode} showLicenseExpiration={showLicenseExpiration} /> + {bottomBarComponent} )} diff --git a/x-pack/test/functional/apps/monitoring/beats/beat_detail.js b/x-pack/test/functional/apps/monitoring/beats/beat_detail.js index f3d89ebdeddbdf..35a74a0877aa5c 100644 --- a/x-pack/test/functional/apps/monitoring/beats/beat_detail.js +++ b/x-pack/test/functional/apps/monitoring/beats/beat_detail.js @@ -22,6 +22,8 @@ export default function ({ getService, getPageObjects }) { to: 'Dec 19, 2017 @ 18:15:09.000', }); + await clusterOverview.closeAlertsModal(); + // go to beats detail await clusterOverview.clickBeatsListing(); expect(await listing.isOnListing()).to.be(true); diff --git a/x-pack/test/functional/apps/monitoring/beats/cluster.js b/x-pack/test/functional/apps/monitoring/beats/cluster.js index 7f8f1b181b724c..9d291814ae19c9 100644 --- a/x-pack/test/functional/apps/monitoring/beats/cluster.js +++ b/x-pack/test/functional/apps/monitoring/beats/cluster.js @@ -19,6 +19,8 @@ export default function ({ getService, getPageObjects }) { from: 'Dec 19, 2017 @ 17:14:09.000', to: 'Dec 19, 2017 @ 18:15:09.000', }); + + await overview.closeAlertsModal(); }); after(async () => { diff --git a/x-pack/test/functional/apps/monitoring/beats/listing.js b/x-pack/test/functional/apps/monitoring/beats/listing.js index 4030f80f5b8b9f..67dc9181bda395 100644 --- a/x-pack/test/functional/apps/monitoring/beats/listing.js +++ b/x-pack/test/functional/apps/monitoring/beats/listing.js @@ -22,6 +22,8 @@ export default function ({ getService, getPageObjects }) { to: 'Dec 19, 2017 @ 18:15:09.000', }); + await clusterOverview.closeAlertsModal(); + // go to beats listing await clusterOverview.clickBeatsListing(); expect(await listing.isOnListing()).to.be(true); diff --git a/x-pack/test/functional/apps/monitoring/beats/overview.js b/x-pack/test/functional/apps/monitoring/beats/overview.js index cf544f5e659fde..7d2eaa0689b23b 100644 --- a/x-pack/test/functional/apps/monitoring/beats/overview.js +++ b/x-pack/test/functional/apps/monitoring/beats/overview.js @@ -22,6 +22,8 @@ export default function ({ getService, getPageObjects }) { to: 'Dec 19, 2017 @ 18:15:09.000', }); + await clusterOverview.closeAlertsModal(); + // go to beats overview await clusterOverview.clickBeatsOverview(); expect(await overview.isOnOverview()).to.be(true); diff --git a/x-pack/test/functional/apps/monitoring/cluster/list.js b/x-pack/test/functional/apps/monitoring/cluster/list.js index 98ea3959d6b29e..f88e30f717141e 100644 --- a/x-pack/test/functional/apps/monitoring/cluster/list.js +++ b/x-pack/test/functional/apps/monitoring/cluster/list.js @@ -140,6 +140,7 @@ export default function ({ getService, getPageObjects }) { expect(await clusterOverview.isOnClusterOverview()).to.be(true); expect(await clusterOverview.getClusterName()).to.be('production'); + await PageObjects.monitoring.closeAlertsModal(); await PageObjects.monitoring.clickBreadcrumb('~breadcrumbClusters'); // reset for next test }); diff --git a/x-pack/test/functional/apps/monitoring/cluster/overview.js b/x-pack/test/functional/apps/monitoring/cluster/overview.js index 389c3313d29546..902c82f0881527 100644 --- a/x-pack/test/functional/apps/monitoring/cluster/overview.js +++ b/x-pack/test/functional/apps/monitoring/cluster/overview.js @@ -20,6 +20,8 @@ export default function ({ getService, getPageObjects }) { from: 'Aug 23, 2017 @ 21:29:35.267', to: 'Aug 23, 2017 @ 21:47:25.556', }); + + await overview.closeAlertsModal(); }); after(async () => { @@ -71,6 +73,8 @@ export default function ({ getService, getPageObjects }) { from: 'Aug 29, 2017 @ 17:23:47.528', to: 'Aug 29, 2017 @ 17:25:50.701', }); + + await overview.closeAlertsModal(); }); after(async () => { @@ -117,6 +121,8 @@ export default function ({ getService, getPageObjects }) { from: 'Aug 29, 2017 @ 17:55:43.879', to: 'Aug 29, 2017 @ 18:01:34.958', }); + + await overview.closeAlertsModal(); }); after(async () => { diff --git a/x-pack/test/functional/apps/monitoring/elasticsearch/index_detail.js b/x-pack/test/functional/apps/monitoring/elasticsearch/index_detail.js index 5ea7904e039a1d..663b05442ba249 100644 --- a/x-pack/test/functional/apps/monitoring/elasticsearch/index_detail.js +++ b/x-pack/test/functional/apps/monitoring/elasticsearch/index_detail.js @@ -32,6 +32,8 @@ export default function ({ getService, getPageObjects }) { } ); + await overview.closeAlertsModal(); + // go to indices listing await overview.clickEsIndices(); expect(await indicesList.isOnListing()).to.be(true); diff --git a/x-pack/test/functional/apps/monitoring/elasticsearch/index_detail_mb.js b/x-pack/test/functional/apps/monitoring/elasticsearch/index_detail_mb.js index 9d6938fb09c53a..61a84cd60fbe0e 100644 --- a/x-pack/test/functional/apps/monitoring/elasticsearch/index_detail_mb.js +++ b/x-pack/test/functional/apps/monitoring/elasticsearch/index_detail_mb.js @@ -32,6 +32,8 @@ export default function ({ getService, getPageObjects }) { } ); + await overview.closeAlertsModal(); + // go to indices listing await overview.clickEsIndices(); expect(await indicesList.isOnListing()).to.be(true); diff --git a/x-pack/test/functional/apps/monitoring/elasticsearch/indices.js b/x-pack/test/functional/apps/monitoring/elasticsearch/indices.js index 44ded151f0713f..ae35f53350ec96 100644 --- a/x-pack/test/functional/apps/monitoring/elasticsearch/indices.js +++ b/x-pack/test/functional/apps/monitoring/elasticsearch/indices.js @@ -22,6 +22,8 @@ export default function ({ getService, getPageObjects }) { to: 'Oct 6, 2017 @ 20:15:30.212', }); + await overview.closeAlertsModal(); + // go to indices listing await overview.clickEsIndices(); expect(await indicesList.isOnListing()).to.be(true); diff --git a/x-pack/test/functional/apps/monitoring/elasticsearch/indices_mb.js b/x-pack/test/functional/apps/monitoring/elasticsearch/indices_mb.js index 551afbc71b7258..b0c53839fab367 100644 --- a/x-pack/test/functional/apps/monitoring/elasticsearch/indices_mb.js +++ b/x-pack/test/functional/apps/monitoring/elasticsearch/indices_mb.js @@ -22,6 +22,8 @@ export default function ({ getService, getPageObjects }) { to: 'Oct 6, 2017 @ 20:15:30.212', }); + await overview.closeAlertsModal(); + // go to indices listing await overview.clickEsIndices(); expect(await indicesList.isOnListing()).to.be(true); diff --git a/x-pack/test/functional/apps/monitoring/elasticsearch/node_detail.js b/x-pack/test/functional/apps/monitoring/elasticsearch/node_detail.js index 79fb399db8a4ea..6b1658dd9ed0ed 100644 --- a/x-pack/test/functional/apps/monitoring/elasticsearch/node_detail.js +++ b/x-pack/test/functional/apps/monitoring/elasticsearch/node_detail.js @@ -27,6 +27,8 @@ export default function ({ getService, getPageObjects }) { } ); + await overview.closeAlertsModal(); + // go to nodes listing await overview.clickEsNodes(); expect(await nodesList.isOnListing()).to.be(true); @@ -82,6 +84,8 @@ export default function ({ getService, getPageObjects }) { to: 'Oct 6, 2017 @ 20:15:30.212', }); + await overview.closeAlertsModal(); + // go to nodes listing await overview.clickEsNodes(); expect(await nodesList.isOnListing()).to.be(true); @@ -121,6 +125,8 @@ export default function ({ getService, getPageObjects }) { } ); + await overview.closeAlertsModal(); + // go to nodes listing await overview.clickEsNodes(); expect(await nodesList.isOnListing()).to.be(true); diff --git a/x-pack/test/functional/apps/monitoring/elasticsearch/node_detail_mb.js b/x-pack/test/functional/apps/monitoring/elasticsearch/node_detail_mb.js index 342668533e963f..9130ce91e7b4db 100644 --- a/x-pack/test/functional/apps/monitoring/elasticsearch/node_detail_mb.js +++ b/x-pack/test/functional/apps/monitoring/elasticsearch/node_detail_mb.js @@ -27,6 +27,8 @@ export default function ({ getService, getPageObjects }) { } ); + await overview.closeAlertsModal(); + // go to nodes listing await overview.clickEsNodes(); expect(await nodesList.isOnListing()).to.be(true); @@ -82,6 +84,8 @@ export default function ({ getService, getPageObjects }) { to: 'Oct 6, 2017 @ 20:15:30.212', }); + await overview.closeAlertsModal(); + // go to nodes listing await overview.clickEsNodes(); expect(await nodesList.isOnListing()).to.be(true); @@ -121,6 +125,8 @@ export default function ({ getService, getPageObjects }) { } ); + await overview.closeAlertsModal(); + // go to nodes listing await overview.clickEsNodes(); expect(await nodesList.isOnListing()).to.be(true); diff --git a/x-pack/test/functional/apps/monitoring/elasticsearch/nodes.js b/x-pack/test/functional/apps/monitoring/elasticsearch/nodes.js index 9c03faf72eff1f..d7c4e5dd12f524 100644 --- a/x-pack/test/functional/apps/monitoring/elasticsearch/nodes.js +++ b/x-pack/test/functional/apps/monitoring/elasticsearch/nodes.js @@ -29,6 +29,8 @@ export default function ({ getService, getPageObjects }) { } ); + await overview.closeAlertsModal(); + // go to nodes listing await overview.clickEsNodes(); expect(await nodesList.isOnListing()).to.be(true); diff --git a/x-pack/test/functional/apps/monitoring/elasticsearch/nodes_mb.js b/x-pack/test/functional/apps/monitoring/elasticsearch/nodes_mb.js index 78462e0d5ec3de..7e9a0fec708241 100644 --- a/x-pack/test/functional/apps/monitoring/elasticsearch/nodes_mb.js +++ b/x-pack/test/functional/apps/monitoring/elasticsearch/nodes_mb.js @@ -29,6 +29,8 @@ export default function ({ getService, getPageObjects }) { } ); + await overview.closeAlertsModal(); + // go to nodes listing await overview.clickEsNodes(); expect(await nodesList.isOnListing()).to.be(true); @@ -261,6 +263,8 @@ export default function ({ getService, getPageObjects }) { } ); + overview.closeAlertsModal(); + // go to nodes listing await overview.clickEsNodes(); expect(await nodesList.isOnListing()).to.be(true); diff --git a/x-pack/test/functional/apps/monitoring/elasticsearch/overview.js b/x-pack/test/functional/apps/monitoring/elasticsearch/overview.js index 61c8c6b266b0d4..c539ca0b2623b6 100644 --- a/x-pack/test/functional/apps/monitoring/elasticsearch/overview.js +++ b/x-pack/test/functional/apps/monitoring/elasticsearch/overview.js @@ -25,6 +25,8 @@ export default function ({ getService, getPageObjects }) { } ); + await clusterOverview.closeAlertsModal(); + // go to overview await clusterOverview.clickEsOverview(); expect(await overview.isOnOverview()).to.be(true); diff --git a/x-pack/test/functional/apps/monitoring/elasticsearch/overview_mb.js b/x-pack/test/functional/apps/monitoring/elasticsearch/overview_mb.js index 7c279119e65d7c..d93a2c3e77b935 100644 --- a/x-pack/test/functional/apps/monitoring/elasticsearch/overview_mb.js +++ b/x-pack/test/functional/apps/monitoring/elasticsearch/overview_mb.js @@ -25,6 +25,8 @@ export default function ({ getService, getPageObjects }) { } ); + await clusterOverview.closeAlertsModal(); + // go to overview await clusterOverview.clickEsOverview(); expect(await overview.isOnOverview()).to.be(true); diff --git a/x-pack/test/functional/apps/monitoring/enable_monitoring/index.js b/x-pack/test/functional/apps/monitoring/enable_monitoring/index.js index dca81fd6fc07e5..79bd479c45a177 100644 --- a/x-pack/test/functional/apps/monitoring/enable_monitoring/index.js +++ b/x-pack/test/functional/apps/monitoring/enable_monitoring/index.js @@ -55,6 +55,7 @@ export default function ({ getService, getPageObjects }) { await retry.tryForTime(20000, async () => { // Click the refresh button await testSubjects.click('querySubmitButton'); + await clusterOverview.closeAlertsModal(); expect(await clusterOverview.isOnClusterOverview()).to.be(true); }); }); diff --git a/x-pack/test/functional/apps/monitoring/kibana/instance.js b/x-pack/test/functional/apps/monitoring/kibana/instance.js index 97f73795e44e06..112642bff9b109 100644 --- a/x-pack/test/functional/apps/monitoring/kibana/instance.js +++ b/x-pack/test/functional/apps/monitoring/kibana/instance.js @@ -22,6 +22,8 @@ export default function ({ getService, getPageObjects }) { to: 'Aug 29, 2017 @ 17:25:44.142', }); + await clusterOverview.closeAlertsModal(); + // go to kibana instance await clusterOverview.clickKibanaInstances(); expect(await instances.isOnInstances()).to.be(true); diff --git a/x-pack/test/functional/apps/monitoring/kibana/instance_mb.js b/x-pack/test/functional/apps/monitoring/kibana/instance_mb.js index a615ed0cf9d59a..0d993add1020ad 100644 --- a/x-pack/test/functional/apps/monitoring/kibana/instance_mb.js +++ b/x-pack/test/functional/apps/monitoring/kibana/instance_mb.js @@ -25,6 +25,8 @@ export default function ({ getService, getPageObjects }) { } ); + await clusterOverview.closeAlertsModal(); + // go to kibana instance await clusterOverview.clickKibanaInstances(); expect(await instances.isOnInstances()).to.be(true); diff --git a/x-pack/test/functional/apps/monitoring/kibana/instances.js b/x-pack/test/functional/apps/monitoring/kibana/instances.js index 554c3c3ece0e1e..f2c403578f52a4 100644 --- a/x-pack/test/functional/apps/monitoring/kibana/instances.js +++ b/x-pack/test/functional/apps/monitoring/kibana/instances.js @@ -22,6 +22,8 @@ export default function ({ getService, getPageObjects }) { to: 'Aug 29, 2017 @ 17:25:44.142', }); + await clusterOverview.closeAlertsModal(); + // go to kibana instances await clusterOverview.clickKibanaInstances(); expect(await instances.isOnInstances()).to.be(true); diff --git a/x-pack/test/functional/apps/monitoring/kibana/instances_mb.js b/x-pack/test/functional/apps/monitoring/kibana/instances_mb.js index 695ef81bf71fb2..c05366c294e87f 100644 --- a/x-pack/test/functional/apps/monitoring/kibana/instances_mb.js +++ b/x-pack/test/functional/apps/monitoring/kibana/instances_mb.js @@ -26,6 +26,8 @@ export default function ({ getService, getPageObjects }) { } ); + await clusterOverview.closeAlertsModal(); + // go to kibana instances await clusterOverview.clickKibanaInstances(); expect(await instances.isOnInstances()).to.be(true); diff --git a/x-pack/test/functional/apps/monitoring/kibana/overview.js b/x-pack/test/functional/apps/monitoring/kibana/overview.js index 060c368563a950..a366033e1baf6a 100644 --- a/x-pack/test/functional/apps/monitoring/kibana/overview.js +++ b/x-pack/test/functional/apps/monitoring/kibana/overview.js @@ -22,6 +22,8 @@ export default function ({ getService, getPageObjects }) { to: 'Aug 29, 2017 @ 17:25:44.142', }); + await clusterOverview.closeAlertsModal(); + // go to kibana overview await clusterOverview.clickKibanaOverview(); expect(await overview.isOnOverview()).to.be(true); diff --git a/x-pack/test/functional/apps/monitoring/kibana/overview_mb.js b/x-pack/test/functional/apps/monitoring/kibana/overview_mb.js index 5f8b926e5d17c8..519903c201474c 100644 --- a/x-pack/test/functional/apps/monitoring/kibana/overview_mb.js +++ b/x-pack/test/functional/apps/monitoring/kibana/overview_mb.js @@ -25,6 +25,8 @@ export default function ({ getService, getPageObjects }) { } ); + await clusterOverview.closeAlertsModal(); + // go to kibana overview await clusterOverview.clickKibanaOverview(); expect(await overview.isOnOverview()).to.be(true); diff --git a/x-pack/test/functional/apps/monitoring/logstash/pipelines.js b/x-pack/test/functional/apps/monitoring/logstash/pipelines.js index 2f698f83912c11..72a6ff8e1af23f 100644 --- a/x-pack/test/functional/apps/monitoring/logstash/pipelines.js +++ b/x-pack/test/functional/apps/monitoring/logstash/pipelines.js @@ -24,6 +24,8 @@ export default function ({ getService, getPageObjects }) { to: 'Jan 22, 2018 @ 09:41:00.000', }); + await overview.closeAlertsModal(); + // go to pipelines listing await overview.clickLsPipelines(); expect(await pipelinesList.isOnListing()).to.be(true); diff --git a/x-pack/test/functional/apps/monitoring/logstash/pipelines_mb.js b/x-pack/test/functional/apps/monitoring/logstash/pipelines_mb.js index 508f919d97efde..89afac834414b4 100644 --- a/x-pack/test/functional/apps/monitoring/logstash/pipelines_mb.js +++ b/x-pack/test/functional/apps/monitoring/logstash/pipelines_mb.js @@ -24,6 +24,8 @@ export default function ({ getService, getPageObjects }) { to: 'Jan 22, 2018 @ 09:41:00.000', }); + await overview.closeAlertsModal(); + // go to pipelines listing await overview.clickLsPipelines(); expect(await pipelinesList.isOnListing()).to.be(true); diff --git a/x-pack/test/functional/page_objects/monitoring_page.ts b/x-pack/test/functional/page_objects/monitoring_page.ts index 151b6733509e6a..acd9a443eb7ce3 100644 --- a/x-pack/test/functional/page_objects/monitoring_page.ts +++ b/x-pack/test/functional/page_objects/monitoring_page.ts @@ -16,6 +16,10 @@ export class MonitoringPageObject extends FtrService { return this.testSubjects.getVisibleText('accessDeniedTitle'); } + async closeAlertsModal() { + return this.testSubjects.click('alerts-modal-button'); + } + async clickBreadcrumb(subj: string) { return this.testSubjects.click(subj); } diff --git a/x-pack/test/functional/services/monitoring/cluster_overview.js b/x-pack/test/functional/services/monitoring/cluster_overview.js index 3da0c82c87a63a..5128cbffd34cff 100644 --- a/x-pack/test/functional/services/monitoring/cluster_overview.js +++ b/x-pack/test/functional/services/monitoring/cluster_overview.js @@ -75,6 +75,10 @@ export function MonitoringClusterOverviewProvider({ getService }) { return testSubjects.exists(SUBJ_CLUSTER_ALERTS); } + closeAlertsModal() { + return testSubjects.click('alerts-modal-button'); + } + getEsStatus() { return testSubjects.getVisibleText(SUBJ_ES_STATUS); }