Alerting: Add MissingSeriesEvalsToResolve to the APIs (#102150)
What is this feature? A follow-up for #101184, adds AlertRule.MissingSeriesEvalsToResolve to the APIs. missing_series_evals_to_resolve must be specified too and it must be > 0. POST /api/ruler/grafana/api/v1/rules/{folderUID} works in the following way: If missing_series_evals_to_resolve is not sent or null, the rule keeps its existing value If missing_series_evals_to_resolve > 0: updates to that value If missing_series_evals_to_resolve = 0: resets to default (nil). AlertRule.MissingSeriesEvalsToResolve can't be 0, so I used it to reset In the Provisioning API, the value is just set if present and > 0. Otherwise it's reset: PUT to /api/v1/provisioning/alert-rules/{UID}: If missing_series_evals_to_resolve is nil, it's reset to the default value If missing_series_evals_to_resolve > 0, it's updated
This commit is contained in:
@@ -217,6 +217,10 @@
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"missing_series_evals_to_resolve": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"noDataState": {
|
||||
"enum": [
|
||||
"Alerting",
|
||||
@@ -1630,6 +1634,10 @@
|
||||
"metadata": {
|
||||
"$ref": "#/definitions/AlertRuleMetadata"
|
||||
},
|
||||
"missing_series_evals_to_resolve": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"namespace_uid": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -2864,6 +2872,12 @@
|
||||
"metadata": {
|
||||
"$ref": "#/definitions/AlertRuleMetadata"
|
||||
},
|
||||
"missing_series_evals_to_resolve": {
|
||||
"description": "Number of consecutive evaluation intervals with no data for a dimension must pass\nbefore the alert state is considered stale and automatically resolved.\nIf set to 0, the value is reset to the default.",
|
||||
"example": 3,
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"no_data_state": {
|
||||
"enum": [
|
||||
"Alerting",
|
||||
@@ -3150,6 +3164,11 @@
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"missingSeriesEvalsToResolve": {
|
||||
"example": 2,
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"noDataState": {
|
||||
"enum": [
|
||||
"Alerting",
|
||||
@@ -4976,6 +4995,7 @@
|
||||
"type": "object"
|
||||
},
|
||||
"gettableAlerts": {
|
||||
"description": "GettableAlerts gettable alerts",
|
||||
"items": {
|
||||
"$ref": "#/definitions/gettableAlert",
|
||||
"type": "object"
|
||||
|
||||
@@ -569,28 +569,35 @@ type PostableGrafanaRule struct {
|
||||
NotificationSettings *AlertRuleNotificationSettings `json:"notification_settings" yaml:"notification_settings"`
|
||||
Record *Record `json:"record" yaml:"record"`
|
||||
Metadata *AlertRuleMetadata `json:"metadata,omitempty" yaml:"metadata,omitempty"`
|
||||
// Number of consecutive evaluation intervals with no data for a dimension must pass
|
||||
// before the alert state is considered stale and automatically resolved.
|
||||
// If set to 0, the value is reset to the default.
|
||||
// required: false
|
||||
// example: 3
|
||||
MissingSeriesEvalsToResolve *int `json:"missing_series_evals_to_resolve,omitempty" yaml:"missing_series_evals_to_resolve,omitempty"`
|
||||
}
|
||||
|
||||
// swagger:model
|
||||
type GettableGrafanaRule struct {
|
||||
Title string `json:"title" yaml:"title"`
|
||||
Condition string `json:"condition" yaml:"condition"`
|
||||
Data []AlertQuery `json:"data" yaml:"data"`
|
||||
Updated time.Time `json:"updated" yaml:"updated"`
|
||||
UpdatedBy *UserInfo `json:"updated_by" yaml:"updated_by"`
|
||||
IntervalSeconds int64 `json:"intervalSeconds" yaml:"intervalSeconds"`
|
||||
Version int64 `json:"version" yaml:"version"`
|
||||
UID string `json:"uid" yaml:"uid"`
|
||||
NamespaceUID string `json:"namespace_uid" yaml:"namespace_uid"`
|
||||
RuleGroup string `json:"rule_group" yaml:"rule_group"`
|
||||
NoDataState NoDataState `json:"no_data_state" yaml:"no_data_state"`
|
||||
ExecErrState ExecutionErrorState `json:"exec_err_state" yaml:"exec_err_state"`
|
||||
Provenance Provenance `json:"provenance,omitempty" yaml:"provenance,omitempty"`
|
||||
IsPaused bool `json:"is_paused" yaml:"is_paused"`
|
||||
NotificationSettings *AlertRuleNotificationSettings `json:"notification_settings,omitempty" yaml:"notification_settings,omitempty"`
|
||||
Record *Record `json:"record,omitempty" yaml:"record,omitempty"`
|
||||
Metadata *AlertRuleMetadata `json:"metadata,omitempty" yaml:"metadata,omitempty"`
|
||||
GUID string `json:"guid" yaml:"guid"`
|
||||
Title string `json:"title" yaml:"title"`
|
||||
Condition string `json:"condition" yaml:"condition"`
|
||||
Data []AlertQuery `json:"data" yaml:"data"`
|
||||
Updated time.Time `json:"updated" yaml:"updated"`
|
||||
UpdatedBy *UserInfo `json:"updated_by" yaml:"updated_by"`
|
||||
IntervalSeconds int64 `json:"intervalSeconds" yaml:"intervalSeconds"`
|
||||
Version int64 `json:"version" yaml:"version"`
|
||||
UID string `json:"uid" yaml:"uid"`
|
||||
NamespaceUID string `json:"namespace_uid" yaml:"namespace_uid"`
|
||||
RuleGroup string `json:"rule_group" yaml:"rule_group"`
|
||||
NoDataState NoDataState `json:"no_data_state" yaml:"no_data_state"`
|
||||
ExecErrState ExecutionErrorState `json:"exec_err_state" yaml:"exec_err_state"`
|
||||
Provenance Provenance `json:"provenance,omitempty" yaml:"provenance,omitempty"`
|
||||
IsPaused bool `json:"is_paused" yaml:"is_paused"`
|
||||
NotificationSettings *AlertRuleNotificationSettings `json:"notification_settings,omitempty" yaml:"notification_settings,omitempty"`
|
||||
Record *Record `json:"record,omitempty" yaml:"record,omitempty"`
|
||||
Metadata *AlertRuleMetadata `json:"metadata,omitempty" yaml:"metadata,omitempty"`
|
||||
GUID string `json:"guid" yaml:"guid"`
|
||||
MissingSeriesEvalsToResolve *int `json:"missing_series_evals_to_resolve,omitempty" yaml:"missing_series_evals_to_resolve,omitempty"`
|
||||
}
|
||||
|
||||
// UserInfo represents user-related information, including a unique identifier and a name.
|
||||
|
||||
@@ -173,6 +173,8 @@ type ProvisionedAlertRule struct {
|
||||
NotificationSettings *AlertRuleNotificationSettings `json:"notification_settings"`
|
||||
//example: {"metric":"grafana_alerts_ratio", "from":"A"}
|
||||
Record *Record `json:"record"`
|
||||
// example: 2
|
||||
MissingSeriesEvalsToResolve *int `json:"missingSeriesEvalsToResolve,omitempty"`
|
||||
}
|
||||
|
||||
// swagger:route GET /v1/provisioning/folder/{FolderUID}/rule-groups/{Group} provisioning stable RouteGetAlertRuleGroup
|
||||
@@ -275,13 +277,14 @@ type AlertRuleExport struct {
|
||||
// ForString and KeepFiringForString are used to:
|
||||
// - Only export the for field for HCL if it is non-zero.
|
||||
// - Format the Prometheus model.Duration type properly for HCL.
|
||||
ForString *string `json:"-" yaml:"-" hcl:"for"`
|
||||
KeepFiringForString *string `json:"-" yaml:"-" hcl:"keep_firing_for"`
|
||||
Annotations *map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty" hcl:"annotations"`
|
||||
Labels *map[string]string `json:"labels,omitempty" yaml:"labels,omitempty" hcl:"labels"`
|
||||
IsPaused bool `json:"isPaused" yaml:"isPaused" hcl:"is_paused"`
|
||||
NotificationSettings *AlertRuleNotificationSettingsExport `json:"notification_settings,omitempty" yaml:"notification_settings,omitempty" hcl:"notification_settings,block"`
|
||||
Record *AlertRuleRecordExport `json:"record,omitempty" yaml:"record,omitempty" hcl:"record,block"`
|
||||
ForString *string `json:"-" yaml:"-" hcl:"for"`
|
||||
KeepFiringForString *string `json:"-" yaml:"-" hcl:"keep_firing_for"`
|
||||
Annotations *map[string]string `json:"annotations,omitempty" yaml:"annotations,omitempty" hcl:"annotations"`
|
||||
Labels *map[string]string `json:"labels,omitempty" yaml:"labels,omitempty" hcl:"labels"`
|
||||
IsPaused bool `json:"isPaused" yaml:"isPaused" hcl:"is_paused"`
|
||||
NotificationSettings *AlertRuleNotificationSettingsExport `json:"notification_settings,omitempty" yaml:"notification_settings,omitempty" hcl:"notification_settings,block"`
|
||||
Record *AlertRuleRecordExport `json:"record,omitempty" yaml:"record,omitempty" hcl:"record,block"`
|
||||
MissingSeriesEvalsToResolve *int `json:"missing_series_evals_to_resolve,omitempty" yaml:"missing_series_evals_to_resolve,omitempty" hcl:"missing_series_evals_to_resolve"`
|
||||
}
|
||||
|
||||
// AlertQueryExport is the provisioned export of models.AlertQuery.
|
||||
|
||||
@@ -217,6 +217,10 @@
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"missing_series_evals_to_resolve": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"noDataState": {
|
||||
"enum": [
|
||||
"Alerting",
|
||||
@@ -1630,6 +1634,10 @@
|
||||
"metadata": {
|
||||
"$ref": "#/definitions/AlertRuleMetadata"
|
||||
},
|
||||
"missing_series_evals_to_resolve": {
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"namespace_uid": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -2864,6 +2872,12 @@
|
||||
"metadata": {
|
||||
"$ref": "#/definitions/AlertRuleMetadata"
|
||||
},
|
||||
"missing_series_evals_to_resolve": {
|
||||
"description": "Number of consecutive evaluation intervals with no data for a dimension must pass\nbefore the alert state is considered stale and automatically resolved.\nIf set to 0, the value is reset to the default.",
|
||||
"example": 3,
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"no_data_state": {
|
||||
"enum": [
|
||||
"Alerting",
|
||||
@@ -3150,6 +3164,11 @@
|
||||
},
|
||||
"type": "object"
|
||||
},
|
||||
"missingSeriesEvalsToResolve": {
|
||||
"example": 2,
|
||||
"format": "int64",
|
||||
"type": "integer"
|
||||
},
|
||||
"noDataState": {
|
||||
"enum": [
|
||||
"Alerting",
|
||||
@@ -4814,7 +4833,6 @@
|
||||
"type": "object"
|
||||
},
|
||||
"alertGroups": {
|
||||
"description": "AlertGroups alert groups",
|
||||
"items": {
|
||||
"$ref": "#/definitions/alertGroup",
|
||||
"type": "object"
|
||||
@@ -4976,7 +4994,6 @@
|
||||
"type": "object"
|
||||
},
|
||||
"gettableAlerts": {
|
||||
"description": "GettableAlerts gettable alerts",
|
||||
"items": {
|
||||
"$ref": "#/definitions/gettableAlert",
|
||||
"type": "object"
|
||||
|
||||
@@ -4442,6 +4442,10 @@
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"missing_series_evals_to_resolve": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"noDataState": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
@@ -5855,6 +5859,10 @@
|
||||
"metadata": {
|
||||
"$ref": "#/definitions/AlertRuleMetadata"
|
||||
},
|
||||
"missing_series_evals_to_resolve": {
|
||||
"type": "integer",
|
||||
"format": "int64"
|
||||
},
|
||||
"namespace_uid": {
|
||||
"type": "string"
|
||||
},
|
||||
@@ -7090,6 +7098,12 @@
|
||||
"metadata": {
|
||||
"$ref": "#/definitions/AlertRuleMetadata"
|
||||
},
|
||||
"missing_series_evals_to_resolve": {
|
||||
"description": "Number of consecutive evaluation intervals with no data for a dimension must pass\nbefore the alert state is considered stale and automatically resolved.\nIf set to 0, the value is reset to the default.",
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"example": 3
|
||||
},
|
||||
"no_data_state": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
@@ -7387,6 +7401,11 @@
|
||||
"team": "sre-team-1"
|
||||
}
|
||||
},
|
||||
"missingSeriesEvalsToResolve": {
|
||||
"type": "integer",
|
||||
"format": "int64",
|
||||
"example": 2
|
||||
},
|
||||
"noDataState": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
@@ -9039,7 +9058,6 @@
|
||||
}
|
||||
},
|
||||
"alertGroups": {
|
||||
"description": "AlertGroups alert groups",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
@@ -9201,7 +9219,6 @@
|
||||
}
|
||||
},
|
||||
"gettableAlerts": {
|
||||
"description": "GettableAlerts gettable alerts",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
|
||||
Reference in New Issue
Block a user