From 706f6fa7a02253fdbfe9bba195d4703a4398b0b9 Mon Sep 17 00:00:00 2001 From: Jonathan Budzenski Date: Thu, 28 Sep 2023 20:13:10 -0500 Subject: [PATCH 1/3] Revert "[AO][SERVERLESS] Fix Custom Threshold rule tests for Serverless (#166942)" This reverts commit 4c1ca7e92fbc387279d0d41fd1238e790ce53518. --- .../composable/component/base.json | 25 -- .../composable/component/event.json | 24 -- .../composable/component/host.json | 189 --------------- .../composable/component/metricset.json | 18 -- .../composable/component/system.json | 69 ------ .../src/data_sources/composable/template.json | 52 ----- .../src/data_sources/fake_hosts/index.ts | 2 +- .../fake_hosts/index_template_def.ts | 38 --- .../src/data_sources/fake_hosts/template.ts | 218 ++++++++++++++++++ .../src/lib/install_template.ts | 28 +++ .../src/lib/manage_template.ts | 59 ----- .../packages/kbn-infra-forge/src/lib/queue.ts | 4 +- x-pack/packages/kbn-infra-forge/src/run.ts | 7 +- .../custom_threshold_rule/avg_pct_fired.ts | 7 +- .../custom_eq_avg_bytes_fired.ts | 7 +- .../documents_count_fired.ts | 7 +- .../custom_threshold_rule/group_by_fired.ts | 7 +- .../observability/metric_threshold_rule.ts | 6 - .../custom_threshold_rule/avg_pct_fired.ts | 23 +- .../custom_threshold_rule/avg_pct_no_data.ts | 10 +- .../custom_eq_avg_bytes_fired.ts | 14 +- .../documents_count_fired.ts | 16 +- .../custom_threshold_rule/group_by_fired.ts | 19 +- 23 files changed, 296 insertions(+), 553 deletions(-) delete mode 100644 x-pack/packages/kbn-infra-forge/src/data_sources/composable/component/base.json delete mode 100644 x-pack/packages/kbn-infra-forge/src/data_sources/composable/component/event.json delete mode 100644 x-pack/packages/kbn-infra-forge/src/data_sources/composable/component/host.json delete mode 100644 x-pack/packages/kbn-infra-forge/src/data_sources/composable/component/metricset.json delete mode 100644 x-pack/packages/kbn-infra-forge/src/data_sources/composable/component/system.json delete mode 100644 x-pack/packages/kbn-infra-forge/src/data_sources/composable/template.json delete mode 100644 x-pack/packages/kbn-infra-forge/src/data_sources/fake_hosts/index_template_def.ts create mode 100644 x-pack/packages/kbn-infra-forge/src/data_sources/fake_hosts/template.ts create mode 100644 x-pack/packages/kbn-infra-forge/src/lib/install_template.ts delete mode 100644 x-pack/packages/kbn-infra-forge/src/lib/manage_template.ts diff --git a/x-pack/packages/kbn-infra-forge/src/data_sources/composable/component/base.json b/x-pack/packages/kbn-infra-forge/src/data_sources/composable/component/base.json deleted file mode 100644 index cebc9c2971745..0000000000000 --- a/x-pack/packages/kbn-infra-forge/src/data_sources/composable/component/base.json +++ /dev/null @@ -1,25 +0,0 @@ -{ - "_meta": { - "documentation": "https://www.elastic.co/guide/en/ecs/current/ecs-base.html", - "ecs_version": "8.0.0" - }, - "template": { - "mappings": { - "properties": { - "@timestamp": { - "type": "date" - }, - "labels": { - "type": "object" - }, - "message": { - "type": "match_only_text" - }, - "tags": { - "ignore_above": 1024, - "type": "keyword" - } - } - } - } -} diff --git a/x-pack/packages/kbn-infra-forge/src/data_sources/composable/component/event.json b/x-pack/packages/kbn-infra-forge/src/data_sources/composable/component/event.json deleted file mode 100644 index f235248f3ee83..0000000000000 --- a/x-pack/packages/kbn-infra-forge/src/data_sources/composable/component/event.json +++ /dev/null @@ -1,24 +0,0 @@ -{ - "_meta": { - "documentation": "https://www.elastic.co/guide/en/ecs/current/ecs-event.html", - "ecs_version": "8.0.0" - }, - "template": { - "mappings": { - "properties": { - "event": { - "properties": { - "dataset": { - "ignore_above": 1024, - "type": "keyword" - }, - "module": { - "ignore_above": 1024, - "type": "keyword" - } - } - } - } - } - } -} diff --git a/x-pack/packages/kbn-infra-forge/src/data_sources/composable/component/host.json b/x-pack/packages/kbn-infra-forge/src/data_sources/composable/component/host.json deleted file mode 100644 index cc370a5270eba..0000000000000 --- a/x-pack/packages/kbn-infra-forge/src/data_sources/composable/component/host.json +++ /dev/null @@ -1,189 +0,0 @@ -{ - "_meta": { - "documentation": "https://www.elastic.co/guide/en/ecs/current/ecs-host.html", - "ecs_version": "8.0.0" - }, - "template": { - "mappings": { - "properties": { - "host": { - "properties": { - "architecture": { - "ignore_above": 1024, - "type": "keyword" - }, - "cpu": { - "properties": { - "usage": { - "scaling_factor": 1000, - "type": "scaled_float" - } - } - }, - "disk": { - "properties": { - "read": { - "properties": { - "bytes": { - "type": "long" - } - } - }, - "write": { - "properties": { - "bytes": { - "type": "long" - } - } - } - } - }, - "domain": { - "ignore_above": 1024, - "type": "keyword" - }, - "geo": { - "properties": { - "city_name": { - "ignore_above": 1024, - "type": "keyword" - }, - "continent_code": { - "ignore_above": 1024, - "type": "keyword" - }, - "continent_name": { - "ignore_above": 1024, - "type": "keyword" - }, - "country_iso_code": { - "ignore_above": 1024, - "type": "keyword" - }, - "country_name": { - "ignore_above": 1024, - "type": "keyword" - }, - "location": { - "type": "geo_point" - }, - "name": { - "ignore_above": 1024, - "type": "keyword" - }, - "postal_code": { - "ignore_above": 1024, - "type": "keyword" - }, - "region_iso_code": { - "ignore_above": 1024, - "type": "keyword" - }, - "region_name": { - "ignore_above": 1024, - "type": "keyword" - }, - "timezone": { - "ignore_above": 1024, - "type": "keyword" - } - } - }, - "hostname": { - "ignore_above": 1024, - "type": "keyword" - }, - "id": { - "ignore_above": 1024, - "type": "keyword" - }, - "ip": { - "type": "ip" - }, - "mac": { - "ignore_above": 1024, - "type": "keyword" - }, - "name": { - "ignore_above": 1024, - "type": "keyword" - }, - "network": { - "properties": { - "egress": { - "properties": { - "bytes": { - "type": "long" - }, - "packets": { - "type": "long" - } - } - }, - "ingress": { - "properties": { - "bytes": { - "type": "long" - }, - "packets": { - "type": "long" - } - } - } - } - }, - "os": { - "properties": { - "family": { - "ignore_above": 1024, - "type": "keyword" - }, - "full": { - "fields": { - "text": { - "type": "match_only_text" - } - }, - "ignore_above": 1024, - "type": "keyword" - }, - "kernel": { - "ignore_above": 1024, - "type": "keyword" - }, - "name": { - "fields": { - "text": { - "type": "match_only_text" - } - }, - "ignore_above": 1024, - "type": "keyword" - }, - "platform": { - "ignore_above": 1024, - "type": "keyword" - }, - "type": { - "ignore_above": 1024, - "type": "keyword" - }, - "version": { - "ignore_above": 1024, - "type": "keyword" - } - } - }, - "type": { - "ignore_above": 1024, - "type": "keyword" - }, - "uptime": { - "type": "long" - } - } - } - } - } - } -} diff --git a/x-pack/packages/kbn-infra-forge/src/data_sources/composable/component/metricset.json b/x-pack/packages/kbn-infra-forge/src/data_sources/composable/component/metricset.json deleted file mode 100644 index 06ef8b57bf4b3..0000000000000 --- a/x-pack/packages/kbn-infra-forge/src/data_sources/composable/component/metricset.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "_meta": { - "ecs_version": "8.0.0" - }, - "template": { - "mappings": { - "properties": { - "metricset": { - "properties": { - "interval": { - "type": "long" - } - } - } - } - } - } -} diff --git a/x-pack/packages/kbn-infra-forge/src/data_sources/composable/component/system.json b/x-pack/packages/kbn-infra-forge/src/data_sources/composable/component/system.json deleted file mode 100644 index 46335a6da442c..0000000000000 --- a/x-pack/packages/kbn-infra-forge/src/data_sources/composable/component/system.json +++ /dev/null @@ -1,69 +0,0 @@ -{ - "_meta": { - "ecs_version": "8.0.0" - }, - "template": { - "mappings": { - "properties": { - "system": { - "properties": { - "cpu": { - "properties": { - "cores": { - "type": "integer" - }, - "system": { - "properties": { - "pct": { - "type": "float" - } - } - }, - "total": { - "properties": { - "norm": { - "properties": { - "pct": { - "type": "float" - } - } - } - } - }, - "user": { - "properties": { - "pct": { - "type": "float" - } - } - } - } - }, - "network": { - "properties": { - "in": { - "properties": { - "bytes": { - "type": "long" - } - } - }, - "name": { - "ignore_above": 1024, - "type": "keyword" - }, - "out": { - "properties": { - "bytes": { - "type": "long" - } - } - } - } - } - } - } - } - } - } -} diff --git a/x-pack/packages/kbn-infra-forge/src/data_sources/composable/template.json b/x-pack/packages/kbn-infra-forge/src/data_sources/composable/template.json deleted file mode 100644 index 8064e7866e5f6..0000000000000 --- a/x-pack/packages/kbn-infra-forge/src/data_sources/composable/template.json +++ /dev/null @@ -1,52 +0,0 @@ -{ - "_meta": { - "description": "Sample composable template that includes all ECS fields", - "ecs_version": "8.0.0" - }, - "composed_of": [ - "ecs_8.0.0_base", - "ecs_8.0.0_event", - "ecs_8.0.0_host", - "ecs_8.0.0_metricset", - "ecs_8.0.0_system" - ], - "index_patterns": [ - "kbn-data-forge-fake_hosts" - ], - "priority": 1, - "template": { - "mappings": { - "_meta": { - "version": "1.6.0" - }, - "date_detection": false, - "dynamic_templates": [ - { - "strings_as_keyword": { - "mapping": { - "fields": { - "text": { - "norms": false, - "type": "text" - } - }, - "ignore_above": 1024, - "type": "keyword" - }, - "match_mapping_type": "string" - } - } - ] - }, - "settings": { - "index": { - "codec": "best_compression", - "mapping": { - "total_fields": { - "limit": 2000 - } - } - } - } - } -} diff --git a/x-pack/packages/kbn-infra-forge/src/data_sources/fake_hosts/index.ts b/x-pack/packages/kbn-infra-forge/src/data_sources/fake_hosts/index.ts index fe969726499b4..f6b685077ec6a 100644 --- a/x-pack/packages/kbn-infra-forge/src/data_sources/fake_hosts/index.ts +++ b/x-pack/packages/kbn-infra-forge/src/data_sources/fake_hosts/index.ts @@ -8,7 +8,7 @@ import lodash from 'lodash'; import type { Moment } from 'moment'; -export { indexTemplate } from './index_template_def'; +export { template } from './template'; const createGroupIndex = (index: number) => Math.floor(index / 1000) * 1000; diff --git a/x-pack/packages/kbn-infra-forge/src/data_sources/fake_hosts/index_template_def.ts b/x-pack/packages/kbn-infra-forge/src/data_sources/fake_hosts/index_template_def.ts deleted file mode 100644 index ab3876edabf5a..0000000000000 --- a/x-pack/packages/kbn-infra-forge/src/data_sources/fake_hosts/index_template_def.ts +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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 * as rt from 'io-ts'; -import base from '../composable/component/base.json'; -import event from '../composable/component/event.json'; -import host from '../composable/component/host.json'; -import metricset from '../composable/component/metricset.json'; -import system from '../composable/component/system.json'; - -import template from '../composable/template.json'; -const IndexTemplateDefRT = rt.type({ - namespace: rt.string, - template: rt.UnknownRecord, - components: rt.array(rt.type({ name: rt.string, template: rt.UnknownRecord })), -}); - -export type IndexTemplateDef = rt.TypeOf; - -const ECS_VERSION = template._meta.ecs_version; - -const components = [ - { name: `fake_hosts_${ECS_VERSION}_base`, template: base }, - { name: `fake_hosts_${ECS_VERSION}_event`, template: event }, - { name: `fake_hosts_${ECS_VERSION}_host`, template: host }, - { name: `fake_hosts_${ECS_VERSION}_metricset`, template: metricset }, - { name: `fake_hosts_${ECS_VERSION}_system`, template: system }, -]; - -export const indexTemplate: IndexTemplateDef = { - namespace: 'fake_hosts', - template: { ...template, composed_of: components.map(({ name }) => name) }, - components, -}; diff --git a/x-pack/packages/kbn-infra-forge/src/data_sources/fake_hosts/template.ts b/x-pack/packages/kbn-infra-forge/src/data_sources/fake_hosts/template.ts new file mode 100644 index 0000000000000..145002606a789 --- /dev/null +++ b/x-pack/packages/kbn-infra-forge/src/data_sources/fake_hosts/template.ts @@ -0,0 +1,218 @@ +/* + * 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. + */ + +export const template = { + order: 1, + index_patterns: ['kbn-data-forge*'], + settings: { + index: { + mapping: { + total_fields: { + limit: '10000', + }, + }, + number_of_shards: '1', + number_of_replicas: '0', + query: { + default_field: ['message', 'labels.*', 'event.*'], + }, + }, + }, + mappings: { + dynamic_templates: [ + { + labels: { + path_match: 'labels.*', + mapping: { + type: 'keyword', + }, + match_mapping_type: 'string', + }, + }, + { + strings_as_keyword: { + mapping: { + ignore_above: 1024, + type: 'keyword', + }, + match_mapping_type: 'string', + }, + }, + ], + date_detection: false, + properties: { + '@timestamp': { + type: 'date', + }, + tags: { + type: 'keyword', + }, + metricset: { + properties: { + period: { + type: 'long', + }, + }, + }, + host: { + properties: { + name: { + type: 'keyword', + ignore_above: 256, + }, + network: { + properties: { + name: { + type: 'keyword', + ignore_above: 256, + }, + }, + }, + }, + }, + event: { + properties: { + dataset: { + type: 'keyword', + ignore_above: 256, + }, + module: { + type: 'keyword', + ignore_above: 256, + }, + }, + }, + system: { + properties: { + cpu: { + properties: { + cores: { + type: 'long', + }, + total: { + properties: { + norm: { + properties: { + pct: { + scaling_factor: 1000, + type: 'scaled_float', + }, + }, + }, + }, + }, + user: { + properties: { + pct: { + scaling_factor: 1000, + type: 'scaled_float', + }, + norm: { + properties: { + pct: { + scaling_factor: 1000, + type: 'scaled_float', + }, + }, + }, + }, + }, + system: { + properties: { + pct: { + scaling_factor: 1000, + type: 'scaled_float', + }, + }, + }, + }, + }, + network: { + properties: { + name: { + type: 'keyword', + ignore_above: 256, + }, + in: { + properties: { + bytes: { + type: 'long', + }, + }, + }, + out: { + properties: { + bytes: { + type: 'long', + }, + }, + }, + }, + }, + }, + }, + container: { + properties: { + id: { + type: 'keyword', + ignore_above: 256, + }, + name: { + type: 'keyword', + ignore_above: 256, + }, + cpu: { + properties: { + cores: { + type: 'long', + }, + total: { + properties: { + norm: { + properties: { + pct: { + scaling_factor: 1000, + type: 'scaled_float', + }, + }, + }, + }, + }, + user: { + properties: { + pct: { + scaling_factor: 1000, + type: 'scaled_float', + }, + norm: { + properties: { + pct: { + scaling_factor: 1000, + type: 'scaled_float', + }, + }, + }, + }, + }, + system: { + properties: { + pct: { + scaling_factor: 1000, + type: 'scaled_float', + }, + }, + }, + }, + }, + }, + }, + }, + }, + aliases: { + 'metrics-fake_hosts': {}, + }, +}; diff --git a/x-pack/packages/kbn-infra-forge/src/lib/install_template.ts b/x-pack/packages/kbn-infra-forge/src/lib/install_template.ts new file mode 100644 index 0000000000000..02e9f1cb8442d --- /dev/null +++ b/x-pack/packages/kbn-infra-forge/src/lib/install_template.ts @@ -0,0 +1,28 @@ +/* + * 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 type { Client } from '@elastic/elasticsearch'; +import type { ToolingLog } from '@kbn/tooling-log'; + +export function installTemplate( + client: Client, + template: object, + namespace: string, + logger: ToolingLog +) { + logger.debug(`installTemplate > template name: kbn-data-forge-${namespace}`); + return client.indices + .putTemplate({ name: `kbn-data-forge-${namespace}`, body: template }) + .catch((error: any) => logger.error(`installTemplate > ${JSON.stringify(error)}`)); +} + +export function deleteTemplate(client: Client, namespace: string, logger: ToolingLog) { + logger.debug(`deleteTemplate > template name: kbn-data-forge-${namespace}`); + return client.indices + .deleteTemplate({ name: `kbn-data-forge-${namespace}` }) + .catch((error: any) => logger.error(`deleteTemplate > ${JSON.stringify(error)}`)); +} diff --git a/x-pack/packages/kbn-infra-forge/src/lib/manage_template.ts b/x-pack/packages/kbn-infra-forge/src/lib/manage_template.ts deleted file mode 100644 index 722d1cb0b8ac4..0000000000000 --- a/x-pack/packages/kbn-infra-forge/src/lib/manage_template.ts +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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 type { Client } from '@elastic/elasticsearch'; -import type { ToolingLog } from '@kbn/tooling-log'; -import { IndexTemplateDef } from '../data_sources/fake_hosts/index_template_def'; - -export async function installTemplate( - client: Client, - template: IndexTemplateDef, - namespace: string, - logger: ToolingLog -) { - logger.info(`Installing index templates (${namespace})`); - const componentNames = template.components.map(({ name }) => name); - logger.info(`Installing components for ${template.namespace} (${componentNames})`); - for (const component of template.components) { - await client.cluster - .putComponentTemplate({ - name: component.name, - ...component.template, - }) - .catch((error) => logger.error(`Failed installing component > ${JSON.stringify(error)}`)); - } - logger.info(`Installing index template (${template.namespace})`); - await client.indices - .putIndexTemplate({ - name: template.namespace, - ...template.template, - }) - .catch((error) => logger.error(`Failed installing template > ${JSON.stringify(error)}`)); -} - -export async function deleteTemplate( - client: Client, - template: IndexTemplateDef, - logger: ToolingLog -) { - logger.info(`deleteIndexTemplate > template name: ${template.namespace}`); - await client.indices - .deleteIndexTemplate({ - name: template.namespace, - }) - .catch((error: any) => - logger.error(`deleteIndexTemplate > ${template.namespace} ${JSON.stringify(error)}`) - ); - for (const component of template.components) { - logger.info(`deleteComponents > component name: ${component.name}`); - await client.cluster - .deleteComponentTemplate({ name: component.name }) - .catch((error: any) => - logger.error(`deleteComponents > ${component.name} ${JSON.stringify(error)}`) - ); - } -} diff --git a/x-pack/packages/kbn-infra-forge/src/lib/queue.ts b/x-pack/packages/kbn-infra-forge/src/lib/queue.ts index 75f3affb743d3..bf6553fe01b88 100644 --- a/x-pack/packages/kbn-infra-forge/src/lib/queue.ts +++ b/x-pack/packages/kbn-infra-forge/src/lib/queue.ts @@ -24,7 +24,7 @@ export const createQueue = ( logger.debug(`createQueue > index name: ${indexName}`); return async.cargoQueue( (docs: object[], callback) => { - const body: object[] = []; + const body: any[] = []; docs.forEach((doc) => { body.push({ create: { @@ -34,7 +34,7 @@ export const createQueue = ( body.push(omit(doc, 'namespace')); }); esClient - .bulk({ body, refresh: true }) + .bulk({ body }) .then((resp) => { if (resp.errors) { logger.error( diff --git a/x-pack/packages/kbn-infra-forge/src/run.ts b/x-pack/packages/kbn-infra-forge/src/run.ts index aad2adb24bc93..470c0afbdccc6 100644 --- a/x-pack/packages/kbn-infra-forge/src/run.ts +++ b/x-pack/packages/kbn-infra-forge/src/run.ts @@ -12,7 +12,7 @@ import type { Moment } from 'moment'; import type { ToolingLog } from '@kbn/tooling-log'; import type { Client } from '@elastic/elasticsearch'; import { createQueue, getIndexName } from './lib/queue'; -import { deleteTemplate, installTemplate } from './lib/manage_template'; +import { deleteTemplate, installTemplate } from './lib/install_template'; import * as fakeHosts from './data_sources/fake_hosts'; const generateEventsFns = { @@ -20,7 +20,7 @@ const generateEventsFns = { }; const templates = { - fake_hosts: fakeHosts.indexTemplate, + fake_hosts: fakeHosts.template, }; const EVENTS_PER_CYCLE = 1; @@ -68,6 +68,5 @@ export const generate = async ({ }; export const cleanup = async ({ esClient, logger }: { esClient: Client; logger: ToolingLog }) => { - const template = templates[DATASET]; - await deleteTemplate(esClient, template, logger); + await deleteTemplate(esClient, DATASET, logger); }; diff --git a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/avg_pct_fired.ts b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/avg_pct_fired.ts index c2d91677af2a2..fd5a4054f0895 100644 --- a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/avg_pct_fired.ts +++ b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/avg_pct_fired.ts @@ -28,9 +28,6 @@ export default function ({ getService }: FtrProviderContext) { describe('Custom Threshold rule - AVG - PCT - FIRED', () => { const CUSTOM_THRESHOLD_RULE_ALERT_INDEX = '.alerts-observability.threshold.alerts-default'; const ALERT_ACTION_INDEX = 'alert-action-threshold'; - // DATE_VIEW should match the index template: - // x-pack/packages/kbn-infra-forge/src/data_sources/composable/template.json - const DATE_VIEW = 'kbn-data-forge-fake_hosts'; const DATA_VIEW_ID = 'data-view-id'; let infraDataIndex: string; let actionId: string; @@ -40,9 +37,9 @@ export default function ({ getService }: FtrProviderContext) { infraDataIndex = await generate({ esClient, lookback: 'now-15m', logger }); await createDataView({ supertest, - name: DATE_VIEW, + name: 'metrics-fake_hosts', id: DATA_VIEW_ID, - title: DATE_VIEW, + title: 'metrics-fake_hosts', }); }); diff --git a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/custom_eq_avg_bytes_fired.ts b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/custom_eq_avg_bytes_fired.ts index d17e0a1568603..7f7e66d050593 100644 --- a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/custom_eq_avg_bytes_fired.ts +++ b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/custom_eq_avg_bytes_fired.ts @@ -34,9 +34,6 @@ export default function ({ getService }: FtrProviderContext) { describe('Custom Threshold rule - CUSTOM_EQ - AVG - BYTES - FIRED', () => { const CUSTOM_THRESHOLD_RULE_ALERT_INDEX = '.alerts-observability.threshold.alerts-default'; const ALERT_ACTION_INDEX = 'alert-action-threshold'; - // DATE_VIEW should match the index template: - // x-pack/packages/kbn-infra-forge/src/data_sources/composable/template.json - const DATE_VIEW = 'kbn-data-forge-fake_hosts'; const DATA_VIEW_ID = 'data-view-id'; let infraDataIndex: string; let actionId: string; @@ -46,9 +43,9 @@ export default function ({ getService }: FtrProviderContext) { infraDataIndex = await generate({ esClient, lookback: 'now-15m', logger }); await createDataView({ supertest, - name: DATE_VIEW, + name: 'metrics-fake_hosts', id: DATA_VIEW_ID, - title: DATE_VIEW, + title: 'metrics-fake_hosts', }); }); diff --git a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/documents_count_fired.ts b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/documents_count_fired.ts index 4f5a1077c22d1..6a17340094e80 100644 --- a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/documents_count_fired.ts +++ b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/documents_count_fired.ts @@ -28,9 +28,6 @@ export default function ({ getService }: FtrProviderContext) { describe('Custom Threshold rule - DOCUMENTS_COUNT - FIRED', () => { const CUSTOM_THRESHOLD_RULE_ALERT_INDEX = '.alerts-observability.threshold.alerts-default'; const ALERT_ACTION_INDEX = 'alert-action-threshold'; - // DATE_VIEW should match the index template: - // x-pack/packages/kbn-infra-forge/src/data_sources/composable/template.json - const DATE_VIEW = 'kbn-data-forge-fake_hosts'; const DATA_VIEW_ID = 'data-view-id'; let infraDataIndex: string; let actionId: string; @@ -40,9 +37,9 @@ export default function ({ getService }: FtrProviderContext) { infraDataIndex = await generate({ esClient, lookback: 'now-15m', logger }); await createDataView({ supertest, - name: DATE_VIEW, + name: 'metrics-fake_hosts', id: DATA_VIEW_ID, - title: DATE_VIEW, + title: 'metrics-fake_hosts', }); }); diff --git a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/group_by_fired.ts b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/group_by_fired.ts index 01386c9bd0250..da18b429c45c0 100644 --- a/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/group_by_fired.ts +++ b/x-pack/test/alerting_api_integration/observability/custom_threshold_rule/group_by_fired.ts @@ -41,9 +41,6 @@ export default function ({ getService }: FtrProviderContext) { describe('Custom Threshold rule - GROUP_BY - FIRED', () => { const CUSTOM_THRESHOLD_RULE_ALERT_INDEX = '.alerts-observability.threshold.alerts-default'; const ALERT_ACTION_INDEX = 'alert-action-threshold'; - // DATE_VIEW should match the index template: - // x-pack/packages/kbn-infra-forge/src/data_sources/composable/template.json - const DATE_VIEW = 'kbn-data-forge-fake_hosts'; const DATA_VIEW_ID = 'data-view-id'; let infraDataIndex: string; let actionId: string; @@ -53,9 +50,9 @@ export default function ({ getService }: FtrProviderContext) { infraDataIndex = await generate({ esClient, lookback: 'now-15m', logger }); await createDataView({ supertest, - name: DATE_VIEW, + name: 'metrics-fake_hosts', id: DATA_VIEW_ID, - title: DATE_VIEW, + title: 'metrics-fake_hosts', }); }); diff --git a/x-pack/test/alerting_api_integration/observability/metric_threshold_rule.ts b/x-pack/test/alerting_api_integration/observability/metric_threshold_rule.ts index 0de7e3d600612..2b727820ade70 100644 --- a/x-pack/test/alerting_api_integration/observability/metric_threshold_rule.ts +++ b/x-pack/test/alerting_api_integration/observability/metric_threshold_rule.ts @@ -36,12 +36,6 @@ export default function ({ getService }: FtrProviderContext) { describe('alert and action creation', () => { before(async () => { - await supertest.patch(`/api/metrics/source/default`).set('kbn-xsrf', 'foo').send({ - anomalyThreshold: 50, - description: '', - metricAlias: 'kbn-data-forge*', - name: 'Default', - }); infraDataIndex = await generate({ esClient, lookback: 'now-15m', logger }); actionId = await createIndexConnector({ supertest, diff --git a/x-pack/test_serverless/api_integration/test_suites/observability/custom_threshold_rule/avg_pct_fired.ts b/x-pack/test_serverless/api_integration/test_suites/observability/custom_threshold_rule/avg_pct_fired.ts index de26cb2e906d4..0389d0eace4e7 100644 --- a/x-pack/test_serverless/api_integration/test_suites/observability/custom_threshold_rule/avg_pct_fired.ts +++ b/x-pack/test_serverless/api_integration/test_suites/observability/custom_threshold_rule/avg_pct_fired.ts @@ -23,11 +23,10 @@ export default function ({ getService }: FtrProviderContext) { const dataViewApi = getService('dataViewApi'); const logger = getService('log'); - describe('Custom Threshold rule - AVG - PCT - FIRED', () => { + // Blocked API: index_not_found_exception: no such index [.alerts-observability.threshold.alerts-default] + // Issue: https://github.com/elastic/kibana/issues/165138 + describe.skip('Custom Threshold rule - AVG - PCT - FIRED', () => { const CUSTOM_THRESHOLD_RULE_ALERT_INDEX = '.alerts-observability.threshold.alerts-default'; - // DATE_VIEW should match the index template: - // x-pack/packages/kbn-infra-forge/src/data_sources/composable/template.json - const DATE_VIEW = 'kbn-data-forge-fake_hosts'; const ALERT_ACTION_INDEX = 'alert-action-threshold'; const DATA_VIEW_ID = 'data-view-id'; let infraDataIndex: string; @@ -35,15 +34,11 @@ export default function ({ getService }: FtrProviderContext) { let ruleId: string; before(async () => { - infraDataIndex = await generate({ - esClient, - lookback: 'now-15m', - logger, - }); + infraDataIndex = await generate({ esClient, lookback: 'now-15m', logger }); await dataViewApi.create({ - name: DATE_VIEW, + name: 'metrics-fake_hosts', id: DATA_VIEW_ID, - title: DATE_VIEW, + title: 'metrics-fake_hosts', }); }); @@ -62,7 +57,7 @@ export default function ({ getService }: FtrProviderContext) { }); await esClient.deleteByQuery({ index: '.kibana-event-log-*', - query: { term: { 'kibana.alert.rule.consumer': 'apm' } }, + query: { term: { 'kibana.alert.rule.consumer': 'logs' } }, }); await dataViewApi.delete({ id: DATA_VIEW_ID, @@ -80,7 +75,7 @@ export default function ({ getService }: FtrProviderContext) { const createdRule = await alertingApi.createRule({ tags: ['observability'], - consumer: 'apm', + consumer: 'logs', name: 'Threshold rule', ruleTypeId: OBSERVABILITY_THRESHOLD_RULE_TYPE_ID, params: { @@ -147,7 +142,7 @@ export default function ({ getService }: FtrProviderContext) { 'kibana.alert.rule.category', 'Custom threshold (BETA)' ); - expect(resp.hits.hits[0]._source).property('kibana.alert.rule.consumer', 'apm'); + expect(resp.hits.hits[0]._source).property('kibana.alert.rule.consumer', 'logs'); expect(resp.hits.hits[0]._source).property('kibana.alert.rule.name', 'Threshold rule'); expect(resp.hits.hits[0]._source).property('kibana.alert.rule.producer', 'observability'); expect(resp.hits.hits[0]._source).property('kibana.alert.rule.revision', 0); diff --git a/x-pack/test_serverless/api_integration/test_suites/observability/custom_threshold_rule/avg_pct_no_data.ts b/x-pack/test_serverless/api_integration/test_suites/observability/custom_threshold_rule/avg_pct_no_data.ts index b1cc5c41f6805..0bd7fdf7bbb6f 100644 --- a/x-pack/test_serverless/api_integration/test_suites/observability/custom_threshold_rule/avg_pct_no_data.ts +++ b/x-pack/test_serverless/api_integration/test_suites/observability/custom_threshold_rule/avg_pct_no_data.ts @@ -20,7 +20,9 @@ export default function ({ getService }: FtrProviderContext) { const alertingApi = getService('alertingApi'); const dataViewApi = getService('dataViewApi'); - describe('Custom Threshold rule - AVG - PCT - NoData', () => { + // Blocked API: index_not_found_exception: no such index [.alerts-observability.threshold.alerts-default] + // Issue: https://github.com/elastic/kibana/issues/165138 + describe.skip('Custom Threshold rule - AVG - PCT - NoData', () => { const CUSTOM_THRESHOLD_RULE_ALERT_INDEX = '.alerts-observability.threshold.alerts-default'; const ALERT_ACTION_INDEX = 'alert-action-threshold'; const DATA_VIEW_ID = 'data-view-id-no-data'; @@ -50,7 +52,7 @@ export default function ({ getService }: FtrProviderContext) { }); await esClient.deleteByQuery({ index: '.kibana-event-log-*', - query: { term: { 'kibana.alert.rule.consumer': 'apm' } }, + query: { term: { 'kibana.alert.rule.consumer': 'logs' } }, }); await dataViewApi.delete({ id: DATA_VIEW_ID, @@ -66,7 +68,7 @@ export default function ({ getService }: FtrProviderContext) { const createdRule = await alertingApi.createRule({ tags: ['observability'], - consumer: 'apm', + consumer: 'logs', name: 'Threshold rule', ruleTypeId: OBSERVABILITY_THRESHOLD_RULE_TYPE_ID, params: { @@ -133,7 +135,7 @@ export default function ({ getService }: FtrProviderContext) { 'kibana.alert.rule.category', 'Custom threshold (BETA)' ); - expect(resp.hits.hits[0]._source).property('kibana.alert.rule.consumer', 'apm'); + expect(resp.hits.hits[0]._source).property('kibana.alert.rule.consumer', 'logs'); expect(resp.hits.hits[0]._source).property('kibana.alert.rule.name', 'Threshold rule'); expect(resp.hits.hits[0]._source).property('kibana.alert.rule.producer', 'observability'); expect(resp.hits.hits[0]._source).property('kibana.alert.rule.revision', 0); diff --git a/x-pack/test_serverless/api_integration/test_suites/observability/custom_threshold_rule/custom_eq_avg_bytes_fired.ts b/x-pack/test_serverless/api_integration/test_suites/observability/custom_threshold_rule/custom_eq_avg_bytes_fired.ts index b4b1858e9bac4..5ee54e1c9ad17 100644 --- a/x-pack/test_serverless/api_integration/test_suites/observability/custom_threshold_rule/custom_eq_avg_bytes_fired.ts +++ b/x-pack/test_serverless/api_integration/test_suites/observability/custom_threshold_rule/custom_eq_avg_bytes_fired.ts @@ -29,11 +29,9 @@ export default function ({ getService }: FtrProviderContext) { const alertingApi = getService('alertingApi'); const dataViewApi = getService('dataViewApi'); - describe('Custom Threshold rule - CUSTOM_EQ - AVG - BYTES - FIRED', () => { + // Issue: https://github.com/elastic/kibana/issues/165138 + describe.skip('Custom Threshold rule - CUSTOM_EQ - AVG - BYTES - FIRED', () => { const CUSTOM_THRESHOLD_RULE_ALERT_INDEX = '.alerts-observability.threshold.alerts-default'; - // DATE_VIEW should match the index template: - // x-pack/packages/kbn-infra-forge/src/data_sources/composable/template.json - const DATE_VIEW = 'kbn-data-forge-fake_hosts'; const ALERT_ACTION_INDEX = 'alert-action-threshold'; const DATA_VIEW_ID = 'data-view-id'; let infraDataIndex: string; @@ -43,9 +41,9 @@ export default function ({ getService }: FtrProviderContext) { before(async () => { infraDataIndex = await generate({ esClient, lookback: 'now-15m', logger }); await dataViewApi.create({ - name: DATE_VIEW, + name: 'metrics-fake_hosts', id: DATA_VIEW_ID, - title: DATE_VIEW, + title: 'metrics-fake_hosts', }); }); @@ -82,7 +80,7 @@ export default function ({ getService }: FtrProviderContext) { const createdRule = await alertingApi.createRule({ tags: ['observability'], - consumer: 'apm', + consumer: 'logs', name: 'Threshold rule', ruleTypeId: OBSERVABILITY_THRESHOLD_RULE_TYPE_ID, params: { @@ -151,7 +149,7 @@ export default function ({ getService }: FtrProviderContext) { 'kibana.alert.rule.category', 'Custom threshold (BETA)' ); - expect(resp.hits.hits[0]._source).property('kibana.alert.rule.consumer', 'apm'); + expect(resp.hits.hits[0]._source).property('kibana.alert.rule.consumer', 'logs'); expect(resp.hits.hits[0]._source).property('kibana.alert.rule.name', 'Threshold rule'); expect(resp.hits.hits[0]._source).property('kibana.alert.rule.producer', 'observability'); expect(resp.hits.hits[0]._source).property('kibana.alert.rule.revision', 0); diff --git a/x-pack/test_serverless/api_integration/test_suites/observability/custom_threshold_rule/documents_count_fired.ts b/x-pack/test_serverless/api_integration/test_suites/observability/custom_threshold_rule/documents_count_fired.ts index f5b0305993a91..56412a8380d2c 100644 --- a/x-pack/test_serverless/api_integration/test_suites/observability/custom_threshold_rule/documents_count_fired.ts +++ b/x-pack/test_serverless/api_integration/test_suites/observability/custom_threshold_rule/documents_count_fired.ts @@ -23,11 +23,9 @@ export default function ({ getService }: FtrProviderContext) { const alertingApi = getService('alertingApi'); const dataViewApi = getService('dataViewApi'); - describe('Custom Threshold rule - DOCUMENTS_COUNT - FIRED', () => { + // Issue: https://github.com/elastic/kibana/issues/165138 + describe.skip('Custom Threshold rule - DOCUMENTS_COUNT - FIRED', () => { const CUSTOM_THRESHOLD_RULE_ALERT_INDEX = '.alerts-observability.threshold.alerts-default'; - // DATE_VIEW should match the index template: - // x-pack/packages/kbn-infra-forge/src/data_sources/composable/template.json - const DATE_VIEW = 'kbn-data-forge-fake_hosts'; const ALERT_ACTION_INDEX = 'alert-action-threshold'; const DATA_VIEW_ID = 'data-view-id'; let infraDataIndex: string; @@ -37,9 +35,9 @@ export default function ({ getService }: FtrProviderContext) { before(async () => { infraDataIndex = await generate({ esClient, lookback: 'now-15m', logger }); await dataViewApi.create({ - name: DATE_VIEW, + name: 'metrics-fake_hosts', id: DATA_VIEW_ID, - title: DATE_VIEW, + title: 'metrics-fake_hosts', }); }); @@ -58,7 +56,7 @@ export default function ({ getService }: FtrProviderContext) { }); await esClient.deleteByQuery({ index: '.kibana-event-log-*', - query: { term: { 'kibana.alert.rule.consumer': 'apm' } }, + query: { term: { 'kibana.alert.rule.consumer': 'logs' } }, }); await dataViewApi.delete({ id: DATA_VIEW_ID, @@ -76,7 +74,7 @@ export default function ({ getService }: FtrProviderContext) { const createdRule = await alertingApi.createRule({ tags: ['observability'], - consumer: 'apm', + consumer: 'logs', name: 'Threshold rule', ruleTypeId: OBSERVABILITY_THRESHOLD_RULE_TYPE_ID, params: { @@ -141,7 +139,7 @@ export default function ({ getService }: FtrProviderContext) { 'kibana.alert.rule.category', 'Custom threshold (BETA)' ); - expect(resp.hits.hits[0]._source).property('kibana.alert.rule.consumer', 'apm'); + expect(resp.hits.hits[0]._source).property('kibana.alert.rule.consumer', 'logs'); expect(resp.hits.hits[0]._source).property('kibana.alert.rule.name', 'Threshold rule'); expect(resp.hits.hits[0]._source).property('kibana.alert.rule.producer', 'observability'); expect(resp.hits.hits[0]._source).property('kibana.alert.rule.revision', 0); diff --git a/x-pack/test_serverless/api_integration/test_suites/observability/custom_threshold_rule/group_by_fired.ts b/x-pack/test_serverless/api_integration/test_suites/observability/custom_threshold_rule/group_by_fired.ts index 09ae231091369..f1b3c949421d4 100644 --- a/x-pack/test_serverless/api_integration/test_suites/observability/custom_threshold_rule/group_by_fired.ts +++ b/x-pack/test_serverless/api_integration/test_suites/observability/custom_threshold_rule/group_by_fired.ts @@ -33,11 +33,9 @@ export default function ({ getService }: FtrProviderContext) { let alertId: string; let startedAt: string; - describe('Custom Threshold rule - GROUP_BY - FIRED', () => { + // Issue: https://github.com/elastic/kibana/issues/165138 + describe.skip('Custom Threshold rule - GROUP_BY - FIRED', () => { const CUSTOM_THRESHOLD_RULE_ALERT_INDEX = '.alerts-observability.threshold.alerts-default'; - // DATE_VIEW should match the index template: - // x-pack/packages/kbn-infra-forge/src/data_sources/composable/template.json - const DATE_VIEW = 'kbn-data-forge-fake_hosts'; const ALERT_ACTION_INDEX = 'alert-action-threshold'; const DATA_VIEW_ID = 'data-view-id'; let infraDataIndex: string; @@ -47,9 +45,9 @@ export default function ({ getService }: FtrProviderContext) { before(async () => { infraDataIndex = await generate({ esClient, lookback: 'now-15m', logger }); await dataViewApi.create({ - name: DATE_VIEW, + name: 'metrics-fake_hosts', id: DATA_VIEW_ID, - title: DATE_VIEW, + title: 'metrics-fake_hosts', }); }); @@ -68,7 +66,7 @@ export default function ({ getService }: FtrProviderContext) { }); await esClient.deleteByQuery({ index: '.kibana-event-log-*', - query: { term: { 'kibana.alert.rule.consumer': 'apm' } }, + query: { term: { 'kibana.alert.rule.consumer': 'logs' } }, }); await dataViewApi.delete({ id: DATA_VIEW_ID, @@ -86,7 +84,7 @@ export default function ({ getService }: FtrProviderContext) { const createdRule = await alertingApi.createRule({ tags: ['observability'], - consumer: 'apm', + consumer: 'logs', name: 'Threshold rule', ruleTypeId: OBSERVABILITY_THRESHOLD_RULE_TYPE_ID, params: { @@ -160,7 +158,7 @@ export default function ({ getService }: FtrProviderContext) { 'kibana.alert.rule.category', 'Custom threshold (BETA)' ); - expect(resp.hits.hits[0]._source).property('kibana.alert.rule.consumer', 'apm'); + expect(resp.hits.hits[0]._source).property('kibana.alert.rule.consumer', 'logs'); expect(resp.hits.hits[0]._source).property('kibana.alert.rule.name', 'Threshold rule'); expect(resp.hits.hits[0]._source).property('kibana.alert.rule.producer', 'observability'); expect(resp.hits.hits[0]._source).property('kibana.alert.rule.revision', 0); @@ -226,8 +224,7 @@ export default function ({ getService }: FtrProviderContext) { expect(resp.hits.hits[0]._source?.ruleType).eql('observability.rules.custom_threshold'); expect(resp.hits.hits[0]._source?.alertDetailsUrl).eql( - // Added the S to protocol.getUrlParts as not returning the correct value. - `${protocol}s://${hostname}:${port}/app/observability/alerts?_a=(kuery:%27kibana.alert.uuid:%20%22${alertId}%22%27%2CrangeFrom:%27${rangeFrom}%27%2CrangeTo:now%2Cstatus:all)` + `${protocol}://${hostname}:${port}/app/observability/alerts?_a=(kuery:%27kibana.alert.uuid:%20%22${alertId}%22%27%2CrangeFrom:%27${rangeFrom}%27%2CrangeTo:now%2Cstatus:all)` ); expect(resp.hits.hits[0]._source?.reason).eql( 'Custom equation is 0.8 in the last 1 min for host-0. Alert when >= 0.2.' From 6431d7c61ec1e1f81969e1750f03f233a076ff52 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Fri, 29 Sep 2023 08:29:23 -0400 Subject: [PATCH 2/3] skip failing test suite (#167619) --- .../observability/custom_threshold_rule/documents_count_fired.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/x-pack/test_serverless/api_integration/test_suites/observability/custom_threshold_rule/documents_count_fired.ts b/x-pack/test_serverless/api_integration/test_suites/observability/custom_threshold_rule/documents_count_fired.ts index 56412a8380d2c..7c67217ca96ee 100644 --- a/x-pack/test_serverless/api_integration/test_suites/observability/custom_threshold_rule/documents_count_fired.ts +++ b/x-pack/test_serverless/api_integration/test_suites/observability/custom_threshold_rule/documents_count_fired.ts @@ -24,6 +24,7 @@ export default function ({ getService }: FtrProviderContext) { const dataViewApi = getService('dataViewApi'); // Issue: https://github.com/elastic/kibana/issues/165138 + // Failing: See https://github.com/elastic/kibana/issues/167619 describe.skip('Custom Threshold rule - DOCUMENTS_COUNT - FIRED', () => { const CUSTOM_THRESHOLD_RULE_ALERT_INDEX = '.alerts-observability.threshold.alerts-default'; const ALERT_ACTION_INDEX = 'alert-action-threshold'; From d7b7659322405e72c4d2dde86c4860fc057c82a6 Mon Sep 17 00:00:00 2001 From: Kibana Machine <42973632+kibanamachine@users.noreply.github.com> Date: Fri, 29 Sep 2023 08:49:05 -0400 Subject: [PATCH 3/3] skip failing test suite (#167560) --- x-pack/test/saved_object_tagging/functional/tests/edit.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/x-pack/test/saved_object_tagging/functional/tests/edit.ts b/x-pack/test/saved_object_tagging/functional/tests/edit.ts index 96a91c72c3f3e..f29212b251827 100644 --- a/x-pack/test/saved_object_tagging/functional/tests/edit.ts +++ b/x-pack/test/saved_object_tagging/functional/tests/edit.ts @@ -15,7 +15,8 @@ export default function ({ getPageObjects, getService }: FtrProviderContext) { const tagManagementPage = PageObjects.tagManagement; - describe('edit tag', () => { + // Failing: See https://github.com/elastic/kibana/issues/167560 + describe.skip('edit tag', () => { let tagModal: typeof tagManagementPage['tagModal']; before(async () => {