diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index ff34e407e3b11..dab819ebffe92 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -750,7 +750,7 @@ examples/resizable_layout_examples @elastic/kibana-data-discovery x-pack/test/plugin_functional/plugins/resolver_test @elastic/security-solution packages/response-ops/feature_flag_service @elastic/response-ops packages/response-ops/rule_form @elastic/response-ops -src/platform/packages/private/response-ops/rule_params @elastic/response-ops +src/platform/packages/shared/response-ops/rule_params @elastic/response-ops examples/response_stream @elastic/ml-ui src/platform/packages/shared/kbn-rison @elastic/kibana-operations x-pack/platform/packages/private/rollup @elastic/kibana-management diff --git a/package.json b/package.json index 3c3f8d2feb3ab..1a3bdf9526d32 100644 --- a/package.json +++ b/package.json @@ -762,7 +762,7 @@ "@kbn/resolver-test-plugin": "link:x-pack/test/plugin_functional/plugins/resolver_test", "@kbn/response-ops-feature-flag-service": "link:packages/response-ops/feature_flag_service", "@kbn/response-ops-rule-form": "link:packages/response-ops/rule_form", - "@kbn/response-ops-rule-params": "link:src/platform/packages/private/response-ops/rule_params", + "@kbn/response-ops-rule-params": "link:src/platform/packages/shared/response-ops/rule_params", "@kbn/response-stream-plugin": "link:examples/response_stream", "@kbn/rison": "link:src/platform/packages/shared/kbn-rison", "@kbn/rollup": "link:x-pack/platform/packages/private/rollup", diff --git a/src/platform/packages/private/response-ops/rule_params/tsconfig.json b/src/platform/packages/private/response-ops/rule_params/tsconfig.json deleted file mode 100644 index bd6cfc03c6683..0000000000000 --- a/src/platform/packages/private/response-ops/rule_params/tsconfig.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "extends": "../../../../../../tsconfig.base.json", - "compilerOptions": { - "outDir": "target/types", - "types": [ - "jest", - "node" - ] - }, - "include": [ - "**/*.ts", - ], - "exclude": [ - "target/**/*" - ], - "kbn_references": [ - "@kbn/config-schema", - ] -} diff --git a/src/platform/packages/private/response-ops/rule_params/README.md b/src/platform/packages/shared/response-ops/rule_params/README.md similarity index 100% rename from src/platform/packages/private/response-ops/rule_params/README.md rename to src/platform/packages/shared/response-ops/rule_params/README.md diff --git a/src/platform/packages/shared/response-ops/rule_params/apm_anomaly/index.ts b/src/platform/packages/shared/response-ops/rule_params/apm_anomaly/index.ts new file mode 100644 index 0000000000000..dc6ebfe4ef99e --- /dev/null +++ b/src/platform/packages/shared/response-ops/rule_params/apm_anomaly/index.ts @@ -0,0 +1,14 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +export { anomalyParamsSchema } from './latest'; +export { anomalyParamsSchema as anomalyParamsSchemaV1 } from './v1'; + +export type { AnomalyRuleParams } from './latest'; +export type { AnomalyRuleParams as AnomalyRuleParamsV1 } from './v1'; diff --git a/src/platform/packages/private/response-ops/rule_params/latest.ts b/src/platform/packages/shared/response-ops/rule_params/apm_anomaly/latest.ts similarity index 100% rename from src/platform/packages/private/response-ops/rule_params/latest.ts rename to src/platform/packages/shared/response-ops/rule_params/apm_anomaly/latest.ts diff --git a/src/platform/packages/shared/response-ops/rule_params/apm_anomaly/v1.ts b/src/platform/packages/shared/response-ops/rule_params/apm_anomaly/v1.ts new file mode 100644 index 0000000000000..9e550815602a8 --- /dev/null +++ b/src/platform/packages/shared/response-ops/rule_params/apm_anomaly/v1.ts @@ -0,0 +1,40 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +import { TypeOf, schema } from '@kbn/config-schema'; +import { ML_ANOMALY_SEVERITY } from '@kbn/ml-anomaly-utils/anomaly_severity'; + +export enum AnomalyDetectorType { + txLatency = 'txLatency', + txThroughput = 'txThroughput', + txFailureRate = 'txFailureRate', +} + +const detectorsSchema = schema.oneOf([ + schema.literal(AnomalyDetectorType.txLatency), + schema.literal(AnomalyDetectorType.txThroughput), + schema.literal(AnomalyDetectorType.txFailureRate), +]); + +export const anomalyParamsSchema = schema.object({ + serviceName: schema.maybe(schema.string()), + transactionType: schema.maybe(schema.string()), + windowSize: schema.number(), + windowUnit: schema.string(), + environment: schema.string(), + anomalySeverityType: schema.oneOf([ + schema.literal(ML_ANOMALY_SEVERITY.CRITICAL), + schema.literal(ML_ANOMALY_SEVERITY.MAJOR), + schema.literal(ML_ANOMALY_SEVERITY.MINOR), + schema.literal(ML_ANOMALY_SEVERITY.WARNING), + ]), + anomalyDetectorTypes: schema.maybe(schema.arrayOf(detectorsSchema, { minSize: 1 })), +}); + +export type AnomalyRuleParams = TypeOf; diff --git a/src/platform/packages/shared/response-ops/rule_params/common/index.ts b/src/platform/packages/shared/response-ops/rule_params/common/index.ts new file mode 100644 index 0000000000000..4eaa2806a1a10 --- /dev/null +++ b/src/platform/packages/shared/response-ops/rule_params/common/index.ts @@ -0,0 +1,10 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +export * from './search_configuration_schema'; diff --git a/src/platform/packages/shared/response-ops/rule_params/common/search_configuration_schema.ts b/src/platform/packages/shared/response-ops/rule_params/common/search_configuration_schema.ts new file mode 100644 index 0000000000000..50b1f3ed1a561 --- /dev/null +++ b/src/platform/packages/shared/response-ops/rule_params/common/search_configuration_schema.ts @@ -0,0 +1,19 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +import { TypeOf, schema } from '@kbn/config-schema'; + +export const searchConfigurationSchema = schema.object({ + query: schema.object({ + query: schema.oneOf([schema.string(), schema.recordOf(schema.string(), schema.any())]), + language: schema.string(), + }), +}); + +export type SearchConfigurationType = TypeOf; diff --git a/src/platform/packages/shared/response-ops/rule_params/error_count/index.ts b/src/platform/packages/shared/response-ops/rule_params/error_count/index.ts new file mode 100644 index 0000000000000..e14153eb3083f --- /dev/null +++ b/src/platform/packages/shared/response-ops/rule_params/error_count/index.ts @@ -0,0 +1,14 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +export { errorCountParamsSchema } from './latest'; +export { errorCountParamsSchema as errorCountParamsSchemaV1 } from './v1'; + +export type { ErrorCountRuleParams } from './latest'; +export type { ErrorCountRuleParams as ErrorCountRuleParamsV1 } from './v1'; diff --git a/src/platform/packages/shared/response-ops/rule_params/error_count/latest.ts b/src/platform/packages/shared/response-ops/rule_params/error_count/latest.ts new file mode 100644 index 0000000000000..f278309c22b03 --- /dev/null +++ b/src/platform/packages/shared/response-ops/rule_params/error_count/latest.ts @@ -0,0 +1,10 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +export * from './v1'; diff --git a/src/platform/packages/shared/response-ops/rule_params/error_count/v1.ts b/src/platform/packages/shared/response-ops/rule_params/error_count/v1.ts new file mode 100644 index 0000000000000..cbbd6742bf235 --- /dev/null +++ b/src/platform/packages/shared/response-ops/rule_params/error_count/v1.ts @@ -0,0 +1,25 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +import { TypeOf, schema } from '@kbn/config-schema'; +import { searchConfigurationSchema } from '../common/search_configuration_schema'; + +export const errorCountParamsSchema = schema.object({ + windowSize: schema.number(), + windowUnit: schema.string(), + threshold: schema.number(), + serviceName: schema.maybe(schema.string()), + environment: schema.string(), + groupBy: schema.maybe(schema.arrayOf(schema.string())), + errorGroupingKey: schema.maybe(schema.string()), + useKqlFilter: schema.maybe(schema.boolean()), + searchConfiguration: schema.maybe(searchConfigurationSchema), +}); + +export type ErrorCountRuleParams = TypeOf; diff --git a/src/platform/packages/private/response-ops/rule_params/index.ts b/src/platform/packages/shared/response-ops/rule_params/index.ts similarity index 100% rename from src/platform/packages/private/response-ops/rule_params/index.ts rename to src/platform/packages/shared/response-ops/rule_params/index.ts diff --git a/src/platform/packages/private/response-ops/rule_params/jest.config.js b/src/platform/packages/shared/response-ops/rule_params/jest.config.js similarity index 87% rename from src/platform/packages/private/response-ops/rule_params/jest.config.js rename to src/platform/packages/shared/response-ops/rule_params/jest.config.js index 76636c7d4fc78..6df21724dbd84 100644 --- a/src/platform/packages/private/response-ops/rule_params/jest.config.js +++ b/src/platform/packages/shared/response-ops/rule_params/jest.config.js @@ -10,5 +10,5 @@ module.exports = { preset: '@kbn/test/jest_node', rootDir: '../../../../../..', - roots: ['/src/platform/packages/private/response-ops/rule_params'], + roots: ['/src/platform/packages/shared/response-ops/rule_params'], }; diff --git a/src/platform/packages/private/response-ops/rule_params/kibana.jsonc b/src/platform/packages/shared/response-ops/rule_params/kibana.jsonc similarity index 56% rename from src/platform/packages/private/response-ops/rule_params/kibana.jsonc rename to src/platform/packages/shared/response-ops/rule_params/kibana.jsonc index 1315303258949..1bf690c87bfd9 100644 --- a/src/platform/packages/private/response-ops/rule_params/kibana.jsonc +++ b/src/platform/packages/shared/response-ops/rule_params/kibana.jsonc @@ -1,9 +1,7 @@ { "type": "shared-common", "id": "@kbn/response-ops-rule-params", - "owner": [ - "@elastic/response-ops" - ], + "owner": ["@elastic/response-ops"], "group": "platform", - "visibility": "private" -} \ No newline at end of file + "visibility": "shared" +} diff --git a/src/platform/packages/shared/response-ops/rule_params/latest.ts b/src/platform/packages/shared/response-ops/rule_params/latest.ts new file mode 100644 index 0000000000000..f278309c22b03 --- /dev/null +++ b/src/platform/packages/shared/response-ops/rule_params/latest.ts @@ -0,0 +1,10 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +export * from './v1'; diff --git a/src/platform/packages/private/response-ops/rule_params/package.json b/src/platform/packages/shared/response-ops/rule_params/package.json similarity index 100% rename from src/platform/packages/private/response-ops/rule_params/package.json rename to src/platform/packages/shared/response-ops/rule_params/package.json diff --git a/src/platform/packages/shared/response-ops/rule_params/transaction_duration/index.ts b/src/platform/packages/shared/response-ops/rule_params/transaction_duration/index.ts new file mode 100644 index 0000000000000..baf910d1c033c --- /dev/null +++ b/src/platform/packages/shared/response-ops/rule_params/transaction_duration/index.ts @@ -0,0 +1,14 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +export { transactionDurationParamsSchema } from './latest'; +export { transactionDurationParamsSchema as transactionDurationParamsSchemaV1 } from './v1'; + +export type { TransactionDurationRuleParams } from './latest'; +export type { TransactionDurationRuleParams as TransactionDurationRuleParamsV1 } from './v1'; diff --git a/src/platform/packages/shared/response-ops/rule_params/transaction_duration/latest.ts b/src/platform/packages/shared/response-ops/rule_params/transaction_duration/latest.ts new file mode 100644 index 0000000000000..f278309c22b03 --- /dev/null +++ b/src/platform/packages/shared/response-ops/rule_params/transaction_duration/latest.ts @@ -0,0 +1,10 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +export * from './v1'; diff --git a/src/platform/packages/shared/response-ops/rule_params/transaction_duration/v1.ts b/src/platform/packages/shared/response-ops/rule_params/transaction_duration/v1.ts new file mode 100644 index 0000000000000..ab80398666607 --- /dev/null +++ b/src/platform/packages/shared/response-ops/rule_params/transaction_duration/v1.ts @@ -0,0 +1,37 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +import { TypeOf, schema } from '@kbn/config-schema'; +import { searchConfigurationSchema } from '../common/search_configuration_schema'; + +export enum AggregationType { + Avg = 'avg', + P95 = '95th', + P99 = '99th', +} + +export const transactionDurationParamsSchema = schema.object({ + serviceName: schema.maybe(schema.string()), + transactionType: schema.maybe(schema.string()), + transactionName: schema.maybe(schema.string()), + windowSize: schema.number(), + windowUnit: schema.string(), + threshold: schema.number(), + aggregationType: schema.oneOf([ + schema.literal(AggregationType.Avg), + schema.literal(AggregationType.P95), + schema.literal(AggregationType.P99), + ]), + environment: schema.string(), + groupBy: schema.maybe(schema.arrayOf(schema.string())), + useKqlFilter: schema.maybe(schema.boolean()), + searchConfiguration: schema.maybe(searchConfigurationSchema), +}); + +export type TransactionDurationRuleParams = TypeOf; diff --git a/src/platform/packages/shared/response-ops/rule_params/transaction_error_rate/index.ts b/src/platform/packages/shared/response-ops/rule_params/transaction_error_rate/index.ts new file mode 100644 index 0000000000000..c9630b7347e81 --- /dev/null +++ b/src/platform/packages/shared/response-ops/rule_params/transaction_error_rate/index.ts @@ -0,0 +1,14 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +export { transactionErrorRateParamsSchema } from './latest'; +export { transactionErrorRateParamsSchema as transactionErrorRateParamsSchemaV1 } from './v1'; + +export type { TransactionErrorRateRuleParams } from './latest'; +export type { TransactionErrorRateRuleParams as TransactionErrorRateRuleParamsV1 } from './v1'; diff --git a/src/platform/packages/shared/response-ops/rule_params/transaction_error_rate/latest.ts b/src/platform/packages/shared/response-ops/rule_params/transaction_error_rate/latest.ts new file mode 100644 index 0000000000000..f278309c22b03 --- /dev/null +++ b/src/platform/packages/shared/response-ops/rule_params/transaction_error_rate/latest.ts @@ -0,0 +1,10 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +export * from './v1'; diff --git a/src/platform/packages/shared/response-ops/rule_params/transaction_error_rate/v1.ts b/src/platform/packages/shared/response-ops/rule_params/transaction_error_rate/v1.ts new file mode 100644 index 0000000000000..452279d8ddd19 --- /dev/null +++ b/src/platform/packages/shared/response-ops/rule_params/transaction_error_rate/v1.ts @@ -0,0 +1,26 @@ +/* + * 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", the "GNU Affero General Public License v3.0 only", and the "Server Side + * Public License v 1"; you may not use this file except in compliance with, at + * your election, the "Elastic License 2.0", the "GNU Affero General Public + * License v3.0 only", or the "Server Side Public License, v 1". + */ + +import { TypeOf, schema } from '@kbn/config-schema'; +import { searchConfigurationSchema } from '../common/search_configuration_schema'; + +export const transactionErrorRateParamsSchema = schema.object({ + windowSize: schema.number(), + windowUnit: schema.string(), + threshold: schema.number(), + transactionType: schema.maybe(schema.string()), + transactionName: schema.maybe(schema.string()), + serviceName: schema.maybe(schema.string()), + environment: schema.string(), + groupBy: schema.maybe(schema.arrayOf(schema.string())), + useKqlFilter: schema.maybe(schema.boolean()), + searchConfiguration: schema.maybe(searchConfigurationSchema), +}); + +export type TransactionErrorRateRuleParams = TypeOf; diff --git a/src/platform/packages/shared/response-ops/rule_params/tsconfig.json b/src/platform/packages/shared/response-ops/rule_params/tsconfig.json new file mode 100644 index 0000000000000..47b4f90bb2813 --- /dev/null +++ b/src/platform/packages/shared/response-ops/rule_params/tsconfig.json @@ -0,0 +1,10 @@ +{ + "extends": "../../../../../../tsconfig.base.json", + "compilerOptions": { + "outDir": "target/types", + "types": ["jest", "node"] + }, + "include": ["**/*.ts"], + "exclude": ["target/**/*"], + "kbn_references": ["@kbn/config-schema", "@kbn/ml-anomaly-utils"] +} diff --git a/src/platform/packages/private/response-ops/rule_params/v1.ts b/src/platform/packages/shared/response-ops/rule_params/v1.ts similarity index 100% rename from src/platform/packages/private/response-ops/rule_params/v1.ts rename to src/platform/packages/shared/response-ops/rule_params/v1.ts diff --git a/tsconfig.base.json b/tsconfig.base.json index 9dddd8d5c1d8a..242f59bd9a198 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1494,8 +1494,8 @@ "@kbn/response-ops-feature-flag-service/*": ["packages/response-ops/feature_flag_service/*"], "@kbn/response-ops-rule-form": ["packages/response-ops/rule_form"], "@kbn/response-ops-rule-form/*": ["packages/response-ops/rule_form/*"], - "@kbn/response-ops-rule-params": ["src/platform/packages/private/response-ops/rule_params"], - "@kbn/response-ops-rule-params/*": ["src/platform/packages/private/response-ops/rule_params/*"], + "@kbn/response-ops-rule-params": ["src/platform/packages/shared/response-ops/rule_params"], + "@kbn/response-ops-rule-params/*": ["src/platform/packages/shared/response-ops/rule_params/*"], "@kbn/response-stream-plugin": ["examples/response_stream"], "@kbn/response-stream-plugin/*": ["examples/response_stream/*"], "@kbn/rison": ["src/platform/packages/shared/kbn-rison"], diff --git a/x-pack/platform/plugins/shared/alerting/server/application/rule/methods/bulk_edit/bulk_edit_rules.ts b/x-pack/platform/plugins/shared/alerting/server/application/rule/methods/bulk_edit/bulk_edit_rules.ts index f7d83545ec193..4ef8a2284c47b 100644 --- a/x-pack/platform/plugins/shared/alerting/server/application/rule/methods/bulk_edit/bulk_edit_rules.ts +++ b/x-pack/platform/plugins/shared/alerting/server/application/rule/methods/bulk_edit/bulk_edit_rules.ts @@ -513,7 +513,7 @@ async function updateRuleAttributesAndParamsInMemory( // Increment revision if params ended up being modified AND it wasn't already incremented as part of attribute update if ( - shouldIncrementRevision(ruleParams) && + shouldIncrementRevision(ruleParams as Params) && !isParamsUpdateSkipped && rule.attributes.revision === updatedRule.revision ) { diff --git a/x-pack/solutions/observability/plugins/apm/common/rules/apm_rule_types.ts b/x-pack/solutions/observability/plugins/apm/common/rules/apm_rule_types.ts index 151e7db67f52e..d1629348a4e23 100644 --- a/x-pack/solutions/observability/plugins/apm/common/rules/apm_rule_types.ts +++ b/x-pack/solutions/observability/plugins/apm/common/rules/apm_rule_types.ts @@ -13,6 +13,10 @@ import { formatDurationFromTimeUnitChar } from '@kbn/observability-plugin/common import { ML_ANOMALY_SEVERITY } from '@kbn/ml-anomaly-utils/anomaly_severity'; import { ML_ANOMALY_THRESHOLD } from '@kbn/ml-anomaly-utils/anomaly_threshold'; import { ApmRuleType } from '@kbn/rule-data-utils'; +import type { ErrorCountRuleParams } from '@kbn/response-ops-rule-params/error_count'; +import type { TransactionDurationRuleParams } from '@kbn/response-ops-rule-params/transaction_duration'; +import type { AnomalyRuleParams } from '@kbn/response-ops-rule-params/apm_anomaly'; +import type { TransactionErrorRateRuleParams } from '@kbn/response-ops-rule-params/transaction_error_rate'; import { ERROR_GROUP_ID, ERROR_GROUP_NAME, @@ -32,6 +36,13 @@ export enum AggregationType { P99 = '99th', } +export interface ApmRuleParamsType { + [ApmRuleType.TransactionDuration]: TransactionDurationRuleParams; + [ApmRuleType.ErrorCount]: ErrorCountRuleParams; + [ApmRuleType.Anomaly]: AnomalyRuleParams; + [ApmRuleType.TransactionErrorRate]: TransactionErrorRateRuleParams; +} + export const THRESHOLD_MET_GROUP_ID = 'threshold_met'; export type ThresholdMetActionGroupId = typeof THRESHOLD_MET_GROUP_ID; export const THRESHOLD_MET_GROUP: ActionGroup = { diff --git a/x-pack/solutions/observability/plugins/apm/public/components/alerting/rule_types/transaction_duration_rule_type/index.tsx b/x-pack/solutions/observability/plugins/apm/public/components/alerting/rule_types/transaction_duration_rule_type/index.tsx index f2f2ab0e50510..343dd4df480b7 100644 --- a/x-pack/solutions/observability/plugins/apm/public/components/alerting/rule_types/transaction_duration_rule_type/index.tsx +++ b/x-pack/solutions/observability/plugins/apm/public/components/alerting/rule_types/transaction_duration_rule_type/index.tsx @@ -15,7 +15,7 @@ import { ForLastExpression, TIME_UNITS } from '@kbn/triggers-actions-ui-plugin/p import { EuiFormRow } from '@elastic/eui'; import { EuiSpacer } from '@elastic/eui'; import { EuiSwitchEvent } from '@elastic/eui'; -import { SearchConfigurationType } from '../../../../../common/rules/schema'; +import { SearchConfigurationType } from '@kbn/response-ops-rule-params/common'; import { AggregationType } from '../../../../../common/rules/apm_rule_types'; import { ENVIRONMENT_ALL } from '../../../../../common/environment_filter_values'; import { getDurationFormatter } from '../../../../../common/utils/formatters'; diff --git a/x-pack/solutions/observability/plugins/apm/public/components/alerting/rule_types/transaction_error_rate_rule_type/index.tsx b/x-pack/solutions/observability/plugins/apm/public/components/alerting/rule_types/transaction_error_rate_rule_type/index.tsx index 35a64ed9d8c2a..c2202a6e49e61 100644 --- a/x-pack/solutions/observability/plugins/apm/public/components/alerting/rule_types/transaction_error_rate_rule_type/index.tsx +++ b/x-pack/solutions/observability/plugins/apm/public/components/alerting/rule_types/transaction_error_rate_rule_type/index.tsx @@ -14,7 +14,7 @@ import { ForLastExpression, TIME_UNITS } from '@kbn/triggers-actions-ui-plugin/p import { EuiFormRow } from '@elastic/eui'; import { EuiSpacer } from '@elastic/eui'; import { EuiSwitchEvent } from '@elastic/eui'; -import { SearchConfigurationType } from '../../../../../common/rules/schema'; +import { SearchConfigurationType } from '@kbn/response-ops-rule-params/common'; import { ENVIRONMENT_ALL } from '../../../../../common/environment_filter_values'; import { asPercent } from '../../../../../common/utils/formatters'; import { FETCH_STATUS, isPending, useFetcher } from '../../../../hooks/use_fetcher'; diff --git a/x-pack/solutions/observability/plugins/apm/server/routes/alerts/rule_types/anomaly/register_anomaly_rule_type.ts b/x-pack/solutions/observability/plugins/apm/server/routes/alerts/rule_types/anomaly/register_anomaly_rule_type.ts index 531b5c9558a56..6d2c6745ffe4c 100644 --- a/x-pack/solutions/observability/plugins/apm/server/routes/alerts/rule_types/anomaly/register_anomaly_rule_type.ts +++ b/x-pack/solutions/observability/plugins/apm/server/routes/alerts/rule_types/anomaly/register_anomaly_rule_type.ts @@ -35,6 +35,7 @@ import { ObservabilityApmAlert } from '@kbn/alerts-as-data-utils'; import { addSpaceIdToPath } from '@kbn/spaces-plugin/common'; import { asyncForEach } from '@kbn/std'; import { compact } from 'lodash'; +import { anomalyParamsSchema } from '@kbn/response-ops-rule-params/apm_anomaly'; import { getSeverity } from '../../../../../common/anomaly_detection'; import { PROCESSOR_EVENT, @@ -52,6 +53,7 @@ import { formatAnomalyReason, RULE_TYPES_CONFIG, THRESHOLD_MET_GROUP, + ApmRuleParamsType, } from '../../../../../common/rules/apm_rule_types'; import { asMutableArray } from '../../../../../common/utils/as_mutable_array'; import { getAlertUrlTransaction } from '../../../../../common/utils/formatters'; @@ -62,7 +64,6 @@ import { RegisterRuleDependencies, } from '../../register_apm_rule_types'; import { getServiceGroupFieldsForAnomaly } from './get_service_group_fields_for_anomaly'; -import { anomalyParamsSchema, ApmRuleParamsType } from '../../../../../common/rules/schema'; import { getAnomalyDetectorIndex, getAnomalyDetectorType, diff --git a/x-pack/solutions/observability/plugins/apm/server/routes/alerts/rule_types/error_count/register_error_count_rule_type.ts b/x-pack/solutions/observability/plugins/apm/server/routes/alerts/rule_types/error_count/register_error_count_rule_type.ts index 8fb4000645a2e..a330017e52579 100644 --- a/x-pack/solutions/observability/plugins/apm/server/routes/alerts/rule_types/error_count/register_error_count_rule_type.ts +++ b/x-pack/solutions/observability/plugins/apm/server/routes/alerts/rule_types/error_count/register_error_count_rule_type.ts @@ -32,6 +32,7 @@ import { ObservabilityApmAlert } from '@kbn/alerts-as-data-utils'; import { getParsedFilterQuery, termQuery } from '@kbn/observability-plugin/server'; import { addSpaceIdToPath } from '@kbn/spaces-plugin/common'; import { asyncForEach } from '@kbn/std'; +import { errorCountParamsSchema } from '@kbn/response-ops-rule-params/error_count'; import { getEnvironmentEsField } from '../../../../../common/environment_filter_values'; import { ERROR_GROUP_ID, @@ -44,8 +45,8 @@ import { formatErrorCountReason, RULE_TYPES_CONFIG, THRESHOLD_MET_GROUP, + ApmRuleParamsType, } from '../../../../../common/rules/apm_rule_types'; -import { errorCountParamsSchema, ApmRuleParamsType } from '../../../../../common/rules/schema'; import { environmentQuery } from '../../../../../common/utils/environment_query'; import { getAlertUrlErrorCount } from '../../../../../common/utils/formatters'; import { apmActionVariables } from '../../action_variables'; diff --git a/x-pack/solutions/observability/plugins/apm/server/routes/alerts/rule_types/transaction_duration/register_transaction_duration_rule_type.ts b/x-pack/solutions/observability/plugins/apm/server/routes/alerts/rule_types/transaction_duration/register_transaction_duration_rule_type.ts index dfc32ec9eb54e..407fc7af21513 100644 --- a/x-pack/solutions/observability/plugins/apm/server/routes/alerts/rule_types/transaction_duration/register_transaction_duration_rule_type.ts +++ b/x-pack/solutions/observability/plugins/apm/server/routes/alerts/rule_types/transaction_duration/register_transaction_duration_rule_type.ts @@ -33,6 +33,7 @@ import { } from '@kbn/rule-data-utils'; import { ObservabilityApmAlert } from '@kbn/alerts-as-data-utils'; import { addSpaceIdToPath } from '@kbn/spaces-plugin/common'; +import { transactionDurationParamsSchema } from '@kbn/response-ops-rule-params/transaction_duration'; import { getGroupByTerms } from '../utils/get_groupby_terms'; import { SearchAggregatedTransactionSetting } from '../../../../../common/aggregated_transactions'; import { getEnvironmentEsField } from '../../../../../common/environment_filter_values'; @@ -48,11 +49,8 @@ import { formatTransactionDurationReason, RULE_TYPES_CONFIG, THRESHOLD_MET_GROUP, -} from '../../../../../common/rules/apm_rule_types'; -import { - transactionDurationParamsSchema, ApmRuleParamsType, -} from '../../../../../common/rules/schema'; +} from '../../../../../common/rules/apm_rule_types'; import { environmentQuery } from '../../../../../common/utils/environment_query'; import { getAlertUrlTransaction, diff --git a/x-pack/solutions/observability/plugins/apm/server/routes/alerts/rule_types/transaction_error_rate/register_transaction_error_rate_rule_type.ts b/x-pack/solutions/observability/plugins/apm/server/routes/alerts/rule_types/transaction_error_rate/register_transaction_error_rate_rule_type.ts index 1090a1c91d54b..bbece95a79e4b 100644 --- a/x-pack/solutions/observability/plugins/apm/server/routes/alerts/rule_types/transaction_error_rate/register_transaction_error_rate_rule_type.ts +++ b/x-pack/solutions/observability/plugins/apm/server/routes/alerts/rule_types/transaction_error_rate/register_transaction_error_rate_rule_type.ts @@ -33,6 +33,7 @@ import { import { ObservabilityApmAlert } from '@kbn/alerts-as-data-utils'; import { addSpaceIdToPath } from '@kbn/spaces-plugin/common'; import { asyncForEach } from '@kbn/std'; +import { transactionErrorRateParamsSchema } from '@kbn/response-ops-rule-params/transaction_error_rate'; import { SearchAggregatedTransactionSetting } from '../../../../../common/aggregated_transactions'; import { getEnvironmentEsField } from '../../../../../common/environment_filter_values'; import { @@ -49,11 +50,8 @@ import { formatTransactionErrorRateReason, RULE_TYPES_CONFIG, THRESHOLD_MET_GROUP, -} from '../../../../../common/rules/apm_rule_types'; -import { - transactionErrorRateParamsSchema, ApmRuleParamsType, -} from '../../../../../common/rules/schema'; +} from '../../../../../common/rules/apm_rule_types'; import { environmentQuery } from '../../../../../common/utils/environment_query'; import { asDecimalOrInteger, getAlertUrlTransaction } from '../../../../../common/utils/formatters'; import { getBackwardCompatibleDocumentTypeFilter } from '../../../../lib/helpers/transactions'; diff --git a/x-pack/solutions/observability/plugins/apm/tsconfig.json b/x-pack/solutions/observability/plugins/apm/tsconfig.json index ec766864a4e11..54f09cd0d1e43 100644 --- a/x-pack/solutions/observability/plugins/apm/tsconfig.json +++ b/x-pack/solutions/observability/plugins/apm/tsconfig.json @@ -130,6 +130,7 @@ "@kbn/saved-search-component", "@kbn/saved-search-plugin", "@kbn/entityManager-plugin", + "@kbn/response-ops-rule-params" ], "exclude": ["target/**/*"] } diff --git a/x-pack/test/api_integration/deployment_agnostic/services/alerting_api.ts b/x-pack/test/api_integration/deployment_agnostic/services/alerting_api.ts index 7a5cff10d58b1..f75f5d297c740 100644 --- a/x-pack/test/api_integration/deployment_agnostic/services/alerting_api.ts +++ b/x-pack/test/api_integration/deployment_agnostic/services/alerting_api.ts @@ -8,10 +8,10 @@ import type { AggregationsAggregate, SearchResponse } from '@elastic/elasticsearch/lib/api/types'; import { MetricThresholdParams } from '@kbn/infra-plugin/common/alerting/metrics'; import { ThresholdParams } from '@kbn/observability-plugin/common/custom_threshold_rule/types'; -import { ApmRuleParamsType } from '@kbn/apm-plugin/common/rules/schema'; import { RoleCredentials } from '@kbn/ftr-common-functional-services'; import { errors, type Client } from '@elastic/elasticsearch'; import type { TryWithRetriesOptions } from '@kbn/ftr-common-functional-services'; +import { ApmRuleParamsType } from '@kbn/apm-plugin/common/rules/apm_rule_types'; import { v4 as uuidv4 } from 'uuid'; import moment from 'moment'; import { DeploymentAgnosticFtrProviderContext } from '../ftr_provider_context'; diff --git a/x-pack/test/apm_api_integration/tests/alerts/helpers/alerting_api_helper.ts b/x-pack/test/apm_api_integration/tests/alerts/helpers/alerting_api_helper.ts index 86544981bbdb4..69d3664e38679 100644 --- a/x-pack/test/apm_api_integration/tests/alerts/helpers/alerting_api_helper.ts +++ b/x-pack/test/apm_api_integration/tests/alerts/helpers/alerting_api_helper.ts @@ -7,10 +7,11 @@ import { Client, errors } from '@elastic/elasticsearch'; import { ParsedTechnicalFields } from '@kbn/rule-registry-plugin/common'; +import { ApmRuleParamsType } from '@kbn/apm-plugin/common/rules/apm_rule_types'; import pRetry from 'p-retry'; import type { Agent as SuperTestAgent } from 'supertest'; import { ApmRuleType } from '@kbn/rule-data-utils'; -import { ApmRuleParamsType } from '@kbn/apm-plugin/common/rules/schema'; + import { ObservabilityApmAlert } from '@kbn/alerts-as-data-utils'; import { APM_ACTION_VARIABLE_INDEX, diff --git a/yarn.lock b/yarn.lock index 51c8d5dc5e55f..325fa522999cf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6831,7 +6831,7 @@ version "0.0.0" uid "" -"@kbn/response-ops-rule-params@link:src/platform/packages/private/response-ops/rule_params": +"@kbn/response-ops-rule-params@link:src/platform/packages/shared/response-ops/rule_params": version "0.0.0" uid ""