Alerting: Support recording rule struct in provisioning API (#87849)

* Support record struct in provisioning API

* Update api spec

* Use record field

* Restrict API endpoints following toggle

* Fix swagger spec

* Add recording rule validation to store validator
This commit is contained in:
William Wernert
2024-06-06 21:05:02 +03:00
committed by GitHub
parent 808cf75ff8
commit d359591dac
15 changed files with 426 additions and 202 deletions
+44 -83
View File
@@ -3731,6 +3731,9 @@
"type": "integer",
"format": "int64"
},
"record": {
"$ref": "#/definitions/AlertRuleRecordExport"
},
"title": {
"type": "string"
},
@@ -3878,6 +3881,18 @@
}
}
},
"AlertRuleRecordExport": {
"type": "object",
"title": "Record is the provisioned export of models.Record.",
"properties": {
"from": {
"type": "string"
},
"metric": {
"type": "string"
}
}
},
"AlertingFileExport": {
"type": "object",
"title": "AlertingFileExport is the full provisioned file export.",
@@ -4480,7 +4495,7 @@
}
},
"EvalQueriesResponse": {
"$ref": "#/definitions/EvalQueriesResponse"
"type": "object"
},
"ExplorePanelsState": {
"description": "This is an object constructed with the keys as the values of the enum VisType and the value being a bag of properties"
@@ -6449,6 +6464,9 @@
"provenance": {
"$ref": "#/definitions/Provenance"
},
"record": {
"$ref": "#/definitions/Record"
},
"ruleGroup": {
"type": "string",
"maxLength": 190,
@@ -6770,13 +6788,20 @@
},
"Record": {
"type": "object",
"title": "Record defines how data produced by a recording rule is written.",
"required": [
"metric",
"from"
],
"properties": {
"from": {
"type": "string"
"description": "Which expression node should be used as the input for the recorded metric.",
"type": "string",
"example": "A"
},
"metric": {
"type": "string"
"description": "Name of the recorded metric.",
"type": "string",
"example": "grafana_alerts_ratio"
}
}
},
@@ -7972,15 +7997,15 @@
"receiver": {
"$ref": "#/definitions/receiver"
}
},
"$ref": "#/definitions/alertGroup"
}
},
"alertGroups": {
"description": "AlertGroups alert groups",
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/alertGroup"
},
"$ref": "#/definitions/alertGroups"
}
},
"alertStatus": {
"description": "AlertStatus alert status",
@@ -8081,7 +8106,6 @@
}
},
"gettableAlert": {
"description": "GettableAlert gettable alert",
"type": "object",
"required": [
"labels",
@@ -8092,58 +8116,14 @@
"startsAt",
"status",
"updatedAt"
],
"properties": {
"annotations": {
"$ref": "#/definitions/labelSet"
},
"endsAt": {
"description": "ends at",
"type": "string",
"format": "date-time"
},
"fingerprint": {
"description": "fingerprint",
"type": "string"
},
"generatorURL": {
"description": "generator URL\nFormat: uri",
"type": "string",
"format": "uri"
},
"labels": {
"$ref": "#/definitions/labelSet"
},
"receivers": {
"description": "receivers",
"type": "array",
"items": {
"$ref": "#/definitions/receiver"
}
},
"startsAt": {
"description": "starts at",
"type": "string",
"format": "date-time"
},
"status": {
"$ref": "#/definitions/alertStatus"
},
"updatedAt": {
"description": "updated at",
"type": "string",
"format": "date-time"
}
},
"$ref": "#/definitions/gettableAlert"
]
},
"gettableAlerts": {
"description": "GettableAlerts gettable alerts",
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gettableAlert"
},
"$ref": "#/definitions/gettableAlerts"
}
},
"gettableSilence": {
"description": "GettableSilence gettable silence",
@@ -8192,17 +8172,17 @@
"type": "string",
"format": "date-time"
}
},
"$ref": "#/definitions/gettableSilence"
}
},
"gettableSilences": {
"type": "array",
"items": {
"type": "object",
"$ref": "#/definitions/gettableSilence"
},
"$ref": "#/definitions/gettableSilences"
}
},
"integration": {
"description": "Integration integration",
"type": "object",
"required": [
"name",
@@ -8230,8 +8210,7 @@
"description": "send resolved",
"type": "boolean"
}
},
"$ref": "#/definitions/integration"
}
},
"labelSet": {
"description": "LabelSet label set",
@@ -8347,6 +8326,7 @@
}
},
"postableSilence": {
"description": "PostableSilence postable silence",
"type": "object",
"required": [
"comment",
@@ -8381,8 +8361,7 @@
"type": "string",
"format": "date-time"
}
},
"$ref": "#/definitions/postableSilence"
}
},
"receiver": {
"type": "object",
@@ -8390,25 +8369,7 @@
"active",
"integrations",
"name"
],
"properties": {
"active": {
"description": "active",
"type": "boolean"
},
"integrations": {
"description": "integrations",
"type": "array",
"items": {
"$ref": "#/definitions/integration"
}
},
"name": {
"description": "name",
"type": "string"
}
},
"$ref": "#/definitions/receiver"
]
},
"silence": {
"description": "Silence silence",