Alerting: Allow more characters in label names so notifications are sent (#38629)

Remove validation for labels to be accepted in the Alertmanager, This helps with datasources that produce non-compatible labels.

Adds an "object_matchers" to alert manager routers so we can support labels names with extended characters beyond prometheus/openmetrics. It only does this for the internal Grafana managed Alert Manager.

This requires a change to alert manager, so for now we use grafana/alertmanager which is a slight fork, with the intention of going back to upstream.

The frontend handles the migration of "matchers" -> "object_matchers" when the route is edited and saved. Once this is done, downgrades will not work old versions will not recognize the "object_matchers".

Co-authored-by: Kyle Brandt <kyle@grafana.com>
Co-authored-by: Nathan Rodman <nathanrodman@gmail.com>
This commit is contained in:
gotjosh
2021-10-04 14:06:40 +01:00
committed by GitHub
parent 706a665240
commit 6572017ec7
16 changed files with 740 additions and 188 deletions
+127 -27
View File
@@ -1024,10 +1024,10 @@
"x-go-name": "ActiveAt"
},
"annotations": {
"$ref": "#/definitions/labels"
"$ref": "#/definitions/overrideLabels"
},
"labels": {
"$ref": "#/definitions/labels"
"$ref": "#/definitions/overrideLabels"
},
"state": {
"type": "string",
@@ -1189,7 +1189,7 @@
"x-go-name": "Alerts"
},
"annotations": {
"$ref": "#/definitions/labels"
"$ref": "#/definitions/overrideLabels"
},
"duration": {
"type": "number",
@@ -1206,7 +1206,7 @@
"x-go-name": "Health"
},
"labels": {
"$ref": "#/definitions/labels"
"$ref": "#/definitions/overrideLabels"
},
"lastError": {
"type": "string",
@@ -1611,6 +1611,13 @@
},
"x-go-name": "SlackConfigs"
},
"sns_configs": {
"type": "array",
"items": {
"$ref": "#/definitions/SNSConfig"
},
"x-go-name": "SNSConfigs"
},
"victorops_configs": {
"type": "array",
"items": {
@@ -2168,6 +2175,10 @@
},
"x-go-package": "github.com/prometheus/common/config"
},
"ObjectMatchers": {
"description": "ObjectMatchers is Matchers with a different Unmarshal and Marshal methods that accept matchers as objects\nthat have already been parsed.",
"$ref": "#/definitions/Matchers"
},
"OpsGenieConfig": {
"type": "object",
"title": "OpsGenieConfig configures notifications via OpsGenie.",
@@ -2222,6 +2233,10 @@
"tags": {
"type": "string",
"x-go-name": "Tags"
},
"update_alerts": {
"type": "boolean",
"x-go-name": "UpdateAlerts"
}
},
"x-go-package": "github.com/prometheus/alertmanager/config"
@@ -2459,6 +2474,13 @@
},
"x-go-name": "SlackConfigs"
},
"sns_configs": {
"type": "array",
"items": {
"$ref": "#/definitions/SNSConfig"
},
"x-go-name": "SNSConfigs"
},
"victorops_configs": {
"type": "array",
"items": {
@@ -2753,6 +2775,13 @@
},
"x-go-name": "SlackConfigs"
},
"sns_configs": {
"type": "array",
"items": {
"$ref": "#/definitions/SNSConfig"
},
"x-go-name": "SNSConfigs"
},
"victorops_configs": {
"type": "array",
"items": {
@@ -2807,8 +2836,8 @@
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"Route": {
"description": "A Route is a node that contains definitions of how to handle alerts. This is modified\nfrom the upstream alertmanager in that it adds the ObjectMatchers property.",
"type": "object",
"title": "A Route is a node that contains definitions of how to handle alerts.",
"properties": {
"continue": {
"type": "boolean",
@@ -2848,6 +2877,9 @@
},
"x-go-name": "MuteTimeIntervals"
},
"object_matchers": {
"$ref": "#/definitions/ObjectMatchers"
},
"receiver": {
"type": "string",
"x-go-name": "Receiver"
@@ -2863,7 +2895,7 @@
"x-go-name": "Routes"
}
},
"x-go-package": "github.com/prometheus/alertmanager/config"
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"Rule": {
"description": "adapted from cortex",
@@ -2885,7 +2917,7 @@
"x-go-name": "Health"
},
"labels": {
"$ref": "#/definitions/labels"
"$ref": "#/definitions/overrideLabels"
},
"lastError": {
"type": "string",
@@ -3017,6 +3049,53 @@
"title": "RuleType models the type of a rule.",
"x-go-package": "github.com/prometheus/client_golang/api/prometheus/v1"
},
"SNSConfig": {
"type": "object",
"properties": {
"api_url": {
"type": "string",
"x-go-name": "APIUrl"
},
"attributes": {
"type": "object",
"additionalProperties": {
"type": "string"
},
"x-go-name": "Attributes"
},
"http_config": {
"$ref": "#/definitions/HTTPClientConfig"
},
"message": {
"type": "string",
"x-go-name": "Message"
},
"phone_number": {
"type": "string",
"x-go-name": "PhoneNumber"
},
"send_resolved": {
"type": "boolean",
"x-go-name": "VSendResolved"
},
"sigv4": {
"$ref": "#/definitions/SigV4Config"
},
"subject": {
"type": "string",
"x-go-name": "Subject"
},
"target_arn": {
"type": "string",
"x-go-name": "TargetARN"
},
"topic_arn": {
"type": "string",
"x-go-name": "TopicARN"
}
},
"x-go-package": "github.com/prometheus/alertmanager/config"
},
"Sample": {
"type": "object",
"title": "Sample is a single sample belonging to a metric.",
@@ -3044,6 +3123,28 @@
"title": "SecretURL is a URL that must not be revealed on marshaling.",
"$ref": "#/definitions/URL"
},
"SigV4Config": {
"description": "SigV4Config is the configuration for signing remote write requests with\nAWS's SigV4 verification process. Empty values will be retrieved using the\nAWS default credentials chain.",
"type": "object",
"properties": {
"AccessKey": {
"type": "string"
},
"Profile": {
"type": "string"
},
"Region": {
"type": "string"
},
"RoleARN": {
"type": "string"
},
"SecretKey": {
"$ref": "#/definitions/Secret"
}
},
"x-go-package": "github.com/prometheus/common/sigv4"
},
"SlackAction": {
"description": "See https://api.slack.com/docs/message-attachments#action_fields and https://api.slack.com/docs/message-buttons\nfor more information.",
"type": "object",
@@ -3552,7 +3653,6 @@
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
},
"alertGroup": {
"description": "AlertGroup alert group",
"type": "object",
"required": [
"alerts",
@@ -3575,14 +3675,17 @@
"$ref": "#/definitions/receiver"
}
},
"x-go-name": "AlertGroup",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models",
"$ref": "#/definitions/alertGroup"
},
"alertGroups": {
"description": "AlertGroups alert groups",
"type": "array",
"items": {
"$ref": "#/definitions/alertGroup"
},
"x-go-name": "AlertGroups",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models",
"$ref": "#/definitions/alertGroups"
},
"alertStatus": {
@@ -3703,6 +3806,7 @@
"$ref": "#/definitions/Duration"
},
"gettableAlert": {
"description": "GettableAlert gettable alert",
"type": "object",
"required": [
"labels",
@@ -3762,17 +3866,14 @@
"x-go-name": "UpdatedAt"
}
},
"x-go-name": "GettableAlert",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models",
"$ref": "#/definitions/gettableAlert"
},
"gettableAlerts": {
"description": "GettableAlerts gettable alerts",
"type": "array",
"items": {
"$ref": "#/definitions/gettableAlert"
},
"x-go-name": "GettableAlerts",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models",
"$ref": "#/definitions/gettableAlerts"
},
"gettableSilence": {
@@ -3833,12 +3934,11 @@
"$ref": "#/definitions/gettableSilence"
},
"gettableSilences": {
"description": "GettableSilences gettable silences",
"type": "array",
"items": {
"$ref": "#/definitions/gettableSilence"
},
"x-go-name": "GettableSilences",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models",
"$ref": "#/definitions/gettableSilences"
},
"labelSet": {
@@ -3850,15 +3950,6 @@
"x-go-name": "LabelSet",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
},
"labels": {
"description": "The custom marshaling for labels.Labels ends up doing this anyways.",
"type": "object",
"title": "override the labels type with a map for generation.",
"additionalProperties": {
"type": "string"
},
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"matcher": {
"description": "Matcher matcher",
"type": "object",
@@ -3901,6 +3992,15 @@
"x-go-name": "Matchers",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
},
"overrideLabels": {
"description": "The custom marshaling for labels.Labels ends up doing this anyways.",
"type": "object",
"title": "override the labels type with a map for generation.",
"additionalProperties": {
"type": "string"
},
"x-go-package": "github.com/grafana/grafana/pkg/services/ngalert/api/tooling/definitions"
},
"peerStatus": {
"description": "PeerStatus peer status",
"type": "object",
@@ -3968,7 +4068,6 @@
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models"
},
"postableSilence": {
"description": "PostableSilence postable silence",
"type": "object",
"required": [
"comment",
@@ -4009,9 +4108,12 @@
"x-go-name": "StartsAt"
}
},
"x-go-name": "PostableSilence",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models",
"$ref": "#/definitions/postableSilence"
},
"receiver": {
"description": "Receiver receiver",
"type": "object",
"required": [
"name"
@@ -4023,8 +4125,6 @@
"x-go-name": "Name"
}
},
"x-go-name": "Receiver",
"x-go-package": "github.com/prometheus/alertmanager/api/v2/models",
"$ref": "#/definitions/receiver"
},
"silence": {