diff --git a/x-pack/plugins/infra/public/pages/metrics/hosts/components/tabs/alerts/alerts_tab_content.tsx b/x-pack/plugins/infra/public/pages/metrics/hosts/components/tabs/alerts/alerts_tab_content.tsx index cb31f2c5e9102..7933d3bdb9f3c 100644 --- a/x-pack/plugins/infra/public/pages/metrics/hosts/components/tabs/alerts/alerts_tab_content.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/hosts/components/tabs/alerts/alerts_tab_content.tsx @@ -49,7 +49,7 @@ export const AlertsTabContent = () => { return ( - + diff --git a/x-pack/plugins/infra/public/pages/metrics/hosts/components/tabs/alerts_tab_badge.tsx b/x-pack/plugins/infra/public/pages/metrics/hosts/components/tabs/alerts_tab_badge.tsx index 534d28e671fe3..1333c5b5c3439 100644 --- a/x-pack/plugins/infra/public/pages/metrics/hosts/components/tabs/alerts_tab_badge.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/hosts/components/tabs/alerts_tab_badge.tsx @@ -40,7 +40,11 @@ export const AlertsTabBadge = () => { typeof alertsCount?.activeAlertCount === 'number' && alertsCount.activeAlertCount > 0; return shouldRenderBadge ? ( - + {alertsCount?.activeAlertCount} ) : null; diff --git a/x-pack/test/functional/apps/infra/constants.ts b/x-pack/test/functional/apps/infra/constants.ts index 248c4f49a16c7..b1739f9a489d7 100644 --- a/x-pack/test/functional/apps/infra/constants.ts +++ b/x-pack/test/functional/apps/infra/constants.ts @@ -42,3 +42,5 @@ export const ML_JOB_IDS = [ ]; export const HOSTS_LINK_LOCAL_STORAGE_KEY = 'inventoryUI:hostsLinkClicked'; + +export const HOSTS_VIEW_PATH = 'metrics/hosts'; diff --git a/x-pack/test/functional/apps/infra/hosts_view.ts b/x-pack/test/functional/apps/infra/hosts_view.ts index 4f3166c80afb9..1f1773505ffef 100644 --- a/x-pack/test/functional/apps/infra/hosts_view.ts +++ b/x-pack/test/functional/apps/infra/hosts_view.ts @@ -6,9 +6,11 @@ */ import expect from '@kbn/expect'; +import { enableInfrastructureHostsView } from '@kbn/observability-plugin/common'; +import { ALERT_STATUS_ACTIVE, ALERT_STATUS_RECOVERED } from '@kbn/rule-data-utils'; import moment from 'moment'; import { FtrProviderContext } from '../../ftr_provider_context'; -import { DATES, HOSTS_LINK_LOCAL_STORAGE_KEY } from './constants'; +import { DATES, HOSTS_LINK_LOCAL_STORAGE_KEY, HOSTS_VIEW_PATH } from './constants'; const START_DATE = moment.utc(DATES.metricsAndLogs.hosts.min); const END_DATE = moment.utc(DATES.metricsAndLogs.hosts.max); @@ -18,6 +20,7 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { const kibanaServer = getService('kibanaServer'); const esArchiver = getService('esArchiver'); const browser = getService('browser'); + const find = getService('find'); const security = getService('security'); const pageObjects = getPageObjects([ 'common', @@ -29,9 +32,11 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { ]); // Helpers + const setHostViewEnabled = (value: boolean = true) => + kibanaServer.uiSettings.update({ [enableInfrastructureHostsView]: value }); - const loginWithReadOnlyUserAndNavigateToInfra = async () => { - await security.role.create('global_hosts_read_privileges_role', { + const loginWithReadOnlyUser = async () => { + const roleCreation = security.role.create('global_hosts_read_privileges_role', { elasticsearch: { indices: [{ names: ['metricbeat-*'], privileges: ['read', 'view_index_metadata'] }], }, @@ -46,13 +51,15 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { ], }); - await security.user.create('global_hosts_read_privileges_user', { + const userCreation = security.user.create('global_hosts_read_privileges_user', { password: 'global_hosts_read_privileges_user-password', roles: ['global_hosts_read_privileges_role'], full_name: 'test user', }); - await pageObjects.security.forceLogout(); + const logout = pageObjects.security.forceLogout(); + + await Promise.all([roleCreation, userCreation, logout]); await pageObjects.security.login( 'global_hosts_read_privileges_user', @@ -61,87 +68,55 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { expectSpaceSelector: false, } ); - - await browser.removeLocalStorageItem(HOSTS_LINK_LOCAL_STORAGE_KEY); - await pageObjects.common.navigateToApp('infraOps'); }; - const logoutAndDeleteReadOnlyUser = async () => { - await pageObjects.security.forceLogout(); - await Promise.all([ + const logoutAndDeleteReadOnlyUser = () => + Promise.all([ + pageObjects.security.forceLogout(), security.role.delete('global_hosts_read_privileges_role'), security.user.delete('global_hosts_read_privileges_user'), ]); - }; - const navigateAndDisableHostView = async () => { - await esArchiver.load('x-pack/test/functional/es_archives/infra/metrics_and_logs'); - await browser.removeLocalStorageItem(HOSTS_LINK_LOCAL_STORAGE_KEY); - await pageObjects.common.navigateToApp('infraOps'); - await pageObjects.common.navigateToUrl('management', 'kibana/settings', { - basePath: `/s/default`, - ensureCurrentUrl: false, - shouldLoginIfPrompted: false, - shouldUseHashForSubUrl: false, - }); - await pageObjects.settings.toggleAdvancedSettingCheckbox( - 'observability:enableInfrastructureHostsView', - false - ); - return esArchiver.unload('x-pack/test/functional/es_archives/infra/metrics_and_logs'); - }; - - const navigateAndEnableHostView = async () => { - await esArchiver.load('x-pack/test/functional/es_archives/infra/metrics_and_logs'); - await browser.removeLocalStorageItem(HOSTS_LINK_LOCAL_STORAGE_KEY); - await pageObjects.common.navigateToApp('infraOps'); - await pageObjects.infraHome.clickDismissKubernetesTourButton(); - await pageObjects.infraHostsView.clickTryHostViewLink(); - await pageObjects.infraHostsView.clickEnableHostViewButton(); - }; + const enableHostView = () => pageObjects.infraHostsView.clickEnableHostViewButton(); // Tests - describe('Hosts view', function () { + describe('Hosts View', function () { this.tags('includeFirefox'); + before(async () => { - await kibanaServer.savedObjects.cleanStandardList(); + await Promise.all([ + esArchiver.load('x-pack/test/functional/es_archives/infra/alerts'), + esArchiver.load('x-pack/test/functional/es_archives/infra/metrics_and_logs'), + kibanaServer.savedObjects.cleanStandardList(), + ]); }); - describe('shows hosts view landing page for admin', () => { - before(async () => { - await esArchiver.load('x-pack/test/functional/es_archives/infra/metrics_and_logs'); - await pageObjects.common.navigateToApp('infraOps'); - await pageObjects.infraHome.clickDismissKubernetesTourButton(); - await pageObjects.infraHostsView.clickTryHostViewBadge(); - }); - after(async () => { - await browser.removeLocalStorageItem(HOSTS_LINK_LOCAL_STORAGE_KEY); - return esArchiver.unload('x-pack/test/functional/es_archives/infra/metrics_and_logs'); - }); + after(() => { + esArchiver.unload('x-pack/test/functional/es_archives/infra/alerts'); + esArchiver.unload('x-pack/test/functional/es_archives/infra/metrics_and_logs'); + browser.removeLocalStorageItem(HOSTS_LINK_LOCAL_STORAGE_KEY); + }); - it('should show hosts landing page with enable button when the hosts view is disabled', async () => { - const landingPageEnableButton = - await pageObjects.infraHostsView.getHostsLandingPageEnableButton(); - const landingPageEnableButtonText = await landingPageEnableButton.getVisibleText(); - expect(landingPageEnableButtonText).to.eql('Enable hosts view'); - }); + it('should be accessible from the Inventory page', async () => { + await pageObjects.common.navigateToApp('infraOps'); + await pageObjects.infraHome.clickDismissKubernetesTourButton(); + await pageObjects.infraHostsView.clickTryHostViewBadge(); + + const pageUrl = await browser.getCurrentUrl(); + + expect(pageUrl).to.contain(HOSTS_VIEW_PATH); }); - describe('should show hosts view landing page for user with read permission', () => { - before(async () => { - await esArchiver.load('x-pack/test/functional/es_archives/infra/metrics_and_logs'); - await loginWithReadOnlyUserAndNavigateToInfra(); - await pageObjects.infraHome.clickDismissKubernetesTourButton(); - await pageObjects.infraHostsView.clickTryHostViewBadge(); - }); - after(async () => { - // NOTE: Logout needs to happen before anything else to avoid flaky behavior - await logoutAndDeleteReadOnlyUser(); - return esArchiver.unload('x-pack/test/functional/es_archives/infra/metrics_and_logs'); + describe('#Landing page', () => { + beforeEach(() => { + setHostViewEnabled(false); }); - it('should show hosts landing page with callout when the hosts view is disabled', async () => { + it('as a user with read permission, should show hosts landing page with callout when the hosts view is disabled', async () => { + await loginWithReadOnlyUser(); + await pageObjects.common.navigateToApp(HOSTS_VIEW_PATH); + const landingPageDisabled = await pageObjects.infraHostsView.getHostsLandingPageDisabled(); const learnMoreDocsUrl = await pageObjects.infraHostsView.getHostsLandingPageDocsLink(); const parsedUrl = new URL(learnMoreDocsUrl); @@ -151,33 +126,57 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { expect(landingPageDisabled).to.contain( 'Your user role doesn’t have sufficient privileges to enable this feature' ); + + await logoutAndDeleteReadOnlyUser(); + }); + + it('as an admin, should see an enable button when the hosts view is disabled', async () => { + await pageObjects.common.navigateToApp(HOSTS_VIEW_PATH); + + const landingPageEnableButton = + await pageObjects.infraHostsView.getHostsLandingPageEnableButton(); + const landingPageEnableButtonText = await landingPageEnableButton.getVisibleText(); + expect(landingPageEnableButtonText).to.eql('Enable hosts view'); + }); + + it('as an admin, should be able to enable the hosts view feature', async () => { + await pageObjects.common.navigateToApp(HOSTS_VIEW_PATH); + await enableHostView(); + + const titleElement = await find.byCssSelector('h1'); + const title = await titleElement.getVisibleText(); + + expect(title).to.contain('Hosts'); }); }); - describe('enables hosts view page and checks content', () => { + describe('#Page Content', () => { before(async () => { - await navigateAndEnableHostView(); + await setHostViewEnabled(true); + await loginWithReadOnlyUser(); + await pageObjects.common.navigateToApp(HOSTS_VIEW_PATH); await pageObjects.timePicker.setAbsoluteRange( START_DATE.format(timepickerFormat), END_DATE.format(timepickerFormat) ); }); + after(async () => { - await navigateAndDisableHostView(); + await logoutAndDeleteReadOnlyUser(); }); - describe('should show hosts page for admin user and see the page content', async () => { - it('should render the correct page title', async () => { - const documentTitle = await browser.getTitle(); - expect(documentTitle).to.contain('Hosts - Infrastructure - Observability - Elastic'); - }); + it('should render the correct page title', async () => { + const documentTitle = await browser.getTitle(); + expect(documentTitle).to.contain('Hosts - Infrastructure - Observability - Elastic'); + }); - it('should have six hosts', async () => { - const hosts = await pageObjects.infraHostsView.getHostsTableData(); - expect(hosts.length).to.equal(6); - }); + it('should render a table with 6 hosts', async () => { + const hosts = await pageObjects.infraHostsView.getHostsTableData(); + expect(hosts.length).to.equal(6); + }); - it('should load 5 metrics trend tiles', async () => { + describe('KPI tiles', () => { + it('should render 5 metrics trend tiles', async () => { const hosts = await pageObjects.infraHostsView.getAllMetricsTrendTiles(); expect(hosts.length).to.equal(5); }); @@ -195,56 +194,80 @@ export default ({ getPageObjects, getService }: FtrProviderContext) => { }); }); }); - }); - describe('should show hosts page for read only user and see the page content', async () => { - before(async () => { - await navigateAndEnableHostView(); - await loginWithReadOnlyUserAndNavigateToInfra(); - await browser.removeLocalStorageItem(HOSTS_LINK_LOCAL_STORAGE_KEY); - await pageObjects.infraHostsView.clickTryHostViewLink(); - await pageObjects.timePicker.setAbsoluteRange( - START_DATE.format(timepickerFormat), - END_DATE.format(timepickerFormat) - ); - }); - after(async () => { - // NOTE: Logout needs to happen before anything else to avoid flaky behavior - await logoutAndDeleteReadOnlyUser(); - await navigateAndDisableHostView(); - }); + describe('Metrics Tab', () => { + it('should load 8 lens metric charts', async () => { + const metricCharts = await pageObjects.infraHostsView.getAllMetricsCharts(); + expect(metricCharts.length).to.equal(8); + }); - it('should have six hosts', async () => { - const hosts = await pageObjects.infraHostsView.getHostsTableData(); - expect(hosts.length).to.equal(6); + it('should have an option to open the chart in lens', async () => { + await pageObjects.infraHostsView.getOpenInLensOption(); + }); }); - it('should load 5 metrics trend tiles', async () => { - const hosts = await pageObjects.infraHostsView.getAllMetricsTrendTiles(); - expect(hosts.length).to.equal(5); - }); + describe('Alerts Tab', () => { + const observability = getService('observability'); + const testSubjects = getService('testSubjects'); + const retry = getService('retry'); + + const ACTIVE_ALERTS = 6; + const RECOVERED_ALERTS = 4; + const ALL_ALERTS = ACTIVE_ALERTS + RECOVERED_ALERTS; + const COLUMNS = 5; - [ - { metric: 'hosts', value: '6' }, - { metric: 'cpu', value: '0.8%' }, - { metric: 'memory', value: '16.8%' }, - { metric: 'tx', value: '0 bit/s' }, - { metric: 'rx', value: '0 bit/s' }, - ].forEach(({ metric, value }) => { - it(`${metric} tile should show ${value}`, async () => { - const tileValue = await pageObjects.infraHostsView.getMetricsTrendTileValue(metric); - expect(tileValue).to.eql(value); + before(async () => { + await pageObjects.infraHostsView.visitAlertTab(); }); - }); - describe('Lens charts', () => { - it('should load 8 lens metric charts', async () => { - const metricCharts = await pageObjects.infraHostsView.getAllMetricsCharts(); - expect(metricCharts.length).to.equal(8); + it('should correctly load the Alerts tab section when clicking on it', async () => { + testSubjects.existOrFail('hostsView-alerts'); }); - it('should have an option to open the chart in lens', async () => { - await pageObjects.infraHostsView.getOpenInLensOption(); + it('should correctly render a badge with the active alerts count', async () => { + const alertsCountBadge = await pageObjects.infraHostsView.getAlertsTabCountBadge(); + const alertsCount = await alertsCountBadge.getVisibleText(); + + expect(alertsCount).to.be('6'); + }); + + describe('#FilterButtonGroup', () => { + it('can be filtered to only show "active" alerts using the filter button', async () => { + await pageObjects.infraHostsView.setAlertStatusFilter(ALERT_STATUS_ACTIVE); + await retry.try(async () => { + const tableRows = await observability.alerts.common.getTableCellsInRows(); + expect(tableRows.length).to.be(ACTIVE_ALERTS); + }); + }); + + it('can be filtered to only show "recovered" alerts using the filter button', async () => { + await pageObjects.infraHostsView.setAlertStatusFilter(ALERT_STATUS_RECOVERED); + await retry.try(async () => { + const tableRows = await observability.alerts.common.getTableCellsInRows(); + expect(tableRows.length).to.be(RECOVERED_ALERTS); + }); + }); + + it('can be filtered to only show "all" alerts using the filter button', async () => { + await pageObjects.infraHostsView.setAlertStatusFilter(); + await retry.try(async () => { + const tableRows = await observability.alerts.common.getTableCellsInRows(); + expect(tableRows.length).to.be(ALL_ALERTS); + }); + }); + }); + + describe('#AlertsTable', () => { + it('should correctly render', async () => { + await observability.alerts.common.getTableOrFail(); + }); + + it('should renders the correct number of cells', async () => { + await retry.try(async () => { + const cells = await observability.alerts.common.getTableCells(); + expect(cells.length).to.be(ALL_ALERTS * COLUMNS); + }); + }); }); }); }); diff --git a/x-pack/test/functional/es_archives/infra/alerts/data.json.gz b/x-pack/test/functional/es_archives/infra/alerts/data.json.gz new file mode 100644 index 0000000000000..5410bb6abe5b0 Binary files /dev/null and b/x-pack/test/functional/es_archives/infra/alerts/data.json.gz differ diff --git a/x-pack/test/functional/es_archives/infra/alerts/mappings.json b/x-pack/test/functional/es_archives/infra/alerts/mappings.json new file mode 100644 index 0000000000000..89ab07bc009f3 --- /dev/null +++ b/x-pack/test/functional/es_archives/infra/alerts/mappings.json @@ -0,0 +1,776 @@ +{ + "type": "index", + "value": { + "aliases": { + ".alerts-observability.apm.alerts-default": { + "is_write_index": true + } + }, + "index": ".internal.alerts-observability.apm.alerts-default-000001", + "mappings": { + "_meta": { + "kibana": { + "version": "8.0.0" + }, + "namespace": "default" + }, + "dynamic": "false", + "properties": { + "@timestamp": { + "type": "date" + }, + "host": { + "properties": { + "name": { + "type": "keyword" + } + } + }, + "ecs": { + "properties": { + "version": { + "type": "keyword" + } + } + }, + "event": { + "properties": { + "action": { + "type": "keyword" + }, + "kind": { + "type": "keyword" + } + } + }, + "kibana": { + "properties": { + "alert": { + "properties": { + "action_group": { + "type": "keyword" + }, + "duration": { + "properties": { + "us": { + "type": "long" + } + } + }, + "end": { + "type": "date" + }, + "evaluation": { + "properties": { + "threshold": { + "scaling_factor": 100, + "type": "scaled_float" + }, + "value": { + "scaling_factor": 100, + "type": "scaled_float" + } + } + }, + "instance": { + "properties": { + "id": { + "type": "keyword" + } + } + }, + "reason": { + "type": "keyword" + }, + "rule": { + "properties": { + "author": { + "type": "keyword" + }, + "category": { + "type": "keyword" + }, + "consumer": { + "type": "keyword" + }, + "created_at": { + "type": "date" + }, + "created_by": { + "type": "keyword" + }, + "description": { + "type": "keyword" + }, + "enabled": { + "type": "keyword" + }, + "from": { + "type": "keyword" + }, + "interval": { + "type": "keyword" + }, + "license": { + "type": "keyword" + }, + "name": { + "type": "keyword" + }, + "note": { + "type": "keyword" + }, + "params": { + "index": false, + "type": "keyword" + }, + "producer": { + "type": "keyword" + }, + "references": { + "type": "keyword" + }, + "risk_score": { + "type": "float" + }, + "risk_score_mapping": { + "properties": { + "field": { + "type": "keyword" + }, + "operator": { + "type": "keyword" + }, + "value": { + "type": "keyword" + } + } + }, + "rule_id": { + "type": "keyword" + }, + "rule_name_override": { + "type": "keyword" + }, + "rule_type_id": { + "type": "keyword" + }, + "severity": { + "type": "keyword" + }, + "severity_mapping": { + "properties": { + "field": { + "type": "keyword" + }, + "operator": { + "type": "keyword" + }, + "severity": { + "type": "keyword" + }, + "value": { + "type": "keyword" + } + } + }, + "tags": { + "type": "keyword" + }, + "to": { + "type": "keyword" + }, + "type": { + "type": "keyword" + }, + "updated_at": { + "type": "date" + }, + "updated_by": { + "type": "keyword" + }, + "uuid": { + "type": "keyword" + }, + "version": { + "type": "keyword" + } + } + }, + "severity": { + "type": "keyword" + }, + "start": { + "type": "date" + }, + "status": { + "type": "keyword" + }, + "system_status": { + "type": "keyword" + }, + "uuid": { + "type": "keyword" + }, + "workflow_reason": { + "type": "keyword" + }, + "workflow_status": { + "type": "keyword" + }, + "workflow_user": { + "type": "keyword" + } + } + }, + "space_ids": { + "type": "keyword" + }, + "version": { + "type": "version" + } + } + }, + "processor": { + "properties": { + "event": { + "type": "keyword" + } + } + }, + "service": { + "properties": { + "environment": { + "type": "keyword" + }, + "name": { + "type": "keyword" + } + } + }, + "tags": { + "type": "keyword" + }, + "transaction": { + "properties": { + "type": { + "type": "keyword" + } + } + } + } + }, + "settings": { + "index": { + "lifecycle": { + "name": ".alerts-ilm-policy", + "rollover_alias": ".alerts-observability.apm.alerts-default" + }, + "number_of_replicas": "1", + "number_of_shards": "1" + } + } + } +} + +{ + "type": "index", + "value": { + "aliases": { + ".alerts-observability.logs.alerts-default": { + "is_write_index": true + } + }, + "index": ".internal.alerts-observability.logs.alerts-default-000001", + "mappings": { + "_meta": { + "kibana": { + "version": "8.0.0" + }, + "namespace": "default" + }, + "dynamic": "false", + "properties": { + "@timestamp": { + "type": "date" + }, + "host": { + "properties": { + "name": { + "type": "keyword" + } + } + }, + "ecs": { + "properties": { + "version": { + "type": "keyword" + } + } + }, + "event": { + "properties": { + "action": { + "type": "keyword" + }, + "kind": { + "type": "keyword" + } + } + }, + "kibana": { + "properties": { + "alert": { + "properties": { + "action_group": { + "type": "keyword" + }, + "duration": { + "properties": { + "us": { + "type": "long" + } + } + }, + "end": { + "type": "date" + }, + "evaluation": { + "properties": { + "threshold": { + "scaling_factor": 100, + "type": "scaled_float" + }, + "value": { + "scaling_factor": 100, + "type": "scaled_float" + } + } + }, + "instance": { + "properties": { + "id": { + "type": "keyword" + } + } + }, + "reason": { + "type": "keyword" + }, + "rule": { + "properties": { + "author": { + "type": "keyword" + }, + "category": { + "type": "keyword" + }, + "consumer": { + "type": "keyword" + }, + "created_at": { + "type": "date" + }, + "created_by": { + "type": "keyword" + }, + "description": { + "type": "keyword" + }, + "enabled": { + "type": "keyword" + }, + "from": { + "type": "keyword" + }, + "interval": { + "type": "keyword" + }, + "license": { + "type": "keyword" + }, + "name": { + "type": "keyword" + }, + "note": { + "type": "keyword" + }, + "params": { + "index": false, + "type": "keyword" + }, + "producer": { + "type": "keyword" + }, + "references": { + "type": "keyword" + }, + "risk_score": { + "type": "float" + }, + "risk_score_mapping": { + "properties": { + "field": { + "type": "keyword" + }, + "operator": { + "type": "keyword" + }, + "value": { + "type": "keyword" + } + } + }, + "rule_id": { + "type": "keyword" + }, + "rule_name_override": { + "type": "keyword" + }, + "rule_type_id": { + "type": "keyword" + }, + "severity": { + "type": "keyword" + }, + "severity_mapping": { + "properties": { + "field": { + "type": "keyword" + }, + "operator": { + "type": "keyword" + }, + "severity": { + "type": "keyword" + }, + "value": { + "type": "keyword" + } + } + }, + "tags": { + "type": "keyword" + }, + "to": { + "type": "keyword" + }, + "type": { + "type": "keyword" + }, + "updated_at": { + "type": "date" + }, + "updated_by": { + "type": "keyword" + }, + "uuid": { + "type": "keyword" + }, + "version": { + "type": "keyword" + } + } + }, + "severity": { + "type": "keyword" + }, + "start": { + "type": "date" + }, + "status": { + "type": "keyword" + }, + "system_status": { + "type": "keyword" + }, + "uuid": { + "type": "keyword" + }, + "workflow_reason": { + "type": "keyword" + }, + "workflow_status": { + "type": "keyword" + }, + "workflow_user": { + "type": "keyword" + } + } + }, + "space_ids": { + "type": "keyword" + }, + "version": { + "type": "version" + } + } + }, + "tags": { + "type": "keyword" + } + } + }, + "settings": { + "index": { + "lifecycle": { + "name": ".alerts-ilm-policy", + "rollover_alias": ".alerts-observability.logs.alerts-default" + }, + "number_of_replicas": "1", + "number_of_shards": "1" + } + } + } +} + +{ + "type": "index", + "value": { + "aliases": { + ".alerts-observability.metrics.alerts-default": { + "is_write_index": true + } + }, + "index": ".internal.alerts-observability.metrics.alerts-default-000001", + "mappings": { + "_meta": { + "kibana": { + "version": "8.0.0" + }, + "namespace": "default" + }, + "dynamic": "false", + "properties": { + "@timestamp": { + "type": "date" + }, + "host": { + "properties": { + "name": { + "type": "keyword" + } + } + }, + "ecs": { + "properties": { + "version": { + "type": "keyword" + } + } + }, + "event": { + "properties": { + "action": { + "type": "keyword" + }, + "kind": { + "type": "keyword" + } + } + }, + "kibana": { + "properties": { + "alert": { + "properties": { + "action_group": { + "type": "keyword" + }, + "duration": { + "properties": { + "us": { + "type": "long" + } + } + }, + "end": { + "type": "date" + }, + "evaluation": { + "properties": { + "threshold": { + "scaling_factor": 100, + "type": "scaled_float" + }, + "value": { + "scaling_factor": 100, + "type": "scaled_float" + } + } + }, + "instance": { + "properties": { + "id": { + "type": "keyword" + } + } + }, + "reason": { + "type": "keyword" + }, + "rule": { + "properties": { + "author": { + "type": "keyword" + }, + "category": { + "type": "keyword" + }, + "consumer": { + "type": "keyword" + }, + "created_at": { + "type": "date" + }, + "created_by": { + "type": "keyword" + }, + "description": { + "type": "keyword" + }, + "enabled": { + "type": "keyword" + }, + "from": { + "type": "keyword" + }, + "interval": { + "type": "keyword" + }, + "license": { + "type": "keyword" + }, + "name": { + "type": "keyword" + }, + "note": { + "type": "keyword" + }, + "params": { + "index": false, + "type": "keyword" + }, + "producer": { + "type": "keyword" + }, + "references": { + "type": "keyword" + }, + "risk_score": { + "type": "float" + }, + "risk_score_mapping": { + "properties": { + "field": { + "type": "keyword" + }, + "operator": { + "type": "keyword" + }, + "value": { + "type": "keyword" + } + } + }, + "rule_id": { + "type": "keyword" + }, + "rule_name_override": { + "type": "keyword" + }, + "rule_type_id": { + "type": "keyword" + }, + "severity": { + "type": "keyword" + }, + "severity_mapping": { + "properties": { + "field": { + "type": "keyword" + }, + "operator": { + "type": "keyword" + }, + "severity": { + "type": "keyword" + }, + "value": { + "type": "keyword" + } + } + }, + "tags": { + "type": "keyword" + }, + "to": { + "type": "keyword" + }, + "type": { + "type": "keyword" + }, + "updated_at": { + "type": "date" + }, + "updated_by": { + "type": "keyword" + }, + "uuid": { + "type": "keyword" + }, + "version": { + "type": "keyword" + } + } + }, + "severity": { + "type": "keyword" + }, + "start": { + "type": "date" + }, + "status": { + "type": "keyword" + }, + "system_status": { + "type": "keyword" + }, + "uuid": { + "type": "keyword" + }, + "workflow_reason": { + "type": "keyword" + }, + "workflow_status": { + "type": "keyword" + }, + "workflow_user": { + "type": "keyword" + } + } + }, + "space_ids": { + "type": "keyword" + }, + "version": { + "type": "version" + } + } + }, + "tags": { + "type": "keyword" + } + } + }, + "settings": { + "index": { + "lifecycle": { + "name": ".alerts-ilm-policy", + "rollover_alias": ".alerts-observability.metrics.alerts-default" + }, + "number_of_replicas": "1", + "number_of_shards": "1" + } + } + } +} \ No newline at end of file diff --git a/x-pack/test/functional/page_objects/infra_hosts_view.ts b/x-pack/test/functional/page_objects/infra_hosts_view.ts index ddc7f24029d46..b070a1267d4f0 100644 --- a/x-pack/test/functional/page_objects/infra_hosts_view.ts +++ b/x-pack/test/functional/page_objects/infra_hosts_view.ts @@ -5,6 +5,7 @@ * 2.0. */ +import { AlertStatus, ALERT_STATUS_ACTIVE, ALERT_STATUS_RECOVERED } from '@kbn/rule-data-utils'; import { FtrProviderContext } from '../ftr_provider_context'; export function InfraHostsViewProvider({ getService }: FtrProviderContext) { @@ -79,5 +80,31 @@ export function InfraHostsViewProvider({ getService }: FtrProviderContext) { await testSubjects.existOrFail('embeddablePanelContextMenuOpen'); return testSubjects.existOrFail('embeddablePanelAction-openInLens'); }, + + // Alerts Tab + getAlertsTab() { + return testSubjects.find('hostsView-tabs-alerts'); + }, + + getAlertsTabCountBadge() { + return testSubjects.find('hostsView-tabs-alerts-count'); + }, + + async visitAlertTab() { + const alertsTab = await this.getAlertsTab(); + alertsTab.click(); + }, + + setAlertStatusFilter(alertStatus?: AlertStatus) { + const buttons = { + [ALERT_STATUS_ACTIVE]: 'hostsView-alert-status-filter-active-button', + [ALERT_STATUS_RECOVERED]: 'hostsView-alert-status-filter-recovered-button', + all: 'hostsView-alert-status-filter-show-all-button', + }; + + const buttonSubject = alertStatus ? buttons[alertStatus] : buttons.all; + + return testSubjects.click(buttonSubject); + }, }; }