From 3ccafe3a5af8fc2a1539dad16277f210b4de7219 Mon Sep 17 00:00:00 2001 From: Alex Moreno Date: Fri, 27 Jan 2023 10:50:06 +0100 Subject: [PATCH] Alerting: Add is_paused attr to the POST alert rule group endpoint (#62253) Add is_paused attr to the POST alert rule group endpoint --- pkg/services/ngalert/api/api_ruler_validation.go | 1 + pkg/services/ngalert/api/tooling/api.json | 4 +++- .../ngalert/api/tooling/definitions/cortex-ruler.go | 1 + pkg/services/ngalert/api/tooling/post.json | 8 ++++++-- pkg/services/ngalert/api/tooling/spec.json | 9 ++++++--- public/api-merged.json | 4 +++- 6 files changed, 20 insertions(+), 7 deletions(-) diff --git a/pkg/services/ngalert/api/api_ruler_validation.go b/pkg/services/ngalert/api/api_ruler_validation.go index a8f86eee6ab..60c01732631 100644 --- a/pkg/services/ngalert/api/api_ruler_validation.go +++ b/pkg/services/ngalert/api/api_ruler_validation.go @@ -97,6 +97,7 @@ func validateRuleNode( RuleGroup: groupName, NoDataState: noDataState, ExecErrState: errorState, + IsPaused: ruleNode.GrafanaManagedAlert.IsPaused, } newAlertRule.For, err = validateForInterval(ruleNode) diff --git a/pkg/services/ngalert/api/tooling/api.json b/pkg/services/ngalert/api/tooling/api.json index 86cd1cc9299..41a5eb5e903 100644 --- a/pkg/services/ngalert/api/tooling/api.json +++ b/pkg/services/ngalert/api/tooling/api.json @@ -2005,6 +2005,9 @@ ], "type": "string" }, + "is_paused": { + "type": "boolean" + }, "no_data_state": { "enum": [ "Alerting", @@ -3495,7 +3498,6 @@ "type": "object" }, "gettableAlert": { - "description": "GettableAlert gettable alert", "properties": { "annotations": { "$ref": "#/definitions/labelSet" diff --git a/pkg/services/ngalert/api/tooling/definitions/cortex-ruler.go b/pkg/services/ngalert/api/tooling/definitions/cortex-ruler.go index 4acab8ab44d..f93e9d4cc3b 100644 --- a/pkg/services/ngalert/api/tooling/definitions/cortex-ruler.go +++ b/pkg/services/ngalert/api/tooling/definitions/cortex-ruler.go @@ -374,6 +374,7 @@ type PostableGrafanaRule struct { UID string `json:"uid" yaml:"uid"` NoDataState NoDataState `json:"no_data_state" yaml:"no_data_state"` ExecErrState ExecutionErrorState `json:"exec_err_state" yaml:"exec_err_state"` + IsPaused bool `json:"is_paused" yaml:"is_paused"` } // swagger:model diff --git a/pkg/services/ngalert/api/tooling/post.json b/pkg/services/ngalert/api/tooling/post.json index ce003de9465..0604354ec23 100644 --- a/pkg/services/ngalert/api/tooling/post.json +++ b/pkg/services/ngalert/api/tooling/post.json @@ -2005,6 +2005,9 @@ ], "type": "string" }, + "is_paused": { + "type": "boolean" + }, "no_data_state": { "enum": [ "Alerting", @@ -3155,6 +3158,7 @@ "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" @@ -3190,7 +3194,7 @@ "$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" }, "Userinfo": { @@ -3496,7 +3500,6 @@ "type": "object" }, "gettableAlert": { - "description": "GettableAlert gettable alert", "properties": { "annotations": { "$ref": "#/definitions/labelSet" @@ -3606,6 +3609,7 @@ "type": "object" }, "gettableSilences": { + "description": "GettableSilences gettable silences", "items": { "$ref": "#/definitions/gettableSilence" }, diff --git a/pkg/services/ngalert/api/tooling/spec.json b/pkg/services/ngalert/api/tooling/spec.json index ce7a76b2117..4e0e3f16423 100644 --- a/pkg/services/ngalert/api/tooling/spec.json +++ b/pkg/services/ngalert/api/tooling/spec.json @@ -4501,6 +4501,9 @@ "Error" ] }, + "is_paused": { + "type": "boolean" + }, "no_data_state": { "type": "string", "enum": [ @@ -5887,7 +5890,6 @@ "$ref": "#/definitions/alertGroup" }, "alertGroups": { - "description": "AlertGroups alert groups", "type": "array", "items": { "$ref": "#/definitions/alertGroup" @@ -5993,7 +5995,6 @@ } }, "gettableAlert": { - "description": "GettableAlert gettable alert", "type": "object", "required": [ "labels", @@ -6050,6 +6051,7 @@ "$ref": "#/definitions/gettableAlert" }, "gettableAlerts": { + "description": "GettableAlerts gettable alerts", "type": "array", "items": { "$ref": "#/definitions/gettableAlert" @@ -6057,6 +6059,7 @@ "$ref": "#/definitions/gettableAlerts" }, "gettableSilence": { + "description": "GettableSilence gettable silence", "type": "object", "required": [ "comment", @@ -6106,6 +6109,7 @@ "$ref": "#/definitions/gettableSilence" }, "gettableSilences": { + "description": "GettableSilences gettable silences", "type": "array", "items": { "$ref": "#/definitions/gettableSilence" @@ -6296,7 +6300,6 @@ "$ref": "#/definitions/postableSilence" }, "receiver": { - "description": "Receiver receiver", "type": "object", "required": [ "active", diff --git a/public/api-merged.json b/public/api-merged.json index 8f18508d55e..9192ca1c1c3 100644 --- a/public/api-merged.json +++ b/public/api-merged.json @@ -15561,6 +15561,9 @@ "Error" ] }, + "is_paused": { + "type": "boolean" + }, "no_data_state": { "type": "string", "enum": [ @@ -18796,7 +18799,6 @@ } }, "gettableAlert": { - "description": "GettableAlert gettable alert", "type": "object", "required": [ "labels",