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:
Alexander Akhmetov
2025-03-26 13:34:53 +01:00
committed by GitHub
parent f2fc1d8575
commit f49a88ab72
17 changed files with 462 additions and 116 deletions
+20
View File
@@ -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"