Alerting: Add recording rules to ruler API and validation (#87779)

* Read path, main API

* Define record field for incoming requests

* Refactor several alerting specific validators into two paths

* Refactor validateCondition actually contain all the condition validation logic

* Move condition validation inside rule path

* Validators for recording rules

* Wire feature flag through to validators

* Test for accepting a valid recording rule

* Tests for negative case, no UID

* Test for ignoring alerting fields

* Build conditions based on recording rules as well

* Regenerate swagger docs

* Fix CRUD test to cover the right thing

* Re-generate swagger docs with backdated v0.30.2 version

* Regenerate base spec

* Regenerate ngalert specs

* Regenerate top level specs

* Comment and rename

* Return struct instead of modifying ref
This commit is contained in:
Alexander Weaver
2024-05-21 14:39:28 -05:00
committed by GitHub
parent fa319f36fb
commit 49c8deb1ea
12 changed files with 399 additions and 75 deletions
+22 -3
View File
@@ -1573,6 +1573,9 @@
"provenance": {
"$ref": "#/definitions/Provenance"
},
"record": {
"$ref": "#/definitions/Record"
},
"rule_group": {
"type": "string"
},
@@ -2730,6 +2733,9 @@
"notification_settings": {
"$ref": "#/definitions/AlertRuleNotificationSettings"
},
"record": {
"$ref": "#/definitions/Record"
},
"title": {
"type": "string"
},
@@ -3247,6 +3253,18 @@
"title": "ReceiverExport is the provisioned file export of alerting.ReceiverV1.",
"type": "object"
},
"Record": {
"properties": {
"from": {
"type": "string"
},
"metric": {
"type": "string"
}
},
"title": "Record defines how data produced by a recording rule is written.",
"type": "object"
},
"RelativeTimeRange": {
"description": "RelativeTimeRange is the per query start and end time\nfor requests.",
"properties": {
@@ -4417,6 +4435,7 @@
"type": "object"
},
"alertGroup": {
"description": "AlertGroup alert group",
"properties": {
"alerts": {
"description": "alerts",
@@ -4545,7 +4564,6 @@
"type": "object"
},
"gettableAlert": {
"description": "GettableAlert gettable alert",
"properties": {
"annotations": {
"$ref": "#/definitions/labelSet"
@@ -4601,6 +4619,7 @@
"type": "object"
},
"gettableAlerts": {
"description": "GettableAlerts gettable alerts",
"items": {
"$ref": "#/definitions/gettableAlert"
},
@@ -4655,13 +4674,13 @@
"type": "object"
},
"gettableSilences": {
"description": "GettableSilences gettable silences",
"items": {
"$ref": "#/definitions/gettableSilence"
},
"type": "array"
},
"integration": {
"description": "Integration integration",
"properties": {
"lastNotifyAttempt": {
"description": "A timestamp indicating the last attempt to deliver a notification regardless of the outcome.\nFormat: date-time",
@@ -4805,7 +4824,6 @@
"type": "array"
},
"postableSilence": {
"description": "PostableSilence postable silence",
"properties": {
"comment": {
"description": "comment",
@@ -4843,6 +4861,7 @@
"type": "object"
},
"receiver": {
"description": "Receiver receiver",
"properties": {
"active": {
"description": "active",