From 98cc4b153fb884baa26cc5965fd299a8413e4f2d Mon Sep 17 00:00:00 2001 From: Antonio Date: Fri, 3 Jan 2025 13:20:03 +0100 Subject: [PATCH] [ResponseOps][Rules] Move synthetic rule types' params to @kbn/response-ops-rule-params (#204582) Connected with #195187 ## Summary - Moved params of synthetic status monitor rule type to `/response-ops/rule_params/synthetics_monitor_status/` - Moved params of TLS rule type to `/response-ops/rule_params/synthetics_tls/` I created a follow-up issue to handle the places where io-ts is used for params validation in `observability/plugins/synthetics`. #205207 --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com> --- .github/CODEOWNERS | 2 +- .../synthetics_monitor_status/index.ts | 20 +++++ .../synthetics_monitor_status/latest.ts | 10 +++ .../synthetics_monitor_status/v1.ts | 76 +++++++++++++++++++ .../rule_params/synthetics_tls/index.ts | 14 ++++ .../rule_params/synthetics_tls/latest.ts | 10 +++ .../rule_params/synthetics_tls/v1.ts | 23 ++++++ .../plugins/shared/alerting/tsconfig.json | 4 +- .../synthetics/common/rules/status_rule.ts | 64 +--------------- .../common/runtime_types/alerts/tls.ts | 3 +- .../common/condition_locations_value.tsx | 2 +- .../alerts/common/condition_window_value.tsx | 3 +- .../alerts/common/for_the_last_expression.tsx | 3 +- .../components/alerts/status_rule_ui.tsx | 2 +- .../components/alerts/tls_rule_ui.tsx | 6 +- .../lazy_wrapper/monitor_status.tsx | 2 +- .../alert_types/lazy_wrapper/tls_alert.tsx | 6 +- .../lib/alert_types/monitor_status.tsx | 2 +- .../apps/synthetics/lib/alert_types/tls.tsx | 4 +- .../synthetics/server/alert_rules/common.ts | 5 +- .../alert_rules/status_rule/message_utils.ts | 3 +- .../status_rule/monitor_status_rule.ts | 4 +- .../status_rule/queries/filter_monitors.ts | 2 +- .../status_rule/status_rule_executor.ts | 3 +- .../server/alert_rules/status_rule/types.ts | 2 +- .../server/alert_rules/tls_rule/tls_rule.ts | 15 ++-- .../alert_rules/tls_rule/tls_rule_executor.ts | 6 +- .../plugins/synthetics/tsconfig.json | 3 +- .../synthetics/custom_status_rule.ts | 2 +- .../synthetics/synthetics_rule_helper.ts | 2 +- x-pack/test/tsconfig.json | 3 +- 31 files changed, 204 insertions(+), 102 deletions(-) create mode 100644 src/platform/packages/shared/response-ops/rule_params/synthetics_monitor_status/index.ts create mode 100644 src/platform/packages/shared/response-ops/rule_params/synthetics_monitor_status/latest.ts create mode 100644 src/platform/packages/shared/response-ops/rule_params/synthetics_monitor_status/v1.ts create mode 100644 src/platform/packages/shared/response-ops/rule_params/synthetics_tls/index.ts create mode 100644 src/platform/packages/shared/response-ops/rule_params/synthetics_tls/latest.ts create mode 100644 src/platform/packages/shared/response-ops/rule_params/synthetics_tls/v1.ts diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index b5968d2e05157..7e9f694892399 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -2865,7 +2865,6 @@ src/platform/packages/private/kbn-ui-shared-deps-npm @elastic/kibana-operations src/platform/packages/private/kbn-ui-shared-deps-src @elastic/kibana-operations src/platform/packages/private/kbn-unsaved-changes-badge @elastic/kibana-data-discovery src/platform/packages/private/react/kibana_context/root @elastic/appex-sharedux -src/platform/packages/private/response-ops/rule_params @elastic/response-ops src/platform/packages/private/serverless/project_switcher @elastic/appex-sharedux src/platform/packages/private/serverless/settings/common @elastic/appex-sharedux @elastic/kibana-management src/platform/packages/private/serverless/types @elastic/appex-sharedux @@ -3062,6 +3061,7 @@ src/platform/packages/shared/shared-ux/prompt/no_data_views/types @elastic/appex src/platform/packages/shared/shared-ux/prompt/not_found @elastic/appex-sharedux src/platform/packages/shared/shared-ux/router/impl @elastic/appex-sharedux src/platform/packages/shared/shared-ux/storybook/mock @elastic/appex-sharedux +src/platform/packages/shared/response-ops/rule_params @elastic/response-ops src/platform/plugins/private/advanced_settings @elastic/appex-sharedux @elastic/kibana-management src/platform/plugins/private/event_annotation @elastic/kibana-visualizations src/platform/plugins/private/event_annotation_listing @elastic/kibana-visualizations diff --git a/src/platform/packages/shared/response-ops/rule_params/synthetics_monitor_status/index.ts b/src/platform/packages/shared/response-ops/rule_params/synthetics_monitor_status/index.ts new file mode 100644 index 0000000000000..6d88868f33633 --- /dev/null +++ b/src/platform/packages/shared/response-ops/rule_params/synthetics_monitor_status/index.ts @@ -0,0 +1,20 @@ +/* + * 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 { syntheticsMonitorStatusRuleParamsSchema } from './latest'; +export { syntheticsMonitorStatusRuleParamsSchema as syntheticsMonitorStatusRuleParamsSchemaV1 } from './v1'; + +export type { SyntheticsMonitorStatusRuleParams } from './latest'; +export type { SyntheticsMonitorStatusRuleParams as SyntheticsMonitorStatusRuleParamsV1 } from './v1'; + +export type { TimeWindow } from './latest'; +export type { TimeWindow as TimeWindowV1 } from './v1'; + +export type { StatusRuleCondition } from './latest'; +export type { StatusRuleCondition as StatusRuleConditionV1 } from './v1'; diff --git a/src/platform/packages/shared/response-ops/rule_params/synthetics_monitor_status/latest.ts b/src/platform/packages/shared/response-ops/rule_params/synthetics_monitor_status/latest.ts new file mode 100644 index 0000000000000..f278309c22b03 --- /dev/null +++ b/src/platform/packages/shared/response-ops/rule_params/synthetics_monitor_status/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/synthetics_monitor_status/v1.ts b/src/platform/packages/shared/response-ops/rule_params/synthetics_monitor_status/v1.ts new file mode 100644 index 0000000000000..b2356b2630455 --- /dev/null +++ b/src/platform/packages/shared/response-ops/rule_params/synthetics_monitor_status/v1.ts @@ -0,0 +1,76 @@ +/* + * 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'; + +const TimeWindowSchema = schema.object({ + unit: schema.oneOf( + [schema.literal('s'), schema.literal('m'), schema.literal('h'), schema.literal('d')], + { + defaultValue: 'm', + } + ), + size: schema.number({ + defaultValue: 5, + }), +}); + +const NumberOfChecksSchema = schema.object({ + numberOfChecks: schema.number({ + defaultValue: 5, + min: 1, + max: 100, + }), +}); + +const StatusRuleConditionSchema = schema.object({ + groupBy: schema.maybe( + schema.string({ + defaultValue: 'locationId', + }) + ), + downThreshold: schema.maybe( + schema.number({ + defaultValue: 3, + }) + ), + locationsThreshold: schema.maybe( + schema.number({ + defaultValue: 1, + }) + ), + window: schema.oneOf([ + schema.object({ + time: TimeWindowSchema, + }), + NumberOfChecksSchema, + ]), + includeRetests: schema.maybe(schema.boolean()), +}); + +export const syntheticsMonitorStatusRuleParamsSchema = schema.object( + { + condition: schema.maybe(StatusRuleConditionSchema), + monitorIds: schema.maybe(schema.arrayOf(schema.string())), + locations: schema.maybe(schema.arrayOf(schema.string())), + tags: schema.maybe(schema.arrayOf(schema.string())), + monitorTypes: schema.maybe(schema.arrayOf(schema.string())), + projects: schema.maybe(schema.arrayOf(schema.string())), + kqlQuery: schema.maybe(schema.string()), + }, + { + meta: { description: 'The parameters for the rule.' }, + } +); + +export type SyntheticsMonitorStatusRuleParams = TypeOf< + typeof syntheticsMonitorStatusRuleParamsSchema +>; +export type TimeWindow = TypeOf; +export type StatusRuleCondition = TypeOf; diff --git a/src/platform/packages/shared/response-ops/rule_params/synthetics_tls/index.ts b/src/platform/packages/shared/response-ops/rule_params/synthetics_tls/index.ts new file mode 100644 index 0000000000000..49f3fb4669f30 --- /dev/null +++ b/src/platform/packages/shared/response-ops/rule_params/synthetics_tls/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 { tlsRuleParamsSchema } from './latest'; +export { tlsRuleParamsSchema as tlsRuleParamsSchemaV1 } from './v1'; + +export type { TLSRuleParams } from './latest'; +export type { TLSRuleParams as TLSRuleParamsV1 } from './v1'; diff --git a/src/platform/packages/shared/response-ops/rule_params/synthetics_tls/latest.ts b/src/platform/packages/shared/response-ops/rule_params/synthetics_tls/latest.ts new file mode 100644 index 0000000000000..f278309c22b03 --- /dev/null +++ b/src/platform/packages/shared/response-ops/rule_params/synthetics_tls/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/synthetics_tls/v1.ts b/src/platform/packages/shared/response-ops/rule_params/synthetics_tls/v1.ts new file mode 100644 index 0000000000000..6bf7c0ffbd744 --- /dev/null +++ b/src/platform/packages/shared/response-ops/rule_params/synthetics_tls/v1.ts @@ -0,0 +1,23 @@ +/* + * 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 tlsRuleParamsSchema = schema.object( + { + search: schema.maybe(schema.string()), + certExpirationThreshold: schema.maybe(schema.number()), + certAgeThreshold: schema.maybe(schema.number()), + }, + { + meta: { description: 'The parameters for the rule.' }, + } +); + +export type TLSRuleParams = TypeOf; diff --git a/x-pack/platform/plugins/shared/alerting/tsconfig.json b/x-pack/platform/plugins/shared/alerting/tsconfig.json index 274cb8dde4527..a73c99e39fd96 100644 --- a/x-pack/platform/plugins/shared/alerting/tsconfig.json +++ b/x-pack/platform/plugins/shared/alerting/tsconfig.json @@ -75,8 +75,8 @@ "@kbn/zod", "@kbn/core-saved-objects-base-server-internal", "@kbn/core-security-server-mocks", - "@kbn/response-ops-rule-params", - "@kbn/core-http-server-utils" + "@kbn/core-http-server-utils", + "@kbn/response-ops-rule-params" ], "exclude": [ "target/**/*" diff --git a/x-pack/solutions/observability/plugins/synthetics/common/rules/status_rule.ts b/x-pack/solutions/observability/plugins/synthetics/common/rules/status_rule.ts index 584888353cbc4..d18d8acc9ae21 100644 --- a/x-pack/solutions/observability/plugins/synthetics/common/rules/status_rule.ts +++ b/x-pack/solutions/observability/plugins/synthetics/common/rules/status_rule.ts @@ -5,68 +5,12 @@ * 2.0. */ -import { schema, TypeOf } from '@kbn/config-schema'; +import { + StatusRuleCondition, + TimeWindow, +} from '@kbn/response-ops-rule-params/synthetics_monitor_status'; import { isEmpty } from 'lodash'; -export const TimeWindowSchema = schema.object({ - unit: schema.oneOf( - [schema.literal('s'), schema.literal('m'), schema.literal('h'), schema.literal('d')], - { - defaultValue: 'm', - } - ), - size: schema.number({ - defaultValue: 5, - }), -}); - -export const NumberOfChecksSchema = schema.object({ - numberOfChecks: schema.number({ - defaultValue: 5, - min: 1, - max: 100, - }), -}); - -export const StatusRuleConditionSchema = schema.object({ - groupBy: schema.maybe( - schema.string({ - defaultValue: 'locationId', - }) - ), - downThreshold: schema.maybe( - schema.number({ - defaultValue: 3, - }) - ), - locationsThreshold: schema.maybe( - schema.number({ - defaultValue: 1, - }) - ), - window: schema.oneOf([ - schema.object({ - time: TimeWindowSchema, - }), - NumberOfChecksSchema, - ]), - includeRetests: schema.maybe(schema.boolean()), -}); - -export const StatusRulePramsSchema = schema.object({ - condition: schema.maybe(StatusRuleConditionSchema), - monitorIds: schema.maybe(schema.arrayOf(schema.string())), - locations: schema.maybe(schema.arrayOf(schema.string())), - tags: schema.maybe(schema.arrayOf(schema.string())), - monitorTypes: schema.maybe(schema.arrayOf(schema.string())), - projects: schema.maybe(schema.arrayOf(schema.string())), - kqlQuery: schema.maybe(schema.string()), -}); - -export type TimeWindow = TypeOf; -export type StatusRuleParams = TypeOf; -export type StatusRuleCondition = TypeOf; - export const getConditionType = (condition?: StatusRuleCondition) => { let numberOfChecks = 1; let timeWindow: TimeWindow = { unit: 'm', size: 1 }; diff --git a/x-pack/solutions/observability/plugins/synthetics/common/runtime_types/alerts/tls.ts b/x-pack/solutions/observability/plugins/synthetics/common/runtime_types/alerts/tls.ts index 564485d44f239..05a5e7e1f4c7d 100644 --- a/x-pack/solutions/observability/plugins/synthetics/common/runtime_types/alerts/tls.ts +++ b/x-pack/solutions/observability/plugins/synthetics/common/runtime_types/alerts/tls.ts @@ -7,10 +7,9 @@ import * as t from 'io-ts'; +// This should be replaced by TLSParams from @kbn/response-ops-rule-params export const TLSParamsType = t.partial({ search: t.string, certAgeThreshold: t.number, certExpirationThreshold: t.number, }); - -export type TLSParams = t.TypeOf; diff --git a/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/alerts/common/condition_locations_value.tsx b/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/alerts/common/condition_locations_value.tsx index 7b5babfd38786..6896302252bd2 100644 --- a/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/alerts/common/condition_locations_value.tsx +++ b/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/alerts/common/condition_locations_value.tsx @@ -8,7 +8,7 @@ import React, { useCallback } from 'react'; import { i18n } from '@kbn/i18n'; import { EuiFieldNumber, EuiPopoverTitle } from '@elastic/eui'; -import { StatusRuleCondition } from '../../../../../../common/rules/status_rule'; +import { StatusRuleCondition } from '@kbn/response-ops-rule-params/synthetics_monitor_status'; import { PopoverExpression } from './popover_expression'; import { StatusRuleParamsProps } from '../status_rule_ui'; diff --git a/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/alerts/common/condition_window_value.tsx b/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/alerts/common/condition_window_value.tsx index 717a15f9da4f2..768c4007eac3e 100644 --- a/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/alerts/common/condition_window_value.tsx +++ b/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/alerts/common/condition_window_value.tsx @@ -9,8 +9,9 @@ import { ForLastExpression, TIME_UNITS } from '@kbn/triggers-actions-ui-plugin/p import React, { useCallback } from 'react'; import { i18n } from '@kbn/i18n'; import { EuiFieldNumber, EuiPopoverTitle } from '@elastic/eui'; +import { TimeWindow } from '@kbn/response-ops-rule-params/synthetics_monitor_status'; import { PopoverExpression } from './popover_expression'; -import { getConditionType, TimeWindow } from '../../../../../../common/rules/status_rule'; +import { getConditionType } from '../../../../../../common/rules/status_rule'; import { StatusRuleParamsProps } from '../status_rule_ui'; interface Props { diff --git a/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/alerts/common/for_the_last_expression.tsx b/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/alerts/common/for_the_last_expression.tsx index 81153d88be61d..c9402a10e1e56 100644 --- a/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/alerts/common/for_the_last_expression.tsx +++ b/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/alerts/common/for_the_last_expression.tsx @@ -7,7 +7,8 @@ import { EuiExpression, EuiPopover, EuiPopoverTitle, EuiSelectable } from '@elastic/eui'; import React, { useEffect, useState } from 'react'; import { i18n } from '@kbn/i18n'; -import { getConditionType, StatusRuleCondition } from '../../../../../../common/rules/status_rule'; +import { StatusRuleCondition } from '@kbn/response-ops-rule-params/synthetics_monitor_status'; +import { getConditionType } from '../../../../../../common/rules/status_rule'; import { StatusRuleParamsProps } from '../status_rule_ui'; interface Props { diff --git a/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/alerts/status_rule_ui.tsx b/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/alerts/status_rule_ui.tsx index 70278c8951773..218f4942c3c36 100644 --- a/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/alerts/status_rule_ui.tsx +++ b/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/alerts/status_rule_ui.tsx @@ -9,10 +9,10 @@ import React, { useCallback } from 'react'; import { RuleTypeParamsExpressionProps } from '@kbn/triggers-actions-ui-plugin/public'; import { Filter } from '@kbn/es-query'; import { EuiSpacer } from '@elastic/eui'; +import { SyntheticsMonitorStatusRuleParams as StatusRuleParams } from '@kbn/response-ops-rule-params/synthetics_monitor_status'; import { FieldFilters } from './common/field_filters'; import { AlertSearchBar } from './query_bar'; import { StatusRuleExpression } from './status_rule_expression'; -import { StatusRuleParams } from '../../../../../common/rules/status_rule'; export type StatusRuleParamsProps = RuleTypeParamsExpressionProps; diff --git a/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/alerts/tls_rule_ui.tsx b/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/alerts/tls_rule_ui.tsx index eb97a0d5f3962..ecfa5187cd94a 100644 --- a/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/alerts/tls_rule_ui.tsx +++ b/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/components/alerts/tls_rule_ui.tsx @@ -8,14 +8,14 @@ import { useDispatch, useSelector } from 'react-redux'; import React, { useEffect } from 'react'; import { RuleTypeParamsExpressionProps } from '@kbn/triggers-actions-ui-plugin/public'; +import type { TLSRuleParams } from '@kbn/response-ops-rule-params/synthetics_tls'; import { AlertTlsComponent } from './alert_tls'; import { getDynamicSettingsAction, selectDynamicSettings } from '../../state/settings'; -import { TLSParams } from '../../../../../common/runtime_types/alerts/tls'; import { DYNAMIC_SETTINGS_DEFAULTS } from '../../../../../common/constants'; export const TLSRuleComponent: React.FC<{ - ruleParams: RuleTypeParamsExpressionProps['ruleParams']; - setRuleParams: RuleTypeParamsExpressionProps['setRuleParams']; + ruleParams: RuleTypeParamsExpressionProps['ruleParams']; + setRuleParams: RuleTypeParamsExpressionProps['setRuleParams']; }> = ({ ruleParams, setRuleParams }) => { const dispatch = useDispatch(); diff --git a/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/lib/alert_types/lazy_wrapper/monitor_status.tsx b/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/lib/alert_types/lazy_wrapper/monitor_status.tsx index 0fc0bf738963c..5e95c32eff608 100644 --- a/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/lib/alert_types/lazy_wrapper/monitor_status.tsx +++ b/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/lib/alert_types/lazy_wrapper/monitor_status.tsx @@ -14,11 +14,11 @@ import { RuleTypeParamsExpressionProps } from '@kbn/triggers-actions-ui-plugin/p import { EuiSpacer, EuiText } from '@elastic/eui'; import { FormattedMessage } from '@kbn/i18n-react'; import { isEmpty } from 'lodash'; +import { SyntheticsMonitorStatusRuleParams as StatusRuleParams } from '@kbn/response-ops-rule-params/synthetics_monitor_status'; import { StatusRuleComponent } from '../../../components/alerts/status_rule_ui'; import { kibanaService } from '../../../../../utils/kibana_service'; import { ClientPluginsStart } from '../../../../../plugin'; import { store } from '../../../state'; -import type { StatusRuleParams } from '../../../../../../common/rules/status_rule'; interface Props { coreStart: CoreStart; diff --git a/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/lib/alert_types/lazy_wrapper/tls_alert.tsx b/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/lib/alert_types/lazy_wrapper/tls_alert.tsx index 5c3f3a7c6bc31..96633a4e8321e 100644 --- a/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/lib/alert_types/lazy_wrapper/tls_alert.tsx +++ b/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/lib/alert_types/lazy_wrapper/tls_alert.tsx @@ -10,17 +10,17 @@ import { Provider as ReduxProvider } from 'react-redux'; import { CoreStart } from '@kbn/core/public'; import { KibanaContextProvider } from '@kbn/kibana-react-plugin/public'; import type { RuleTypeParamsExpressionProps } from '@kbn/triggers-actions-ui-plugin/public'; +import type { TLSRuleParams } from '@kbn/response-ops-rule-params/synthetics_tls'; import { TLSRuleComponent } from '../../../components/alerts/tls_rule_ui'; import { ClientPluginsStart } from '../../../../../plugin'; -import { TLSParams } from '../../../../../../common/runtime_types/alerts/tls'; import { kibanaService } from '../../../../../utils/kibana_service'; import { store } from '../../../state'; interface Props { coreStart: CoreStart; plugins: ClientPluginsStart; - ruleParams: RuleTypeParamsExpressionProps['ruleParams']; - setRuleParams: RuleTypeParamsExpressionProps['setRuleParams']; + ruleParams: RuleTypeParamsExpressionProps['ruleParams']; + setRuleParams: RuleTypeParamsExpressionProps['setRuleParams']; } // eslint-disable-next-line import/no-default-export diff --git a/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/lib/alert_types/monitor_status.tsx b/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/lib/alert_types/monitor_status.tsx index 7c8824a8d56c9..e5b13163b311b 100644 --- a/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/lib/alert_types/monitor_status.tsx +++ b/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/lib/alert_types/monitor_status.tsx @@ -11,10 +11,10 @@ import { ALERT_REASON, SYNTHETICS_ALERT_RULE_TYPES } from '@kbn/rule-data-utils' import type { ObservabilityRuleTypeModel } from '@kbn/observability-plugin/public'; import type { RuleTypeParamsExpressionProps } from '@kbn/triggers-actions-ui-plugin/public'; +import { SyntheticsMonitorStatusRuleParams as StatusRuleParams } from '@kbn/response-ops-rule-params/synthetics_monitor_status'; import { getSyntheticsErrorRouteFromMonitorId } from '../../../../../common/utils/get_synthetics_monitor_url'; import { STATE_ID } from '../../../../../common/field_names'; import { SyntheticsMonitorStatusTranslations } from '../../../../../common/rules/synthetics/translations'; -import type { StatusRuleParams } from '../../../../../common/rules/status_rule'; import type { AlertTypeInitializer } from './types'; const { defaultActionMessage, defaultRecoveryMessage, description } = diff --git a/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/lib/alert_types/tls.tsx b/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/lib/alert_types/tls.tsx index 10c45ece27a9f..00a08355d431b 100644 --- a/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/lib/alert_types/tls.tsx +++ b/x-pack/solutions/observability/plugins/synthetics/public/apps/synthetics/lib/alert_types/tls.tsx @@ -10,9 +10,9 @@ import { ALERT_REASON, SYNTHETICS_ALERT_RULE_TYPES } from '@kbn/rule-data-utils' import { ObservabilityRuleTypeModel } from '@kbn/observability-plugin/public'; import type { RuleTypeParamsExpressionProps } from '@kbn/triggers-actions-ui-plugin/public'; import { ValidationResult } from '@kbn/triggers-actions-ui-plugin/public'; +import type { TLSRuleParams } from '@kbn/response-ops-rule-params/synthetics_tls'; import { TlsTranslations } from '../../../../../common/rules/synthetics/translations'; import { CERTIFICATES_ROUTE } from '../../../../../common/constants/ui'; -import type { TLSParams } from '../../../../../common/runtime_types/alerts/tls'; import type { AlertTypeInitializer } from './types'; @@ -30,7 +30,7 @@ export const initTlsAlertType: AlertTypeInitializer = ({ documentationUrl(docLinks) { return `${docLinks.links.observability.syntheticsAlerting}`; }, - ruleParamsExpression: (params: RuleTypeParamsExpressionProps) => ( + ruleParamsExpression: (params: RuleTypeParamsExpressionProps) => ( ; type TLSRuleTypeState = SyntheticsCommonState; type TLSAlertState = ReturnType; @@ -53,11 +54,7 @@ export const registerSyntheticsTLSCheckRule = ( producer: 'uptime', name: TLS_CERTIFICATE.name, validate: { - params: schema.object({ - search: schema.maybe(schema.string()), - certExpirationThreshold: schema.maybe(schema.number()), - certAgeThreshold: schema.maybe(schema.number()), - }), + params: tlsRuleParamsSchema, }, defaultActionGroupId: TLS_CERTIFICATE.id, actionGroups: [TLS_CERTIFICATE], @@ -67,7 +64,7 @@ export const registerSyntheticsTLSCheckRule = ( doesSetRecoveryContext: true, executor: async ( options: RuleExecutorOptions< - TLSRuleTypeParams, + TLSRuleParams, TLSRuleTypeState, TLSAlertState, TLSAlertContext, diff --git a/x-pack/solutions/observability/plugins/synthetics/server/alert_rules/tls_rule/tls_rule_executor.ts b/x-pack/solutions/observability/plugins/synthetics/server/alert_rules/tls_rule/tls_rule_executor.ts index 2ed465257d0c6..b04729492483d 100644 --- a/x-pack/solutions/observability/plugins/synthetics/server/alert_rules/tls_rule/tls_rule_executor.ts +++ b/x-pack/solutions/observability/plugins/synthetics/server/alert_rules/tls_rule/tls_rule_executor.ts @@ -10,12 +10,12 @@ import { } from '@kbn/core-saved-objects-api-server'; import { ElasticsearchClient } from '@kbn/core-elasticsearch-server'; import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types'; +import type { TLSRuleParams } from '@kbn/response-ops-rule-params/synthetics_tls'; import moment from 'moment'; import { FINAL_SUMMARY_FILTER } from '../../../common/constants/client_defaults'; import { formatFilterString } from '../common'; import { SyntheticsServerSetup } from '../../types'; import { getSyntheticsCerts } from '../../queries/get_certs'; -import { TLSParams } from '../../../common/runtime_types/alerts/tls'; import { savedObjectsAdapter } from '../../saved_objects'; import { DYNAMIC_SETTINGS_DEFAULTS, SYNTHETICS_INDEX_PATTERN } from '../../../common/constants'; import { @@ -35,7 +35,7 @@ import { SyntheticsEsClient } from '../../lib'; export class TLSRuleExecutor { previousStartedAt: Date | null; - params: TLSParams; + params: TLSRuleParams; esClient: SyntheticsEsClient; soClient: SavedObjectsClientContract; server: SyntheticsServerSetup; @@ -44,7 +44,7 @@ export class TLSRuleExecutor { constructor( previousStartedAt: Date | null, - p: TLSParams, + p: TLSRuleParams, soClient: SavedObjectsClientContract, scopedClient: ElasticsearchClient, server: SyntheticsServerSetup, diff --git a/x-pack/solutions/observability/plugins/synthetics/tsconfig.json b/x-pack/solutions/observability/plugins/synthetics/tsconfig.json index 6ce7da00a3457..fef7efd29865d 100644 --- a/x-pack/solutions/observability/plugins/synthetics/tsconfig.json +++ b/x-pack/solutions/observability/plugins/synthetics/tsconfig.json @@ -107,7 +107,8 @@ "@kbn/index-lifecycle-management-common-shared", "@kbn/core-http-server-utils", "@kbn/apm-data-access-plugin", - "@kbn/charts-theme" + "@kbn/charts-theme", + "@kbn/response-ops-rule-params" ], "exclude": ["target/**/*"] } diff --git a/x-pack/test/alerting_api_integration/observability/synthetics/custom_status_rule.ts b/x-pack/test/alerting_api_integration/observability/synthetics/custom_status_rule.ts index 218b40c6be845..6a63f969bd8c9 100644 --- a/x-pack/test/alerting_api_integration/observability/synthetics/custom_status_rule.ts +++ b/x-pack/test/alerting_api_integration/observability/synthetics/custom_status_rule.ts @@ -7,7 +7,7 @@ import expect from '@kbn/expect'; import moment from 'moment'; import { SYNTHETICS_API_URLS } from '@kbn/synthetics-plugin/common/constants'; -import { StatusRuleParams } from '@kbn/synthetics-plugin/common/rules/status_rule'; +import { SyntheticsMonitorStatusRuleParams as StatusRuleParams } from '@kbn/response-ops-rule-params/synthetics_monitor_status'; import { FtrProviderContext } from '../../common/ftr_provider_context'; import { SyntheticsRuleHelper, SYNTHETICS_ALERT_ACTION_INDEX } from './synthetics_rule_helper'; import { waitForDocumentInIndex } from '../helpers/alerting_wait_for_helpers'; diff --git a/x-pack/test/alerting_api_integration/observability/synthetics/synthetics_rule_helper.ts b/x-pack/test/alerting_api_integration/observability/synthetics/synthetics_rule_helper.ts index a2da1c849945f..50d54fa834939 100644 --- a/x-pack/test/alerting_api_integration/observability/synthetics/synthetics_rule_helper.ts +++ b/x-pack/test/alerting_api_integration/observability/synthetics/synthetics_rule_helper.ts @@ -5,7 +5,7 @@ * 2.0. */ -import { StatusRuleParams } from '@kbn/synthetics-plugin/common/rules/status_rule'; +import { SyntheticsMonitorStatusRuleParams as StatusRuleParams } from '@kbn/response-ops-rule-params/synthetics_monitor_status'; import type { Client } from '@elastic/elasticsearch'; import { ToolingLog } from '@kbn/tooling-log'; import { makeDownSummary, makeUpSummary } from '@kbn/observability-synthetics-test-data'; diff --git a/x-pack/test/tsconfig.json b/x-pack/test/tsconfig.json index 2dd261262a697..0a555d2258483 100644 --- a/x-pack/test/tsconfig.json +++ b/x-pack/test/tsconfig.json @@ -190,6 +190,7 @@ "@kbn/gen-ai-functional-testing", "@kbn/integration-assistant-plugin", "@kbn/core-elasticsearch-server", - "@kbn/streams-schema" + "@kbn/streams-schema", + "@kbn/response-ops-rule-params" ] }