Alerting: Support simplified routing receivers in Prometheus conversion API (#105135)
Adds ability to set notifications settings using the Prometheus conversion API.
The API now supports a new optional header: X-Grafana-Alerting-Notification-Settings which can be used to specify notification settings.
The value of the header is the AlertRuleNotificationSettings structure in JSON:
mimirtool rules load alerts.yaml --extra-headers 'X-Grafana-Alerting-Notification-Settings: {"receiver": "my-webhook", "group_by": ["cluster", "pod"]}'
This commit is contained in:
@@ -314,6 +314,16 @@
|
||||
},
|
||||
"AlertRuleNotificationSettings": {
|
||||
"properties": {
|
||||
"active_time_intervals": {
|
||||
"description": "Override the times when notifications should not be muted. These must match the name of a mute time interval defined\nin the alertmanager configuration time_intervals section. All notifications will be suppressed unless they are sent\nat the time that matches any interval.",
|
||||
"example": [
|
||||
"maintenance"
|
||||
],
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"group_by": {
|
||||
"default": [
|
||||
"alertname",
|
||||
@@ -341,7 +351,7 @@
|
||||
"type": "string"
|
||||
},
|
||||
"mute_time_intervals": {
|
||||
"description": "Override the times when notifications should be muted. These must match the name of a mute time interval defined\nin the alertmanager configuration mute_time_intervals section. When muted it will not send any notifications, but\notherwise acts normally.",
|
||||
"description": "Override the times when notifications should be muted. These must match the name of a mute time interval defined\nin the alertmanager configuration time_intervals section. When muted it will not send any notifications, but\notherwise acts normally.",
|
||||
"example": [
|
||||
"maintenance"
|
||||
],
|
||||
@@ -368,6 +378,12 @@
|
||||
},
|
||||
"AlertRuleNotificationSettingsExport": {
|
||||
"properties": {
|
||||
"active_time_intervals": {
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"group_by": {
|
||||
"items": {
|
||||
"type": "string"
|
||||
@@ -2325,6 +2341,12 @@
|
||||
},
|
||||
"NotificationPolicyExport": {
|
||||
"properties": {
|
||||
"active_time_intervals": {
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"continue": {
|
||||
"type": "boolean"
|
||||
},
|
||||
@@ -3710,6 +3732,12 @@
|
||||
"RouteExport": {
|
||||
"description": "RouteExport is the provisioned file export of definitions.Route. This is needed to hide fields that aren't useable in\nprovisioning file format. An alternative would be to define a custom MarshalJSON and MarshalYAML that excludes them.",
|
||||
"properties": {
|
||||
"active_time_intervals": {
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"continue": {
|
||||
"type": "boolean"
|
||||
},
|
||||
@@ -4889,7 +4917,6 @@
|
||||
"type": "object"
|
||||
},
|
||||
"alertGroups": {
|
||||
"description": "AlertGroups alert groups",
|
||||
"items": {
|
||||
"$ref": "#/definitions/alertGroup",
|
||||
"type": "object"
|
||||
@@ -5176,7 +5203,6 @@
|
||||
"type": "object"
|
||||
},
|
||||
"gettableSilences": {
|
||||
"description": "GettableSilences gettable silences",
|
||||
"items": {
|
||||
"$ref": "#/definitions/gettableSilence",
|
||||
"type": "object"
|
||||
@@ -6661,4 +6687,4 @@
|
||||
}
|
||||
},
|
||||
"swagger": "2.0"
|
||||
}
|
||||
}
|
||||
@@ -210,6 +210,12 @@ type RouteConvertPrometheusPostRuleGroupParams struct {
|
||||
RecordingRulesPaused bool `json:"x-grafana-alerting-recording-rules-paused"`
|
||||
// in: header
|
||||
AlertRulesPaused bool `json:"x-grafana-alerting-alert-rules-paused"`
|
||||
// in: header
|
||||
TargetDatasourceUID string `json:"x-grafana-alerting-target-datasource-uid"`
|
||||
// in: header
|
||||
FolderUID string `json:"x-grafana-alerting-folder-uid"`
|
||||
// in: header
|
||||
NotificationReceiver string `json:"x-grafana-alerting-notification-receiver"`
|
||||
// in:body
|
||||
Body PrometheusRuleGroup
|
||||
}
|
||||
|
||||
@@ -314,6 +314,16 @@
|
||||
},
|
||||
"AlertRuleNotificationSettings": {
|
||||
"properties": {
|
||||
"active_time_intervals": {
|
||||
"description": "Override the times when notifications should not be muted. These must match the name of a mute time interval defined\nin the alertmanager configuration time_intervals section. All notifications will be suppressed unless they are sent\nat the time that matches any interval.",
|
||||
"example": [
|
||||
"maintenance"
|
||||
],
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"group_by": {
|
||||
"default": [
|
||||
"alertname",
|
||||
@@ -341,7 +351,7 @@
|
||||
"type": "string"
|
||||
},
|
||||
"mute_time_intervals": {
|
||||
"description": "Override the times when notifications should be muted. These must match the name of a mute time interval defined\nin the alertmanager configuration mute_time_intervals section. When muted it will not send any notifications, but\notherwise acts normally.",
|
||||
"description": "Override the times when notifications should be muted. These must match the name of a mute time interval defined\nin the alertmanager configuration time_intervals section. When muted it will not send any notifications, but\notherwise acts normally.",
|
||||
"example": [
|
||||
"maintenance"
|
||||
],
|
||||
@@ -368,6 +378,12 @@
|
||||
},
|
||||
"AlertRuleNotificationSettingsExport": {
|
||||
"properties": {
|
||||
"active_time_intervals": {
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"group_by": {
|
||||
"items": {
|
||||
"type": "string"
|
||||
@@ -2325,6 +2341,12 @@
|
||||
},
|
||||
"NotificationPolicyExport": {
|
||||
"properties": {
|
||||
"active_time_intervals": {
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"continue": {
|
||||
"type": "boolean"
|
||||
},
|
||||
@@ -3710,6 +3732,12 @@
|
||||
"RouteExport": {
|
||||
"description": "RouteExport is the provisioned file export of definitions.Route. This is needed to hide fields that aren't useable in\nprovisioning file format. An alternative would be to define a custom MarshalJSON and MarshalYAML that excludes them.",
|
||||
"properties": {
|
||||
"active_time_intervals": {
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"type": "array"
|
||||
},
|
||||
"continue": {
|
||||
"type": "boolean"
|
||||
},
|
||||
@@ -4888,7 +4916,6 @@
|
||||
"type": "object"
|
||||
},
|
||||
"alertGroups": {
|
||||
"description": "AlertGroups alert groups",
|
||||
"items": {
|
||||
"$ref": "#/definitions/alertGroup",
|
||||
"type": "object"
|
||||
@@ -5050,7 +5077,6 @@
|
||||
"type": "object"
|
||||
},
|
||||
"gettableAlerts": {
|
||||
"description": "GettableAlerts gettable alerts",
|
||||
"items": {
|
||||
"$ref": "#/definitions/gettableAlert",
|
||||
"type": "object"
|
||||
@@ -5175,6 +5201,7 @@
|
||||
"type": "object"
|
||||
},
|
||||
"gettableSilences": {
|
||||
"description": "GettableSilences gettable silences",
|
||||
"items": {
|
||||
"$ref": "#/definitions/gettableSilence",
|
||||
"type": "object"
|
||||
@@ -6644,6 +6671,21 @@
|
||||
"name": "x-grafana-alerting-alert-rules-paused",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"in": "header",
|
||||
"name": "x-grafana-alerting-target-datasource-uid",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"in": "header",
|
||||
"name": "x-grafana-alerting-folder-uid",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"in": "header",
|
||||
"name": "x-grafana-alerting-notification-receiver",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"in": "body",
|
||||
"name": "Body",
|
||||
@@ -6919,6 +6961,21 @@
|
||||
"name": "x-grafana-alerting-alert-rules-paused",
|
||||
"type": "boolean"
|
||||
},
|
||||
{
|
||||
"in": "header",
|
||||
"name": "x-grafana-alerting-target-datasource-uid",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"in": "header",
|
||||
"name": "x-grafana-alerting-folder-uid",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"in": "header",
|
||||
"name": "x-grafana-alerting-notification-receiver",
|
||||
"type": "string"
|
||||
},
|
||||
{
|
||||
"in": "body",
|
||||
"name": "Body",
|
||||
@@ -9533,4 +9590,4 @@
|
||||
}
|
||||
},
|
||||
"swagger": "2.0"
|
||||
}
|
||||
}
|
||||
@@ -1204,6 +1204,21 @@
|
||||
"name": "x-grafana-alerting-alert-rules-paused",
|
||||
"in": "header"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "x-grafana-alerting-target-datasource-uid",
|
||||
"in": "header"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "x-grafana-alerting-folder-uid",
|
||||
"in": "header"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "x-grafana-alerting-notification-receiver",
|
||||
"in": "header"
|
||||
},
|
||||
{
|
||||
"name": "Body",
|
||||
"in": "body",
|
||||
@@ -1479,6 +1494,21 @@
|
||||
"name": "x-grafana-alerting-alert-rules-paused",
|
||||
"in": "header"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "x-grafana-alerting-target-datasource-uid",
|
||||
"in": "header"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "x-grafana-alerting-folder-uid",
|
||||
"in": "header"
|
||||
},
|
||||
{
|
||||
"type": "string",
|
||||
"name": "x-grafana-alerting-notification-receiver",
|
||||
"in": "header"
|
||||
},
|
||||
{
|
||||
"name": "Body",
|
||||
"in": "body",
|
||||
@@ -4416,6 +4446,16 @@
|
||||
"receiver"
|
||||
],
|
||||
"properties": {
|
||||
"active_time_intervals": {
|
||||
"description": "Override the times when notifications should not be muted. These must match the name of a mute time interval defined\nin the alertmanager configuration time_intervals section. All notifications will be suppressed unless they are sent\nat the time that matches any interval.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
},
|
||||
"example": [
|
||||
"maintenance"
|
||||
]
|
||||
},
|
||||
"group_by": {
|
||||
"description": "Override the labels by which incoming alerts are grouped together. For example, multiple alerts coming in for\ncluster=A and alertname=LatencyHigh would be batched into a single group. To aggregate by all possible labels\nuse the special value '...' as the sole label name.\nThis effectively disables aggregation entirely, passing through all alerts as-is. This is unlikely to be what\nyou want, unless you have a very low alert volume or your upstream notification system performs its own grouping.\nMust include 'alertname' and 'grafana_folder' if not using '...'.",
|
||||
"type": "array",
|
||||
@@ -4443,7 +4483,7 @@
|
||||
"example": "30s"
|
||||
},
|
||||
"mute_time_intervals": {
|
||||
"description": "Override the times when notifications should be muted. These must match the name of a mute time interval defined\nin the alertmanager configuration mute_time_intervals section. When muted it will not send any notifications, but\notherwise acts normally.",
|
||||
"description": "Override the times when notifications should be muted. These must match the name of a mute time interval defined\nin the alertmanager configuration time_intervals section. When muted it will not send any notifications, but\notherwise acts normally.",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
@@ -4468,6 +4508,12 @@
|
||||
"type": "object",
|
||||
"title": "AlertRuleNotificationSettingsExport is the provisioned export of models.NotificationSettings.",
|
||||
"properties": {
|
||||
"active_time_intervals": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"group_by": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
@@ -6427,6 +6473,12 @@
|
||||
"type": "object",
|
||||
"title": "NotificationPolicyExport is the provisioned file export of alerting.NotificiationPolicyV1.",
|
||||
"properties": {
|
||||
"active_time_intervals": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"continue": {
|
||||
"type": "boolean"
|
||||
},
|
||||
@@ -7811,6 +7863,12 @@
|
||||
"description": "RouteExport is the provisioned file export of definitions.Route. This is needed to hide fields that aren't useable in\nprovisioning file format. An alternative would be to define a custom MarshalJSON and MarshalYAML that excludes them.",
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"active_time_intervals": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"continue": {
|
||||
"type": "boolean"
|
||||
},
|
||||
@@ -8988,7 +9046,6 @@
|
||||
}
|
||||
},
|
||||
"alertGroups": {
|
||||
"description": "AlertGroups alert groups",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
@@ -9150,7 +9207,6 @@
|
||||
}
|
||||
},
|
||||
"gettableAlerts": {
|
||||
"description": "GettableAlerts gettable alerts",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
@@ -9275,6 +9331,7 @@
|
||||
}
|
||||
},
|
||||
"gettableSilences": {
|
||||
"description": "GettableSilences gettable silences",
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
@@ -9566,4 +9623,4 @@
|
||||
"type": "basic"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user