Alerting: Support query_offset in the Prometheus conversion (#102499)

Adds support for rule group-level query_offset in Prometheus to Grafana rule conversion. It allows specifying a time offset for rule evaluation, which gets applied and saved during the conversion.
This commit is contained in:
Alexander Akhmetov
2025-03-20 18:05:55 +01:00
committed by GitHub
parent 0845c781ae
commit ad71270ee0
11 changed files with 160 additions and 28 deletions
+24 -1
View File
@@ -208,6 +208,9 @@
"isPaused": {
"type": "boolean"
},
"keepFiringFor": {
"$ref": "#/definitions/Duration"
},
"labels": {
"additionalProperties": {
"type": "string"
@@ -468,6 +471,10 @@
"health": {
"type": "string"
},
"keepFiringFor": {
"format": "double",
"type": "number"
},
"labels": {
"$ref": "#/definitions/Labels"
},
@@ -3012,9 +3019,22 @@
"Interval": {
"$ref": "#/definitions/Duration"
},
"Labels": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"Limit": {
"format": "int64",
"type": "integer"
},
"Name": {
"type": "string"
},
"QueryOffset": {
"type": "string"
},
"Rules": {
"items": {
"$ref": "#/definitions/PrometheusRule"
@@ -3117,6 +3137,10 @@
"example": false,
"type": "boolean"
},
"keep_firing_for": {
"format": "duration",
"type": "string"
},
"labels": {
"additionalProperties": {
"type": "string"
@@ -4952,7 +4976,6 @@
"type": "object"
},
"gettableAlerts": {
"description": "GettableAlerts gettable alerts",
"items": {
"$ref": "#/definitions/gettableAlert",
"type": "object"
@@ -192,9 +192,12 @@ type PrometheusNamespace struct {
// swagger:model
type PrometheusRuleGroup struct {
Name string `yaml:"name"`
Interval model.Duration `yaml:"interval"`
Rules []PrometheusRule `yaml:"rules"`
Name string `yaml:"name"`
Interval model.Duration `yaml:"interval"`
QueryOffset *model.Duration `yaml:"query_offset,omitempty"`
Limit int `yaml:"limit,omitempty"`
Rules []PrometheusRule `yaml:"rules"`
Labels map[string]string `yaml:"labels,omitempty"`
}
// swagger:model
@@ -208,6 +208,9 @@
"isPaused": {
"type": "boolean"
},
"keepFiringFor": {
"$ref": "#/definitions/Duration"
},
"labels": {
"additionalProperties": {
"type": "string"
@@ -468,6 +471,10 @@
"health": {
"type": "string"
},
"keepFiringFor": {
"format": "double",
"type": "number"
},
"labels": {
"$ref": "#/definitions/Labels"
},
@@ -3012,9 +3019,22 @@
"Interval": {
"$ref": "#/definitions/Duration"
},
"Labels": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"Limit": {
"format": "int64",
"type": "integer"
},
"Name": {
"type": "string"
},
"QueryOffset": {
"type": "string"
},
"Rules": {
"items": {
"$ref": "#/definitions/PrometheusRule"
@@ -3117,6 +3137,10 @@
"example": false,
"type": "boolean"
},
"keep_firing_for": {
"format": "duration",
"type": "string"
},
"labels": {
"additionalProperties": {
"type": "string"
@@ -4433,6 +4433,9 @@
"isPaused": {
"type": "boolean"
},
"keepFiringFor": {
"$ref": "#/definitions/Duration"
},
"labels": {
"type": "object",
"additionalProperties": {
@@ -4703,6 +4706,10 @@
"health": {
"type": "string"
},
"keepFiringFor": {
"type": "number",
"format": "double"
},
"labels": {
"$ref": "#/definitions/Labels"
},
@@ -7238,9 +7245,22 @@
"Interval": {
"$ref": "#/definitions/Duration"
},
"Labels": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"Limit": {
"type": "integer",
"format": "int64"
},
"Name": {
"type": "string"
},
"QueryOffset": {
"type": "string"
},
"Rules": {
"type": "array",
"items": {
@@ -7354,6 +7374,10 @@
"type": "boolean",
"example": false
},
"keep_firing_for": {
"type": "string",
"format": "duration"
},
"labels": {
"type": "object",
"additionalProperties": {