mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 01:38:56 -04:00
[ResponseOps][Rules]Move uptime rule params to package (#205238)
Connected with #195187 ## Summary - Moved params of duration anomaly rule type to `/response-ops/rule_params/uptime_duration_anomaly/` - Moved params of monitor status rule type to `/response-ops/rule_params/uptime_monitor_status/` - Moved params of TLS rule type to `/response-ops/rule_params/uptime_tls/` - **Did not move anything related to the legacy TLS rule type.** I ran into a similar issue to #205207 for the monitor status rule type. It doesn't block this PR but some follow up work might be needed for `x-pack/solutions/observability/plugins/uptime/public/legacy_uptime/lib/alert_types/lazy_wrapper/validate_monitor_status.ts`. We will probably decide after the new year. --------- Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
98cc4b153f
commit
c8d46ee949
13 changed files with 169 additions and 53 deletions
|
@ -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 { uptimeDurationAnomalyRuleParamsSchema } from './latest';
|
||||
export { uptimeDurationAnomalyRuleParamsSchema as uptimeDurationAnomalyRuleParamsSchemaV1 } from './v1';
|
||||
|
||||
export type { UptimeDurationAnomalyRuleParams } from './latest';
|
||||
export type { UptimeDurationAnomalyRuleParams as UptimeDurationAnomalyRuleParamsV1 } from './v1';
|
|
@ -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';
|
|
@ -0,0 +1,18 @@
|
|||
/*
|
||||
* 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 uptimeDurationAnomalyRuleParamsSchema = schema.object({
|
||||
stackVersion: schema.maybe(schema.string()),
|
||||
monitorId: schema.string(),
|
||||
severity: schema.number(),
|
||||
});
|
||||
|
||||
export type UptimeDurationAnomalyRuleParams = TypeOf<typeof uptimeDurationAnomalyRuleParamsSchema>;
|
|
@ -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 { uptimeMonitorStatusRuleParamsSchema } from './latest';
|
||||
export { uptimeMonitorStatusRuleParamsSchema as uptimeMonitorStatusRuleParamsSchemaV1 } from './v1';
|
||||
|
||||
export type { UptimeMonitorStatusParams } from './latest';
|
||||
export type { UptimeMonitorStatusParams as UptimeMonitorStatusParamsV1 } from './v1';
|
|
@ -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';
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* 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 uptimeMonitorStatusRuleParamsSchema = schema.object({
|
||||
stackVersion: schema.maybe(schema.string()),
|
||||
availability: schema.maybe(
|
||||
schema.object({
|
||||
range: schema.number(),
|
||||
rangeUnit: schema.string(),
|
||||
threshold: schema.string(),
|
||||
})
|
||||
),
|
||||
// deprecated
|
||||
filters: schema.maybe(
|
||||
schema.oneOf([
|
||||
// deprecated
|
||||
schema.object({
|
||||
'monitor.type': schema.maybe(schema.arrayOf(schema.string())),
|
||||
'observer.geo.name': schema.maybe(schema.arrayOf(schema.string())),
|
||||
tags: schema.maybe(schema.arrayOf(schema.string())),
|
||||
'url.port': schema.maybe(schema.arrayOf(schema.string())),
|
||||
}),
|
||||
schema.string(),
|
||||
])
|
||||
),
|
||||
locations: schema.maybe(schema.arrayOf(schema.string())),
|
||||
numTimes: schema.number(),
|
||||
search: schema.maybe(schema.string()),
|
||||
shouldCheckStatus: schema.boolean(),
|
||||
shouldCheckAvailability: schema.boolean(),
|
||||
timerangeCount: schema.maybe(schema.number()),
|
||||
timerangeUnit: schema.maybe(schema.string()),
|
||||
// deprecated
|
||||
timerange: schema.maybe(
|
||||
schema.object({
|
||||
from: schema.string(),
|
||||
to: schema.string(),
|
||||
})
|
||||
),
|
||||
version: schema.maybe(schema.number()),
|
||||
isAutoGenerated: schema.maybe(schema.boolean()),
|
||||
});
|
||||
|
||||
export type UptimeMonitorStatusParams = TypeOf<typeof uptimeMonitorStatusRuleParamsSchema>;
|
|
@ -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 { uptimeTLSRuleParamsSchema } from './latest';
|
||||
export { uptimeTLSRuleParamsSchema as uptimeTLSRuleParamsSchemaV1 } from './v1';
|
||||
|
||||
export type { UptimeTLSRuleParams } from './latest';
|
||||
export type { UptimeTLSRuleParams as UptimeTLSRuleParamsV1 } from './v1';
|
|
@ -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';
|
|
@ -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 uptimeTLSRuleParamsSchema = schema.object({
|
||||
stackVersion: schema.maybe(schema.string()),
|
||||
search: schema.maybe(schema.string()),
|
||||
certExpirationThreshold: schema.maybe(schema.number()),
|
||||
certAgeThreshold: schema.maybe(schema.number()),
|
||||
});
|
||||
|
||||
export type UptimeTLSRuleParams = TypeOf<typeof uptimeTLSRuleParamsSchema>;
|
|
@ -12,7 +12,6 @@ import {
|
|||
SavedObjectsClientContract,
|
||||
DEFAULT_APP_CATEGORIES,
|
||||
} from '@kbn/core/server';
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import {
|
||||
ALERT_EVALUATION_VALUE,
|
||||
ALERT_EVALUATION_THRESHOLD,
|
||||
|
@ -21,6 +20,7 @@ import {
|
|||
import { ActionGroupIdsOf } from '@kbn/alerting-plugin/common';
|
||||
import type { MlAnomaliesTableRecord } from '@kbn/ml-anomaly-utils';
|
||||
import { getSeverityType } from '@kbn/ml-anomaly-utils';
|
||||
import { uptimeDurationAnomalyRuleParamsSchema } from '@kbn/response-ops-rule-params/uptime_duration_anomaly';
|
||||
import {
|
||||
alertsLocatorID,
|
||||
AlertsLocatorParams,
|
||||
|
@ -109,11 +109,7 @@ export const durationAnomalyAlertFactory: UptimeAlertTypeFactory<ActionGroupIds>
|
|||
producer: 'uptime',
|
||||
name: durationAnomalyTranslations.alertFactoryName,
|
||||
validate: {
|
||||
params: schema.object({
|
||||
stackVersion: schema.maybe(schema.string()),
|
||||
monitorId: schema.string(),
|
||||
severity: schema.number(),
|
||||
}),
|
||||
params: uptimeDurationAnomalyRuleParamsSchema,
|
||||
},
|
||||
defaultActionGroupId: DURATION_ANOMALY.id,
|
||||
actionGroups: [
|
||||
|
|
|
@ -10,12 +10,12 @@ import { min } from 'lodash';
|
|||
import moment from 'moment';
|
||||
|
||||
import datemath from '@kbn/datemath';
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { JsonObject } from '@kbn/utility-types';
|
||||
import { fromKueryExpression, toElasticsearchQuery } from '@kbn/es-query';
|
||||
import { ALERT_REASON } from '@kbn/rule-data-utils';
|
||||
import { ActionGroupIdsOf } from '@kbn/alerting-plugin/common';
|
||||
import { uptimeMonitorStatusRuleParamsSchema } from '@kbn/response-ops-rule-params/uptime_monitor_status';
|
||||
import {
|
||||
alertsLocatorID,
|
||||
AlertsLocatorParams,
|
||||
|
@ -294,45 +294,7 @@ export const statusCheckAlertFactory: UptimeAlertTypeFactory<ActionGroupIds> = (
|
|||
defaultMessage: 'Uptime monitor status',
|
||||
}),
|
||||
validate: {
|
||||
params: schema.object({
|
||||
stackVersion: schema.maybe(schema.string()),
|
||||
availability: schema.maybe(
|
||||
schema.object({
|
||||
range: schema.number(),
|
||||
rangeUnit: schema.string(),
|
||||
threshold: schema.string(),
|
||||
})
|
||||
),
|
||||
// deprecated
|
||||
filters: schema.maybe(
|
||||
schema.oneOf([
|
||||
// deprecated
|
||||
schema.object({
|
||||
'monitor.type': schema.maybe(schema.arrayOf(schema.string())),
|
||||
'observer.geo.name': schema.maybe(schema.arrayOf(schema.string())),
|
||||
tags: schema.maybe(schema.arrayOf(schema.string())),
|
||||
'url.port': schema.maybe(schema.arrayOf(schema.string())),
|
||||
}),
|
||||
schema.string(),
|
||||
])
|
||||
),
|
||||
locations: schema.maybe(schema.arrayOf(schema.string())),
|
||||
numTimes: schema.number(),
|
||||
search: schema.maybe(schema.string()),
|
||||
shouldCheckStatus: schema.boolean(),
|
||||
shouldCheckAvailability: schema.boolean(),
|
||||
timerangeCount: schema.maybe(schema.number()),
|
||||
timerangeUnit: schema.maybe(schema.string()),
|
||||
// deprecated
|
||||
timerange: schema.maybe(
|
||||
schema.object({
|
||||
from: schema.string(),
|
||||
to: schema.string(),
|
||||
})
|
||||
),
|
||||
version: schema.maybe(schema.number()),
|
||||
isAutoGenerated: schema.maybe(schema.boolean()),
|
||||
}),
|
||||
params: uptimeMonitorStatusRuleParamsSchema,
|
||||
},
|
||||
defaultActionGroupId: MONITOR_STATUS.id,
|
||||
actionGroups: [
|
||||
|
|
|
@ -9,7 +9,6 @@ import { DEFAULT_APP_CATEGORIES } from '@kbn/core/server';
|
|||
import { AlertsClientError, GetViewInAppRelativeUrlFnOpts } from '@kbn/alerting-plugin/server';
|
||||
import moment from 'moment';
|
||||
import { ActionGroupIdsOf } from '@kbn/alerting-plugin/common';
|
||||
import { schema } from '@kbn/config-schema';
|
||||
import {
|
||||
alertsLocatorID,
|
||||
AlertsLocatorParams,
|
||||
|
@ -20,6 +19,8 @@ import { LocatorPublic } from '@kbn/share-plugin/common';
|
|||
import { ALERT_REASON, ALERT_UUID } from '@kbn/rule-data-utils';
|
||||
import { asyncForEach } from '@kbn/std';
|
||||
import { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types';
|
||||
import { uptimeTLSRuleParamsSchema } from '@kbn/response-ops-rule-params/uptime_tls';
|
||||
|
||||
import { uptimeRuleFieldMap } from '../../../../common/rules/uptime_rule_field_map';
|
||||
import { formatFilterString } from './status_check';
|
||||
import { UptimeAlertTypeFactory } from './types';
|
||||
|
@ -123,12 +124,7 @@ export const tlsAlertFactory: UptimeAlertTypeFactory<ActionGroupIds> = (
|
|||
producer: 'uptime',
|
||||
name: tlsTranslations.alertFactoryName,
|
||||
validate: {
|
||||
params: schema.object({
|
||||
stackVersion: schema.maybe(schema.string()),
|
||||
search: schema.maybe(schema.string()),
|
||||
certExpirationThreshold: schema.maybe(schema.number()),
|
||||
certAgeThreshold: schema.maybe(schema.number()),
|
||||
}),
|
||||
params: uptimeTLSRuleParamsSchema,
|
||||
},
|
||||
defaultActionGroupId: TLS.id,
|
||||
actionGroups: [
|
||||
|
|
|
@ -79,6 +79,7 @@
|
|||
"@kbn/core-rendering-browser",
|
||||
"@kbn/charts-theme",
|
||||
"@kbn/charts-plugin",
|
||||
"@kbn/response-ops-rule-params",
|
||||
],
|
||||
"exclude": ["target/**/*"]
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue