-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Add alerting_rule_template saved object #233214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
MichelLosier
merged 15 commits into
elastic:main
from
MichelLosier:add-alerting-rule-template-so
Sep 5, 2025
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
0579b17
Add alerting_rule_template saved object definition
MichelLosier 33674ec
Have alerting_rule_template use agnostic namespaceType
MichelLosier 6737e9f
Allow alerting_rule_template to be importable and exportable
MichelLosier 0cbd1de
[CI] Auto-commit changed files from 'node scripts/check_mappings_upda…
kibanamachine b7e992f
Have alerting_rule_template be multiple-isolated
MichelLosier b91cad2
Update check_registered_types
MichelLosier 73bc61a
Add alerting_rule_template to type_registrations test
MichelLosier 31ffc24
Have alerting_rule_template derive from rawRule v6 schema
MichelLosier 9a05a06
Add getTitle impl for alerting_rule_template registration
MichelLosier 8b1a3b3
Have rule template mappings use own definitions
MichelLosier a1767c0
Remove consumer field from alerting_rule_template
MichelLosier 80e7501
Have alerting_rule_template SO hidden by default
MichelLosier 0265b3e
Remove consumer from current fields and mappings json
MichelLosier cfb0c83
[CI] Auto-commit changed files from 'node scripts/jest_integration -u…
kibanamachine f8ff7b4
Merge branch 'main' into add-alerting-rule-template-so
MichelLosier File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
19 changes: 19 additions & 0 deletions
19
...ugins/shared/alerting/server/saved_objects/model_versions/rule_template_model_versions.ts
This file contains hidden or 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,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; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import type { SavedObjectsModelVersionMap } from '@kbn/core-saved-objects-server'; | ||
| import { rawRuleTemplateSchemaV1 } from '../schemas/raw_rule_template'; | ||
|
|
||
| export const ruleTemplateModelVersions: SavedObjectsModelVersionMap = { | ||
| '1': { | ||
| changes: [], | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Question to the @elastic/kibana-core team. When we register a new SO, should we also add all fields here? |
||
| schemas: { | ||
| forwardCompatibility: rawRuleTemplateSchemaV1.extends({}, { unknowns: 'ignore' }), | ||
| create: rawRuleTemplateSchemaV1, | ||
| }, | ||
| }, | ||
| }; | ||
29 changes: 29 additions & 0 deletions
29
x-pack/platform/plugins/shared/alerting/server/saved_objects/rule_template_mappings.ts
This file contains hidden or 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,29 @@ | ||
| /* | ||
| * 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 { SavedObjectsTypeMappingDefinition } from '@kbn/core/server'; | ||
|
|
||
| export const ruleTemplateMappings: SavedObjectsTypeMappingDefinition = { | ||
| dynamic: false, | ||
| properties: { | ||
| name: { | ||
| type: 'text', | ||
| fields: { | ||
| keyword: { | ||
| type: 'keyword', | ||
| normalizer: 'lowercase', | ||
| }, | ||
| }, | ||
| }, | ||
| ruleTypeId: { | ||
| type: 'keyword', | ||
| }, | ||
| tags: { | ||
| type: 'keyword', | ||
| }, | ||
| }, | ||
| }; |
13 changes: 13 additions & 0 deletions
13
.../platform/plugins/shared/alerting/server/saved_objects/schemas/raw_rule_template/index.ts
This file contains hidden or 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,13 @@ | ||
| /* | ||
| * 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 { TypeOf } from '@kbn/config-schema'; | ||
|
|
||
| import { rawRuleTemplateSchema } from './v1'; | ||
|
|
||
| export { rawRuleTemplateSchema as rawRuleTemplateSchemaV1 }; | ||
| export type RawRuleTemplate = TypeOf<typeof rawRuleTemplateSchema>; |
20 changes: 20 additions & 0 deletions
20
x-pack/platform/plugins/shared/alerting/server/saved_objects/schemas/raw_rule_template/v1.ts
This file contains hidden or 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,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; you may not use this file except in compliance with the Elastic License | ||
| * 2.0. | ||
| */ | ||
|
|
||
| import { schema } from '@kbn/config-schema'; | ||
|
|
||
| import { rawRuleSchema } from '../raw_rule/v6'; | ||
|
|
||
| export const rawRuleTemplateSchema = schema.object({ | ||
| name: rawRuleSchema.getPropSchemas().name, | ||
| tags: rawRuleSchema.getPropSchemas().tags, | ||
| ruleTypeId: rawRuleSchema.getPropSchemas().alertTypeId, | ||
| schedule: rawRuleSchema.getPropSchemas().schedule, | ||
| flapping: rawRuleSchema.getPropSchemas().flapping, | ||
| alertDelay: rawRuleSchema.getPropSchemas().alertDelay, | ||
| params: rawRuleSchema.getPropSchemas().params, | ||
| }); |
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A note that this will make the templates available only in the space where the user installed the templates. I think this is the intended behavior, but I wanted to call out just in case.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes Fleet install kibana assets in a specific space, so with that type they should be able to install the assets in the different space they are needed.