Alerting: Add provisioning endpoint to fetch all rules (#59989)
* Domain layer api for fetching all rules * Add endpoint for getting all rules
This commit is contained in:
@@ -2164,6 +2164,12 @@
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"ProvisionedAlertRules": {
|
||||
"items": {
|
||||
"$ref": "#/definitions/ProvisionedAlertRule"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"PushoverConfig": {
|
||||
"properties": {
|
||||
"expire": {
|
||||
@@ -3077,7 +3083,6 @@
|
||||
"type": "object"
|
||||
},
|
||||
"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"
|
||||
@@ -3088,6 +3093,9 @@
|
||||
"Host": {
|
||||
"type": "string"
|
||||
},
|
||||
"OmitHost": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"Opaque": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -3110,7 +3118,7 @@
|
||||
"$ref": "#/definitions/Userinfo"
|
||||
}
|
||||
},
|
||||
"title": "A URL represents a parsed URL (technically, a URI reference).",
|
||||
"title": "URL is a custom URL type that allows validation at configuration load time.",
|
||||
"type": "object"
|
||||
},
|
||||
"Userinfo": {
|
||||
@@ -3395,6 +3403,7 @@
|
||||
"type": "object"
|
||||
},
|
||||
"gettableAlert": {
|
||||
"description": "GettableAlert gettable alert",
|
||||
"properties": {
|
||||
"annotations": {
|
||||
"$ref": "#/definitions/labelSet"
|
||||
@@ -3513,7 +3522,6 @@
|
||||
"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",
|
||||
@@ -3657,7 +3665,6 @@
|
||||
"type": "array"
|
||||
},
|
||||
"postableSilence": {
|
||||
"description": "PostableSilence postable silence",
|
||||
"properties": {
|
||||
"comment": {
|
||||
"description": "comment",
|
||||
@@ -3815,6 +3822,21 @@
|
||||
},
|
||||
"paths": {
|
||||
"/api/v1/provisioning/alert-rules": {
|
||||
"get": {
|
||||
"operationId": "RouteGetAlertRules",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "ProvisionedAlertRules",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/ProvisionedAlertRules"
|
||||
}
|
||||
}
|
||||
},
|
||||
"summary": "Get all the alert rules.",
|
||||
"tags": [
|
||||
"provisioning"
|
||||
]
|
||||
},
|
||||
"post": {
|
||||
"consumes": [
|
||||
"application/json"
|
||||
|
||||
@@ -7,6 +7,13 @@ import (
|
||||
"github.com/prometheus/common/model"
|
||||
)
|
||||
|
||||
// swagger:route GET /api/v1/provisioning/alert-rules provisioning stable RouteGetAlertRules
|
||||
//
|
||||
// Get all the alert rules.
|
||||
//
|
||||
// Responses:
|
||||
// 200: ProvisionedAlertRules
|
||||
|
||||
// swagger:route GET /api/v1/provisioning/alert-rules/{UID} provisioning stable RouteGetAlertRule
|
||||
//
|
||||
// Get a specific alert rule by UID.
|
||||
@@ -63,6 +70,9 @@ type AlertRuleHeaders struct {
|
||||
XDisableProvenance string `json:"X-Disable-Provenance"`
|
||||
}
|
||||
|
||||
// swagger:model
|
||||
type ProvisionedAlertRules []ProvisionedAlertRule
|
||||
|
||||
type ProvisionedAlertRule struct {
|
||||
ID int64 `json:"id"`
|
||||
UID string `json:"uid"`
|
||||
@@ -142,6 +152,14 @@ func NewAlertRule(rule models.AlertRule, provenance models.Provenance) Provision
|
||||
}
|
||||
}
|
||||
|
||||
func NewAlertRules(rules []*models.AlertRule) ProvisionedAlertRules {
|
||||
result := make([]ProvisionedAlertRule, 0, len(rules))
|
||||
for _, r := range rules {
|
||||
result = append(result, NewAlertRule(*r, models.ProvenanceNone))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
// swagger:route GET /api/v1/provisioning/folder/{FolderUID}/rule-groups/{Group} provisioning stable RouteGetAlertRuleGroup
|
||||
//
|
||||
// Get a rule group.
|
||||
|
||||
@@ -2164,6 +2164,12 @@
|
||||
],
|
||||
"type": "object"
|
||||
},
|
||||
"ProvisionedAlertRules": {
|
||||
"items": {
|
||||
"$ref": "#/definitions/ProvisionedAlertRule"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"PushoverConfig": {
|
||||
"properties": {
|
||||
"expire": {
|
||||
@@ -3077,7 +3083,6 @@
|
||||
"type": "object"
|
||||
},
|
||||
"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"
|
||||
@@ -3088,6 +3093,9 @@
|
||||
"Host": {
|
||||
"type": "string"
|
||||
},
|
||||
"OmitHost": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"Opaque": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -3110,7 +3118,7 @@
|
||||
"$ref": "#/definitions/Userinfo"
|
||||
}
|
||||
},
|
||||
"title": "A URL represents a parsed URL (technically, a URI reference).",
|
||||
"title": "URL is a custom URL type that allows validation at configuration load time.",
|
||||
"type": "object"
|
||||
},
|
||||
"Userinfo": {
|
||||
@@ -3266,7 +3274,6 @@
|
||||
"type": "object"
|
||||
},
|
||||
"alertGroup": {
|
||||
"description": "AlertGroup alert group",
|
||||
"properties": {
|
||||
"alerts": {
|
||||
"description": "alerts",
|
||||
@@ -3456,7 +3463,6 @@
|
||||
"type": "array"
|
||||
},
|
||||
"gettableSilence": {
|
||||
"description": "GettableSilence gettable silence",
|
||||
"properties": {
|
||||
"comment": {
|
||||
"description": "comment",
|
||||
@@ -3511,6 +3517,7 @@
|
||||
"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",
|
||||
@@ -3654,7 +3661,6 @@
|
||||
"type": "array"
|
||||
},
|
||||
"postableSilence": {
|
||||
"description": "PostableSilence postable silence",
|
||||
"properties": {
|
||||
"comment": {
|
||||
"description": "comment",
|
||||
@@ -5485,6 +5491,21 @@
|
||||
}
|
||||
},
|
||||
"/api/v1/provisioning/alert-rules": {
|
||||
"get": {
|
||||
"operationId": "RouteGetAlertRules",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "ProvisionedAlertRules",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/ProvisionedAlertRules"
|
||||
}
|
||||
}
|
||||
},
|
||||
"summary": "Get all the alert rules.",
|
||||
"tags": [
|
||||
"provisioning"
|
||||
]
|
||||
},
|
||||
"post": {
|
||||
"consumes": [
|
||||
"application/json"
|
||||
|
||||
@@ -1690,6 +1690,22 @@
|
||||
}
|
||||
},
|
||||
"/api/v1/provisioning/alert-rules": {
|
||||
"get": {
|
||||
"tags": [
|
||||
"provisioning",
|
||||
"stable"
|
||||
],
|
||||
"summary": "Get all the alert rules.",
|
||||
"operationId": "RouteGetAlertRules",
|
||||
"responses": {
|
||||
"200": {
|
||||
"description": "ProvisionedAlertRules",
|
||||
"schema": {
|
||||
"$ref": "#/definitions/ProvisionedAlertRules"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"post": {
|
||||
"consumes": [
|
||||
"application/json"
|
||||
@@ -4611,6 +4627,12 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"ProvisionedAlertRules": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"$ref": "#/definitions/ProvisionedAlertRule"
|
||||
}
|
||||
},
|
||||
"PushoverConfig": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -5524,9 +5546,8 @@
|
||||
}
|
||||
},
|
||||
"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.",
|
||||
"type": "object",
|
||||
"title": "A URL represents a parsed URL (technically, a URI reference).",
|
||||
"title": "URL is a custom URL type that allows validation at configuration load time.",
|
||||
"properties": {
|
||||
"ForceQuery": {
|
||||
"type": "boolean"
|
||||
@@ -5537,6 +5558,9 @@
|
||||
"Host": {
|
||||
"type": "string"
|
||||
},
|
||||
"OmitHost": {
|
||||
"type": "boolean"
|
||||
},
|
||||
"Opaque": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -5713,7 +5737,6 @@
|
||||
}
|
||||
},
|
||||
"alertGroup": {
|
||||
"description": "AlertGroup alert group",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"alerts",
|
||||
@@ -5907,7 +5930,6 @@
|
||||
"$ref": "#/definitions/gettableAlerts"
|
||||
},
|
||||
"gettableSilence": {
|
||||
"description": "GettableSilence gettable silence",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"comment",
|
||||
@@ -5964,6 +5986,7 @@
|
||||
"$ref": "#/definitions/gettableSilences"
|
||||
},
|
||||
"integration": {
|
||||
"description": "Integration integration",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"name",
|
||||
@@ -6108,7 +6131,6 @@
|
||||
}
|
||||
},
|
||||
"postableSilence": {
|
||||
"description": "PostableSilence postable silence",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"comment",
|
||||
|
||||
Reference in New Issue
Block a user