Alerting: Provisioning API - Alert rules (#47930) (#50086)

(cherry picked from commit 81d360529b)

Co-authored-by: Jean-Philippe Quéméner <JohnnyQQQQ@users.noreply.github.com>
This commit is contained in:
Grot (@grafanabot)
2022-06-02 15:05:57 +02:00
committed by GitHub
co-authored by Jean-Philippe Quéméner
parent 1c870e9908
commit b342fe6e30
22 changed files with 1295 additions and 126 deletions
+282 -16
View File
@@ -194,6 +194,91 @@
"type": "object",
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"AlertRule": {
"properties": {
"annotations": {
"additionalProperties": {
"type": "string"
},
"type": "object",
"x-go-name": "Annotations"
},
"condition": {
"type": "string",
"x-go-name": "Condition"
},
"data": {
"items": {
"$ref": "#/definitions/AlertQuery"
},
"type": "array",
"x-go-name": "Data"
},
"execErrState": {
"$ref": "#/definitions/ExecutionErrorState"
},
"folderUID": {
"type": "string",
"x-go-name": "FolderUID"
},
"for": {
"$ref": "#/definitions/Duration"
},
"id": {
"format": "int64",
"type": "integer",
"x-go-name": "ID"
},
"labels": {
"additionalProperties": {
"type": "string"
},
"type": "object",
"x-go-name": "Labels"
},
"noDataState": {
"$ref": "#/definitions/NoDataState"
},
"orgID": {
"format": "int64",
"type": "integer",
"x-go-name": "OrgID"
},
"provenance": {
"$ref": "#/definitions/Provenance"
},
"ruleGroup": {
"type": "string",
"x-go-name": "RuleGroup"
},
"title": {
"type": "string",
"x-go-name": "Title"
},
"uid": {
"type": "string",
"x-go-name": "UID"
},
"updated": {
"format": "date-time",
"type": "string",
"x-go-name": "Updated"
}
},
"type": "object",
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"AlertRuleGroup": {
"properties": {
"interval": {
"format": "int64",
"type": "integer",
"x-go-name": "Interval"
}
},
"type": "object",
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"AlertingRule": {
"description": "adapted from cortex",
"properties": {
@@ -663,6 +748,10 @@
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"EvalQueriesResponse": {},
"ExecutionErrorState": {
"type": "string",
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/models"
},
"ExtendedReceiver": {
"properties": {
"email_configs": {
@@ -1456,6 +1545,10 @@
"type": "object",
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"NoDataState": {
"type": "string",
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/models"
},
"NotFound": {
"type": "object",
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
@@ -2923,6 +3016,7 @@
"x-go-package": "github.com/prometheus/alertmanager/timeinterval"
},
"URL": {
"description": "The general form represented is:\n\n[scheme:][//[userinfo@]host][/]path[?query][#fragment]\n\nURLs that do not start with a slash after the scheme are interpreted as:\n\nscheme:opaque[?query][#fragment]\n\nNote that the Path field is stored in decoded form: /%47%6f%2f becomes /Go/.\nA consequence is that it is impossible to tell which slashes in the Path were\nslashes in the raw URL and which were %2f. This distinction is rarely important,\nbut when it is, the code should use RawPath, an optional field which only gets\nset if the default encoding is different from Path.\n\nURL's String method uses the EscapedPath method to obtain the path. See the\nEscapedPath method for more details.",
"properties": {
"ForceQuery": {
"type": "boolean"
@@ -2955,9 +3049,9 @@
"$ref": "#/definitions/Userinfo"
}
},
"title": "URL is a custom URL type that allows validation at configuration load time.",
"title": "A URL represents a parsed URL (technically, a URI reference).",
"type": "object",
"x-go-package": "github.com/prometheus/common/config"
"x-go-package": "net/url"
},
"Userinfo": {
"description": "The Userinfo type is an immutable encapsulation of username and\npassword details for a URL. An existing Userinfo value is guaranteed\nto have a username set (potentially empty, as allowed by RFC 2396),\nand optionally a password.",
@@ -3179,12 +3273,11 @@
"type": "object"
},
"alertGroups": {
"description": "AlertGroups alert groups",
"items": {
"$ref": "#/definitions/alertGroup"
},
"type": "array",
"x-go-name": "AlertGroups",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
"type": "array"
},
"alertStatus": {
"description": "AlertStatus alert status",
@@ -3304,6 +3397,7 @@
"$ref": "#/definitions/Duration"
},
"gettableAlert": {
"description": "GettableAlert gettable alert",
"properties": {
"annotations": {
"$ref": "#/definitions/labelSet"
@@ -3362,9 +3456,7 @@
"status",
"updatedAt"
],
"type": "object",
"x-go-name": "GettableAlert",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
"type": "object"
},
"gettableAlerts": {
"description": "GettableAlerts gettable alerts",
@@ -3374,7 +3466,6 @@
"type": "array"
},
"gettableSilence": {
"description": "GettableSilence gettable silence",
"properties": {
"comment": {
"description": "comment",
@@ -3426,7 +3517,9 @@
"status",
"updatedAt"
],
"type": "object"
"type": "object",
"x-go-name": "GettableSilence",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
},
"gettableSilences": {
"items": {
@@ -3563,6 +3656,7 @@
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
},
"postableSilence": {
"description": "PostableSilence postable silence",
"properties": {
"comment": {
"description": "comment",
@@ -3602,11 +3696,10 @@
"matchers",
"startsAt"
],
"type": "object",
"x-go-name": "PostableSilence",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
"type": "object"
},
"receiver": {
"description": "Receiver receiver",
"properties": {
"name": {
"description": "name",
@@ -3617,9 +3710,7 @@
"required": [
"name"
],
"type": "object",
"x-go-name": "Receiver",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
"type": "object"
},
"silence": {
"description": "Silence silence",
@@ -4838,6 +4929,134 @@
]
}
},
"/api/provisioning/alert-rules": {
"post": {
"operationId": "RoutePostAlertRule",
"parameters": [
{
"in": "body",
"name": "Body",
"schema": {
"$ref": "#/definitions/AlertRule"
}
}
],
"responses": {
"201": {
"description": "AlertRule",
"schema": {
"$ref": "#/definitions/AlertRule"
}
},
"400": {
"description": "ValidationError",
"schema": {
"$ref": "#/definitions/ValidationError"
}
}
},
"summary": "Create a new alert rule.",
"tags": [
"provisioning"
]
}
},
"/api/provisioning/alert-rules/{UID}": {
"delete": {
"operationId": "RouteDeleteAlertRule",
"parameters": [
{
"in": "path",
"name": "UID",
"required": true,
"type": "string"
}
],
"responses": {
"204": {
"description": " The alert rule was deleted successfully."
},
"400": {
"description": "ValidationError",
"schema": {
"$ref": "#/definitions/ValidationError"
}
}
},
"summary": "Delete a specific alert rule by UID.",
"tags": [
"provisioning"
]
},
"get": {
"operationId": "RouteGetAlertRule",
"parameters": [
{
"in": "path",
"name": "UID",
"required": true,
"type": "string"
}
],
"responses": {
"200": {
"description": "AlertRule",
"schema": {
"$ref": "#/definitions/AlertRule"
}
},
"400": {
"description": "ValidationError",
"schema": {
"$ref": "#/definitions/ValidationError"
}
}
},
"summary": "Get a specific alert rule by UID.",
"tags": [
"provisioning"
]
},
"put": {
"consumes": [
"application/json"
],
"operationId": "RoutePutAlertRule",
"parameters": [
{
"in": "path",
"name": "UID",
"required": true,
"type": "string"
},
{
"in": "body",
"name": "Body",
"schema": {
"$ref": "#/definitions/AlertRule"
}
}
],
"responses": {
"200": {
"description": "AlertRule",
"schema": {
"$ref": "#/definitions/AlertRule"
}
},
"400": {
"description": "ValidationError",
"schema": {
"$ref": "#/definitions/ValidationError"
}
}
},
"summary": "Update an existing alert rule.",
"tags": [
"provisioning"
]
}
},
"/api/provisioning/contact-points": {
"get": {
"operationId": "RouteGetContactpoints",
@@ -4969,6 +5188,53 @@
]
}
},
"/api/provisioning/folder/{FolderUID}/rule-groups/{Group}": {
"put": {
"consumes": [
"application/json"
],
"operationId": "RoutePutAlertRuleGroup",
"parameters": [
{
"in": "path",
"name": "FolderUID",
"required": true,
"type": "string"
},
{
"in": "path",
"name": "Group",
"required": true,
"type": "string"
},
{
"in": "body",
"name": "Body",
"schema": {
"$ref": "#/definitions/AlertRuleGroup"
}
}
],
"responses": {
"200": {
"description": "AlertRuleGroup",
"schema": {
"$ref": "#/definitions/AlertRuleGroup"
}
},
"400": {
"description": "ValidationError",
"schema": {
"$ref": "#/definitions/ValidationError"
}
}
},
"summary": "Update the interval of an rule group.",
"tags": [
"provisioning"
]
}
},
"/api/provisioning/mute-timings": {
"get": {
"operationId": "RouteGetMuteTimings",