mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
Revert "[AO][SERVERLESS] Fix Custom Threshold rule tests for Serverless (#166942)"
This reverts commit 4c1ca7e92f
.
This commit is contained in:
parent
f7095d5e50
commit
706f6fa7a0
23 changed files with 296 additions and 553 deletions
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,18 +0,0 @@
|
|||
{
|
||||
"_meta": {
|
||||
"ecs_version": "8.0.0"
|
||||
},
|
||||
"template": {
|
||||
"mappings": {
|
||||
"properties": {
|
||||
"metricset": {
|
||||
"properties": {
|
||||
"interval": {
|
||||
"type": "long"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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<typeof IndexTemplateDefRT>;
|
||||
|
||||
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,
|
||||
};
|
|
@ -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': {},
|
||||
},
|
||||
};
|
28
x-pack/packages/kbn-infra-forge/src/lib/install_template.ts
Normal file
28
x-pack/packages/kbn-infra-forge/src/lib/install_template.ts
Normal file
|
@ -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)}`));
|
||||
}
|
|
@ -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)}`)
|
||||
);
|
||||
}
|
||||
}
|
|
@ -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(
|
||||
|
|
|
@ -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);
|
||||
};
|
||||
|
|
|
@ -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',
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -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',
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -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',
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -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',
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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.'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue