Alerting: Update RuleGroupConfig definitions with missing fields (#115850)

* Alerting: Update RuleGroupConfig definitions with missing fields

This update adds previously missing fields to the `RuleGroupConfig` structs to
ensure compatibility with external Prometheus-like rulers.

Includes:
- `labels`: per https://github.com/prometheus/prometheus/pull/11474
- `remote_write`: per https://github
.com/grafana/mimir/blob/56f33fed6254fee5a53bde1eab36c604863e3d5f/pkg/mimirtool/rules/rwrulefmt/rulefmt.go#L16

Note: This does not add full support in Grafana; it only allows these fields to
pass through the alerting proxy without causing unmarshal errors when using
external rulers.

* Update OpenAPI spec
This commit is contained in:
Matthew Jacobson
2026-01-06 11:05:01 -05:00
committed by GitHub
parent 1465b44d5a
commit 5eb0e6f432
6 changed files with 371 additions and 47 deletions
+69 -7
View File
@@ -647,12 +647,6 @@
},
"BacktestConfig": {
"properties": {
"annotations": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"condition": {
"type": "string"
},
@@ -662,8 +656,16 @@
},
"type": "array"
},
"exec_err_state": {
"enum": [
"OK",
"Alerting",
"Error"
],
"type": "string"
},
"for": {
"$ref": "#/definitions/Duration"
"type": "string"
},
"from": {
"format": "date-time",
@@ -672,12 +674,22 @@
"interval": {
"$ref": "#/definitions/Duration"
},
"keep_firing_for": {
"type": "string"
},
"labels": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"missing_series_evals_to_resolve": {
"format": "int64",
"type": "integer"
},
"namespace_uid": {
"type": "string"
},
"no_data_state": {
"enum": [
"Alerting",
@@ -686,12 +698,18 @@
],
"type": "string"
},
"rule_group": {
"type": "string"
},
"title": {
"type": "string"
},
"to": {
"format": "date-time",
"type": "string"
},
"uid": {
"type": "string"
}
},
"type": "object"
@@ -1813,6 +1831,12 @@
"interval": {
"$ref": "#/definitions/Duration"
},
"labels": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"limit": {
"format": "int64",
"type": "integer"
@@ -1823,6 +1847,12 @@
"query_offset": {
"type": "string"
},
"remote_write": {
"items": {
"$ref": "#/definitions/RemoteWriteConfig"
},
"type": "array"
},
"rules": {
"items": {
"$ref": "#/definitions/GettableExtendedRuleNode"
@@ -3142,6 +3172,12 @@
"interval": {
"$ref": "#/definitions/Duration"
},
"labels": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"limit": {
"format": "int64",
"type": "integer"
@@ -3152,6 +3188,12 @@
"query_offset": {
"type": "string"
},
"remote_write": {
"items": {
"$ref": "#/definitions/RemoteWriteConfig"
},
"type": "array"
},
"rules": {
"items": {
"$ref": "#/definitions/PostableExtendedRuleNode"
@@ -3817,6 +3859,14 @@
},
"type": "object"
},
"RemoteWriteConfig": {
"properties": {
"url": {
"type": "string"
}
},
"type": "object"
},
"ResponseDetails": {
"properties": {
"msg": {
@@ -4093,6 +4143,12 @@
"interval": {
"$ref": "#/definitions/Duration"
},
"labels": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"limit": {
"format": "int64",
"type": "integer"
@@ -4103,6 +4159,12 @@
"query_offset": {
"type": "string"
},
"remote_write": {
"items": {
"$ref": "#/definitions/RemoteWriteConfig"
},
"type": "array"
},
"rules": {
"items": {
"$ref": "#/definitions/GettableExtendedRuleNode"
@@ -284,11 +284,20 @@ type PostableRuleGroupConfig struct {
// fields below are used by Mimir/Loki rulers
SourceTenants []string `yaml:"source_tenants,omitempty" json:"source_tenants,omitempty"`
EvaluationDelay *model.Duration `yaml:"evaluation_delay,omitempty" json:"evaluation_delay,omitempty"`
QueryOffset *model.Duration `yaml:"query_offset,omitempty" json:"query_offset,omitempty"`
AlignEvaluationTimeOnInterval bool `yaml:"align_evaluation_time_on_interval,omitempty" json:"align_evaluation_time_on_interval,omitempty"`
Limit int `yaml:"limit,omitempty" json:"limit,omitempty"`
SourceTenants []string `yaml:"source_tenants,omitempty" json:"source_tenants,omitempty"`
EvaluationDelay *model.Duration `yaml:"evaluation_delay,omitempty" json:"evaluation_delay,omitempty"`
QueryOffset *model.Duration `yaml:"query_offset,omitempty" json:"query_offset,omitempty"`
AlignEvaluationTimeOnInterval bool `yaml:"align_evaluation_time_on_interval,omitempty" json:"align_evaluation_time_on_interval,omitempty"`
Limit int `yaml:"limit,omitempty" json:"limit,omitempty"`
Labels map[string]string `yaml:"labels,omitempty" json:"labels,omitempty"`
// GEM Ruler.
RWConfigs []RemoteWriteConfig `yaml:"remote_write,omitempty" json:"remote_write,omitempty"`
}
type RemoteWriteConfig struct {
URL string `yaml:"url,omitempty" json:"url,omitempty"`
}
func (c *PostableRuleGroupConfig) UnmarshalJSON(b []byte) error {
@@ -328,8 +337,8 @@ func (c *PostableRuleGroupConfig) validate() error {
return fmt.Errorf("cannot mix Grafana & Prometheus style rules")
}
if hasGrafRules && (len(c.SourceTenants) > 0 || c.EvaluationDelay != nil || c.QueryOffset != nil || c.AlignEvaluationTimeOnInterval || c.Limit > 0) {
return fmt.Errorf("fields source_tenants, evaluation_delay, query_offset, align_evaluation_time_on_interval and limit are not supported for Grafana rules")
if hasGrafRules && (len(c.SourceTenants) > 0 || c.EvaluationDelay != nil || c.QueryOffset != nil || c.AlignEvaluationTimeOnInterval || c.Limit > 0 || len(c.Labels) > 0 || len(c.RWConfigs) > 0) {
return fmt.Errorf("fields source_tenants, evaluation_delay, query_offset, align_evaluation_time_on_interval, limit, labels, and remote_write are not supported for Grafana rules")
}
return nil
}
@@ -345,11 +354,16 @@ type GettableRuleGroupConfig struct {
// fields below are used by Mimir/Loki rulers
SourceTenants []string `yaml:"source_tenants,omitempty" json:"source_tenants,omitempty"`
EvaluationDelay *model.Duration `yaml:"evaluation_delay,omitempty" json:"evaluation_delay,omitempty"`
QueryOffset *model.Duration `yaml:"query_offset,omitempty" json:"query_offset,omitempty"`
AlignEvaluationTimeOnInterval bool `yaml:"align_evaluation_time_on_interval,omitempty" json:"align_evaluation_time_on_interval,omitempty"`
Limit int `yaml:"limit,omitempty" json:"limit,omitempty"`
SourceTenants []string `yaml:"source_tenants,omitempty" json:"source_tenants,omitempty"`
EvaluationDelay *model.Duration `yaml:"evaluation_delay,omitempty" json:"evaluation_delay,omitempty"`
QueryOffset *model.Duration `yaml:"query_offset,omitempty" json:"query_offset,omitempty"`
AlignEvaluationTimeOnInterval bool `yaml:"align_evaluation_time_on_interval,omitempty" json:"align_evaluation_time_on_interval,omitempty"`
Limit int `yaml:"limit,omitempty" json:"limit,omitempty"`
Labels map[string]string `yaml:"labels,omitempty" json:"labels,omitempty"`
// GEM Ruler.
RWConfigs []RemoteWriteConfig `yaml:"remote_write,omitempty" json:"remote_write,omitempty"`
}
func (c *GettableRuleGroupConfig) UnmarshalJSON(b []byte) error {
+69 -7
View File
@@ -647,12 +647,6 @@
},
"BacktestConfig": {
"properties": {
"annotations": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"condition": {
"type": "string"
},
@@ -662,8 +656,16 @@
},
"type": "array"
},
"exec_err_state": {
"enum": [
"OK",
"Alerting",
"Error"
],
"type": "string"
},
"for": {
"$ref": "#/definitions/Duration"
"type": "string"
},
"from": {
"format": "date-time",
@@ -672,12 +674,22 @@
"interval": {
"$ref": "#/definitions/Duration"
},
"keep_firing_for": {
"type": "string"
},
"labels": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"missing_series_evals_to_resolve": {
"format": "int64",
"type": "integer"
},
"namespace_uid": {
"type": "string"
},
"no_data_state": {
"enum": [
"Alerting",
@@ -686,12 +698,18 @@
],
"type": "string"
},
"rule_group": {
"type": "string"
},
"title": {
"type": "string"
},
"to": {
"format": "date-time",
"type": "string"
},
"uid": {
"type": "string"
}
},
"type": "object"
@@ -1813,6 +1831,12 @@
"interval": {
"$ref": "#/definitions/Duration"
},
"labels": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"limit": {
"format": "int64",
"type": "integer"
@@ -1823,6 +1847,12 @@
"query_offset": {
"type": "string"
},
"remote_write": {
"items": {
"$ref": "#/definitions/RemoteWriteConfig"
},
"type": "array"
},
"rules": {
"items": {
"$ref": "#/definitions/GettableExtendedRuleNode"
@@ -3142,6 +3172,12 @@
"interval": {
"$ref": "#/definitions/Duration"
},
"labels": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"limit": {
"format": "int64",
"type": "integer"
@@ -3152,6 +3188,12 @@
"query_offset": {
"type": "string"
},
"remote_write": {
"items": {
"$ref": "#/definitions/RemoteWriteConfig"
},
"type": "array"
},
"rules": {
"items": {
"$ref": "#/definitions/PostableExtendedRuleNode"
@@ -3817,6 +3859,14 @@
},
"type": "object"
},
"RemoteWriteConfig": {
"properties": {
"url": {
"type": "string"
}
},
"type": "object"
},
"ResponseDetails": {
"properties": {
"msg": {
@@ -4093,6 +4143,12 @@
"interval": {
"$ref": "#/definitions/Duration"
},
"labels": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"limit": {
"format": "int64",
"type": "integer"
@@ -4103,6 +4159,12 @@
"query_offset": {
"type": "string"
},
"remote_write": {
"items": {
"$ref": "#/definitions/RemoteWriteConfig"
},
"type": "array"
},
"rules": {
"items": {
"$ref": "#/definitions/GettableExtendedRuleNode"
+69 -7
View File
@@ -5072,12 +5072,6 @@
"BacktestConfig": {
"type": "object",
"properties": {
"annotations": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"condition": {
"type": "string"
},
@@ -5087,8 +5081,16 @@
"$ref": "#/definitions/AlertQuery"
}
},
"exec_err_state": {
"type": "string",
"enum": [
"OK",
"Alerting",
"Error"
]
},
"for": {
"$ref": "#/definitions/Duration"
"type": "string"
},
"from": {
"type": "string",
@@ -5097,12 +5099,22 @@
"interval": {
"$ref": "#/definitions/Duration"
},
"keep_firing_for": {
"type": "string"
},
"labels": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"missing_series_evals_to_resolve": {
"type": "integer",
"format": "int64"
},
"namespace_uid": {
"type": "string"
},
"no_data_state": {
"type": "string",
"enum": [
@@ -5111,12 +5123,18 @@
"OK"
]
},
"rule_group": {
"type": "string"
},
"title": {
"type": "string"
},
"to": {
"type": "string",
"format": "date-time"
},
"uid": {
"type": "string"
}
}
},
@@ -6239,6 +6257,12 @@
"interval": {
"$ref": "#/definitions/Duration"
},
"labels": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"limit": {
"type": "integer",
"format": "int64"
@@ -6249,6 +6273,12 @@
"query_offset": {
"type": "string"
},
"remote_write": {
"type": "array",
"items": {
"$ref": "#/definitions/RemoteWriteConfig"
}
},
"rules": {
"type": "array",
"items": {
@@ -7569,6 +7599,12 @@
"interval": {
"$ref": "#/definitions/Duration"
},
"labels": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"limit": {
"type": "integer",
"format": "int64"
@@ -7579,6 +7615,12 @@
"query_offset": {
"type": "string"
},
"remote_write": {
"type": "array",
"items": {
"$ref": "#/definitions/RemoteWriteConfig"
}
},
"rules": {
"type": "array",
"items": {
@@ -8243,6 +8285,14 @@
}
}
},
"RemoteWriteConfig": {
"type": "object",
"properties": {
"url": {
"type": "string"
}
}
},
"ResponseDetails": {
"type": "object",
"properties": {
@@ -8520,6 +8570,12 @@
"interval": {
"$ref": "#/definitions/Duration"
},
"labels": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"limit": {
"type": "integer",
"format": "int64"
@@ -8530,6 +8586,12 @@
"query_offset": {
"type": "string"
},
"remote_write": {
"type": "array",
"items": {
"$ref": "#/definitions/RemoteWriteConfig"
}
},
"rules": {
"type": "array",
"items": {
+69 -7
View File
@@ -13829,12 +13829,6 @@
"BacktestConfig": {
"type": "object",
"properties": {
"annotations": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"condition": {
"type": "string"
},
@@ -13844,8 +13838,16 @@
"$ref": "#/definitions/AlertQuery"
}
},
"exec_err_state": {
"type": "string",
"enum": [
"OK",
"Alerting",
"Error"
]
},
"for": {
"$ref": "#/definitions/Duration"
"type": "string"
},
"from": {
"type": "string",
@@ -13854,12 +13856,22 @@
"interval": {
"$ref": "#/definitions/Duration"
},
"keep_firing_for": {
"type": "string"
},
"labels": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"missing_series_evals_to_resolve": {
"type": "integer",
"format": "int64"
},
"namespace_uid": {
"type": "string"
},
"no_data_state": {
"type": "string",
"enum": [
@@ -13868,12 +13880,18 @@
"OK"
]
},
"rule_group": {
"type": "string"
},
"title": {
"type": "string"
},
"to": {
"type": "string",
"format": "date-time"
},
"uid": {
"type": "string"
}
}
},
@@ -16778,6 +16796,12 @@
"interval": {
"$ref": "#/definitions/Duration"
},
"labels": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"limit": {
"type": "integer",
"format": "int64"
@@ -16788,6 +16812,12 @@
"query_offset": {
"type": "string"
},
"remote_write": {
"type": "array",
"items": {
"$ref": "#/definitions/RemoteWriteConfig"
}
},
"rules": {
"type": "array",
"items": {
@@ -19263,6 +19293,12 @@
"interval": {
"$ref": "#/definitions/Duration"
},
"labels": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"limit": {
"type": "integer",
"format": "int64"
@@ -19273,6 +19309,12 @@
"query_offset": {
"type": "string"
},
"remote_write": {
"type": "array",
"items": {
"$ref": "#/definitions/RemoteWriteConfig"
}
},
"rules": {
"type": "array",
"items": {
@@ -20310,6 +20352,14 @@
}
}
},
"RemoteWriteConfig": {
"type": "object",
"properties": {
"url": {
"type": "string"
}
}
},
"Report": {
"type": "object",
"properties": {
@@ -21009,6 +21059,12 @@
"interval": {
"$ref": "#/definitions/Duration"
},
"labels": {
"type": "object",
"additionalProperties": {
"type": "string"
}
},
"limit": {
"type": "integer",
"format": "int64"
@@ -21019,6 +21075,12 @@
"query_offset": {
"type": "string"
},
"remote_write": {
"type": "array",
"items": {
"$ref": "#/definitions/RemoteWriteConfig"
}
},
"rules": {
"type": "array",
"items": {
+69 -7
View File
@@ -3364,12 +3364,6 @@
},
"BacktestConfig": {
"properties": {
"annotations": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"condition": {
"type": "string"
},
@@ -3379,8 +3373,16 @@
},
"type": "array"
},
"exec_err_state": {
"enum": [
"OK",
"Alerting",
"Error"
],
"type": "string"
},
"for": {
"$ref": "#/components/schemas/Duration"
"type": "string"
},
"from": {
"format": "date-time",
@@ -3389,12 +3391,22 @@
"interval": {
"$ref": "#/components/schemas/Duration"
},
"keep_firing_for": {
"type": "string"
},
"labels": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"missing_series_evals_to_resolve": {
"format": "int64",
"type": "integer"
},
"namespace_uid": {
"type": "string"
},
"no_data_state": {
"enum": [
"Alerting",
@@ -3403,12 +3415,18 @@
],
"type": "string"
},
"rule_group": {
"type": "string"
},
"title": {
"type": "string"
},
"to": {
"format": "date-time",
"type": "string"
},
"uid": {
"type": "string"
}
},
"type": "object"
@@ -6313,6 +6331,12 @@
"interval": {
"$ref": "#/components/schemas/Duration"
},
"labels": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"limit": {
"format": "int64",
"type": "integer"
@@ -6323,6 +6347,12 @@
"query_offset": {
"type": "string"
},
"remote_write": {
"items": {
"$ref": "#/components/schemas/RemoteWriteConfig"
},
"type": "array"
},
"rules": {
"items": {
"$ref": "#/components/schemas/GettableExtendedRuleNode"
@@ -8798,6 +8828,12 @@
"interval": {
"$ref": "#/components/schemas/Duration"
},
"labels": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"limit": {
"format": "int64",
"type": "integer"
@@ -8808,6 +8844,12 @@
"query_offset": {
"type": "string"
},
"remote_write": {
"items": {
"$ref": "#/components/schemas/RemoteWriteConfig"
},
"type": "array"
},
"rules": {
"items": {
"$ref": "#/components/schemas/PostableExtendedRuleNode"
@@ -9846,6 +9888,14 @@
},
"type": "object"
},
"RemoteWriteConfig": {
"properties": {
"url": {
"type": "string"
}
},
"type": "object"
},
"Report": {
"properties": {
"created": {
@@ -10544,6 +10594,12 @@
"interval": {
"$ref": "#/components/schemas/Duration"
},
"labels": {
"additionalProperties": {
"type": "string"
},
"type": "object"
},
"limit": {
"format": "int64",
"type": "integer"
@@ -10554,6 +10610,12 @@
"query_offset": {
"type": "string"
},
"remote_write": {
"items": {
"$ref": "#/components/schemas/RemoteWriteConfig"
},
"type": "array"
},
"rules": {
"items": {
"$ref": "#/components/schemas/GettableExtendedRuleNode"