Skip to content

Commit c9365db

Browse files
Allow packages which have format_version < 3.5.0 to ship alert rule templates (#1012)
This allows Integrations to ship templates without bumping format_version explicitly. The impact of this is that packages can still support installation on 8.19.x (where templates are ignored), whilst also providing templates for users on stack versions that support them. It leaves the decision about format_version up to Integration developers, which ends up being a trade off between stack support for the package and clarity for users about what features and functionality the package provides.
1 parent aa681b1 commit c9365db

File tree

15 files changed

+108
-1
lines changed

15 files changed

+108
-1
lines changed

code/go/pkg/validator/validator_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ func TestValidateFile(t *testing.T) {
3737
"good_input_otel": {},
3838
"good_content": {},
3939
"good_lookup_index": {},
40+
"good_alert_rule_templates": {},
4041
"deploy_custom_agent": {},
4142
"deploy_custom_agent_multi_services": {},
4243
"deploy_docker": {},
@@ -412,6 +413,11 @@ func TestValidateItemNotAllowed(t *testing.T) {
412413
"file.txt",
413414
},
414415
},
416+
"bad_alert_rule_templates": {
417+
"kibana": []string{
418+
"alerting_rule_template",
419+
},
420+
},
415421
}
416422

417423
for pkgName, invalidItemsPerFolder := range tests {

spec/changelog.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
link: https://github.com/elastic/package-spec/pull/999
1818
- version: 3.5.3-next
1919
changes:
20+
- description: Make support for alert rule templates more permissive.
21+
type: enhancement
22+
link: https://github.com/elastic/package-spec/pull/1012
2023
- description: Allow to define the message field in an array in the remove procesor for event.original.
2124
type: enhancement
2225
link: https://github.com/elastic/package-spec/pull/1013

spec/integration/kibana/spec.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ versions:
150150
patch:
151151
- op: remove
152152
path: "/contents/13" # remove SLO definitions
153-
- before: 3.5.0
153+
- before: 3.4.0
154154
patch:
155155
- op: remove
156156
path: "/contents/13" # remove alerting rule template definitions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Bad alert rule templates
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# newer versions go on top
2+
- version: "1.0.0"
3+
changes:
4+
- description: Initial draft of the package
5+
type: enhancement
6+
link: https://github.com/elastic/integrations/pull/1 # FIXME Replace with the real PR link
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Bad alert rule templates
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"id": "some-rule",
3+
"type": "alerting_rule_template",
4+
"attributes": {
5+
"name": "[Something] Some rule",
6+
"ruleTypeId": ".es-query",
7+
"schedule": {
8+
"interval": "1m"
9+
},
10+
"params": {
11+
"searchType": "esqlQuery",
12+
"timeWindowSize": 5,
13+
"timeWindowUnit": "m",
14+
"esqlQuery": {
15+
"esql": "FROM metrics-something-default | STATS max=MAX(some_field) by some_dimension | WHERE max > 100"
16+
},
17+
"groupBy": "row",
18+
"timeField": "@timestamp"
19+
}
20+
},
21+
"managed": true,
22+
"coreMigrationVersion": "8.8.0",
23+
"typeMigrationVersion": "10.1.0"
24+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
format_version: 3.3.0
2+
name: bad_alert_rule_templates
3+
title: "Bad Alert Rule Templates"
4+
version: 1.0.0
5+
description: "This package contains alerting rule templates with an unsupported 'format_version'."
6+
type: integration
7+
conditions:
8+
kibana:
9+
version: "^8.18.0"
10+
elastic:
11+
subscription: "basic"
12+
owner:
13+
github: elastic/integrations
14+
type: elastic
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"description": "This is an example sample-event for Bad Alert Rule Templates. Replace it with a real sample event. Hint: If system tests exist, running `elastic-package test system --generate` will generate this file."
3+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Good alert rule templates

0 commit comments

Comments
 (0)