-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* temp trying out stuff * cleanup * use experimentalFieldMap * fix experimental component template export name * clean up * remove experimental field names from kbn package * remove experimental_rule_data_field_names * fix typescript errors & cleanup * remove experimental_component_template * bring back alert rule parameters * add experimentalRuleFieldMap to apm and uptime componentTemplates * parse experimental fields * fix linter problem * parse exact fieldmap * fix linter issues * use exact combinator for the required fieldmap * pass only alert experimental fields to stop overriding already parsed alerts * remove experimental fields from observability rule type registry Co-authored-by: Kibana Machine <[email protected]>
- Loading branch information
1 parent
22a3c9c
commit 35b483f
Showing
14 changed files
with
89 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
x-pack/plugins/rule_registry/common/assets/field_maps/experimental_rule_field_map.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
/* | ||
* 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 Fields from '../../../common/technical_rule_data_field_names'; | ||
|
||
export const experimentalRuleFieldMap = { | ||
[Fields.ALERT_INSTANCE_ID]: { type: 'keyword', required: true }, | ||
[Fields.ALERT_EVALUATION_THRESHOLD]: { type: 'scaled_float', scaling_factor: 100 }, | ||
[Fields.ALERT_EVALUATION_VALUE]: { type: 'scaled_float', scaling_factor: 100 }, | ||
} as const; | ||
|
||
export type ExperimentalRuleFieldMap = typeof experimentalRuleFieldMap; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
x-pack/plugins/rule_registry/common/parse_experimental_fields.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 { isLeft } from 'fp-ts/lib/Either'; | ||
import { PathReporter } from 'io-ts/lib/PathReporter'; | ||
import { | ||
experimentalRuleFieldMap, | ||
ExperimentalRuleFieldMap, | ||
} from './assets/field_maps/experimental_rule_field_map'; | ||
|
||
import { runtimeTypeFromFieldMap } from './field_map'; | ||
|
||
const experimentalFieldRuntimeType = | ||
runtimeTypeFromFieldMap<ExperimentalRuleFieldMap>(experimentalRuleFieldMap); | ||
|
||
export const parseExperimentalFields = (input: unknown) => { | ||
const validate = experimentalFieldRuntimeType.decode(input); | ||
|
||
if (isLeft(validate)) { | ||
throw new Error(PathReporter.report(validate).join('\n')); | ||
} | ||
return experimentalFieldRuntimeType.encode(validate.right); | ||
}; | ||
|
||
export type ParsedExperimentalFields = ReturnType<typeof parseExperimentalFields>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters