Alerting: Expose info about notification delivery errors in a new /receivers endpoint (#55429)

* (WIP) switch to fork AM, first implementation of the API, generate spec

* get receivers avoiding race conditions

* use latest version of our forked AM, tests

* make linter happy, delete TODO comment

* update number of expected paths to += 2

* delete unused endpoint code, code review comments, tests

* Update pkg/services/ngalert/notifier/alertmanager.go

Co-authored-by: Matthew Jacobson <matthew.jacobson@grafana.com>

* remove call to fmt.Println

* clear naming for fields

* shorter variable names in GetReceivers

Co-authored-by: Matthew Jacobson <matthew.jacobson@grafana.com>
This commit is contained in:
Santiago
2022-10-03 10:58:41 -03:00
committed by GitHub
parent 1e16dd5b7c
commit 09f8e026a1
17 changed files with 667 additions and 454 deletions
+83 -107
View File
@@ -260,7 +260,7 @@
"type": "string"
},
"for": {
"$ref": "#/definitions/Duration"
"type": "string"
},
"labels": {
"additionalProperties": {
@@ -378,25 +378,6 @@
"title": "DataTopic is used to identify which topic the frame should be assigned to.",
"type": "string"
},
"DateTime": {
"description": "DateTime is a time but it serializes to ISO8601 format with millis\nIt knows how to read 3 different variations of a RFC3339 date time.\nMost APIs we encounter want either millisecond or second precision times.\nThis just tries to make it worry-free.",
"format": "date-time",
"type": "string"
},
"DayOfMonthRange": {
"properties": {
"Begin": {
"format": "int64",
"type": "integer"
},
"End": {
"format": "int64",
"type": "integer"
}
},
"title": "A DayOfMonthRange is an inclusive range that may have negative Beginning/End values that represent distance from the End of the month Beginning at -1.",
"type": "object"
},
"DiscoveryBase": {
"properties": {
"error": {
@@ -625,16 +606,12 @@
"FieldConfig": {
"properties": {
"color": {
"additionalProperties": {
"type": "object"
},
"additionalProperties": {},
"description": "Map values to a display color\nNOTE: this interface is under development in the frontend... so simple map for now",
"type": "object"
},
"custom": {
"additionalProperties": {
"type": "object"
},
"additionalProperties": {},
"description": "Panel Specific Values",
"type": "object"
},
@@ -742,8 +719,7 @@
"type": "string"
},
"custom": {
"description": "Custom datasource specific values.",
"type": "object"
"description": "Custom datasource specific values."
},
"dataTopic": {
"$ref": "#/definitions/DataTopic"
@@ -939,7 +915,7 @@
"type": "string"
},
"for": {
"$ref": "#/definitions/Duration"
"type": "string"
},
"grafana_alert": {
"$ref": "#/definitions/GettableGrafanaRule"
@@ -1239,6 +1215,10 @@
"description": "The bearer token file for the targets. Deprecated in favour of\nAuthorization.CredentialsFile.",
"type": "string"
},
"enable_http2": {
"description": "EnableHTTP2 specifies whether the client should configure HTTP2.\nThe omitempty flag is not set, because it would be hidden from the\nmarshalled configuration when set to false.",
"type": "boolean"
},
"follow_redirects": {
"description": "FollowRedirects specifies whether the client should follow HTTP 3xx redirects.\nThe omitempty flag is not set, because it would be hidden from the\nmarshalled configuration when set to false.",
"type": "boolean"
@@ -1268,20 +1248,6 @@
"title": "HostPort represents a \"host:port\" network address.",
"type": "object"
},
"InclusiveRange": {
"properties": {
"Begin": {
"format": "int64",
"type": "integer"
},
"End": {
"format": "int64",
"type": "integer"
}
},
"title": "InclusiveRange is used to hold the Beginning and End values of many time interval components.",
"type": "object"
},
"InhibitRule": {
"description": "InhibitRule defines an inhibition rule that mutes alerts that match the\ntarget labels if an alert matching the source labels exists.\nBoth alerts have to have a set of labels being equal.",
"properties": {
@@ -1501,20 +1467,6 @@
},
"type": "array"
},
"MonthRange": {
"properties": {
"Begin": {
"format": "int64",
"type": "integer"
},
"End": {
"format": "int64",
"type": "integer"
}
},
"title": "A MonthRange is an inclusive range between [1, 12] where 1 = January.",
"type": "object"
},
"MultiStatus": {
"type": "object"
},
@@ -1605,6 +1557,9 @@
},
"type": "object"
},
"proxy_url": {
"$ref": "#/definitions/URL"
},
"scopes": {
"items": {
"type": "string"
@@ -1931,7 +1886,7 @@
"type": "string"
},
"for": {
"$ref": "#/definitions/Duration"
"type": "string"
},
"grafana_alert": {
"$ref": "#/definitions/PostableGrafanaRule"
@@ -2220,7 +2175,7 @@
"PushoverConfig": {
"properties": {
"expire": {
"$ref": "#/definitions/duration"
"type": "string"
},
"html": {
"type": "boolean"
@@ -2235,7 +2190,7 @@
"type": "string"
},
"retry": {
"$ref": "#/definitions/duration"
"type": "string"
},
"send_resolved": {
"type": "boolean"
@@ -2265,16 +2220,12 @@
"description": "The embedded FieldConfig's display name must be set.\nIt corresponds to the QueryResultMetaStat on the frontend (https://github.com/grafana/grafana/blob/master/packages/grafana-data/src/types/data.ts#L53).",
"properties": {
"color": {
"additionalProperties": {
"type": "object"
},
"additionalProperties": {},
"description": "Map values to a display color\nNOTE: this interface is under development in the frontend... so simple map for now",
"type": "object"
},
"custom": {
"additionalProperties": {
"type": "object"
},
"additionalProperties": {},
"description": "Panel Specific Values",
"type": "object"
},
@@ -2462,10 +2413,10 @@
"type": "array"
},
"group_interval": {
"$ref": "#/definitions/Duration"
"type": "string"
},
"group_wait": {
"$ref": "#/definitions/Duration"
"type": "string"
},
"match": {
"additionalProperties": {
@@ -2496,7 +2447,7 @@
"type": "string"
},
"repeat_interval": {
"$ref": "#/definitions/Duration"
"type": "string"
},
"routes": {
"items": {
@@ -2897,6 +2848,9 @@
"description": "The client key file for the targets.",
"type": "string"
},
"min_version": {
"$ref": "#/definitions/TLSVersion"
},
"server_name": {
"description": "Used to verify the hostname for the targets.",
"type": "string"
@@ -2905,6 +2859,10 @@
"title": "TLSConfig configures the options for TLS connections.",
"type": "object"
},
"TLSVersion": {
"format": "uint16",
"type": "integer"
},
"TelegramConfig": {
"properties": {
"api_url": {
@@ -3073,13 +3031,13 @@
"properties": {
"days_of_month": {
"items": {
"$ref": "#/definitions/DayOfMonthRange"
"type": "string"
},
"type": "array"
},
"months": {
"items": {
"$ref": "#/definitions/MonthRange"
"type": "string"
},
"type": "array"
},
@@ -3091,13 +3049,13 @@
},
"weekdays": {
"items": {
"$ref": "#/definitions/WeekdayRange"
"type": "string"
},
"type": "array"
},
"years": {
"items": {
"$ref": "#/definitions/YearRange"
"type": "string"
},
"type": "array"
}
@@ -3120,7 +3078,6 @@
"type": "object"
},
"URL": {
"description": "The general form represented is:\n\n[scheme:][//[userinfo@]host][/]path[?query][#fragment]\n\nURLs that do not start with a slash after the scheme are interpreted as:\n\nscheme:opaque[?query][#fragment]\n\nNote that the Path field is stored in decoded form: /%47%6f%2f becomes /Go/.\nA consequence is that it is impossible to tell which slashes in the Path were\nslashes in the raw URL and which were %2f. This distinction is rarely important,\nbut when it is, the code should use RawPath, an optional field which only gets\nset if the default encoding is different from Path.\n\nURL's String method uses the EscapedPath method to obtain the path. See the\nEscapedPath method for more details.",
"properties": {
"ForceQuery": {
"type": "boolean"
@@ -3131,6 +3088,9 @@
"Host": {
"type": "string"
},
"OmitHost": {
"type": "boolean"
},
"Opaque": {
"type": "string"
},
@@ -3153,7 +3113,7 @@
"$ref": "#/definitions/Userinfo"
}
},
"title": "A URL represents a parsed URL (technically, a URI reference).",
"title": "URL is a custom URL type that allows validation at configuration load time.",
"type": "object"
},
"Userinfo": {
@@ -3291,34 +3251,6 @@
"title": "WechatConfig configures notifications via Wechat.",
"type": "object"
},
"WeekdayRange": {
"properties": {
"Begin": {
"format": "int64",
"type": "integer"
},
"End": {
"format": "int64",
"type": "integer"
}
},
"title": "A WeekdayRange is an inclusive range between [0, 6] where 0 = Sunday.",
"type": "object"
},
"YearRange": {
"properties": {
"Begin": {
"format": "int64",
"type": "integer"
},
"End": {
"format": "int64",
"type": "integer"
}
},
"title": "A YearRange is a positive inclusive range.",
"type": "object"
},
"alert": {
"description": "Alert alert",
"properties": {
@@ -3361,6 +3293,7 @@
"type": "object"
},
"alertGroups": {
"description": "AlertGroups alert groups",
"items": {
"$ref": "#/definitions/alertGroup"
},
@@ -3464,10 +3397,8 @@
],
"type": "object"
},
"duration": {
"$ref": "#/definitions/Duration"
},
"gettableAlert": {
"description": "GettableAlert gettable alert",
"properties": {
"annotations": {
"$ref": "#/definitions/labelSet"
@@ -3530,6 +3461,7 @@
"type": "array"
},
"gettableSilence": {
"description": "GettableSilence gettable silence",
"properties": {
"comment": {
"description": "comment",
@@ -3578,11 +3510,42 @@
"type": "object"
},
"gettableSilences": {
"description": "GettableSilences gettable silences",
"items": {
"$ref": "#/definitions/gettableSilence"
},
"type": "array"
},
"integration": {
"properties": {
"lastNotifyAttempt": {
"description": "A timestamp indicating the last attempt to deliver a notification regardless of the outcome.\nFormat: date-time",
"format": "date-time",
"type": "string"
},
"lastNotifyAttemptDuration": {
"description": "Duration of the last attempt to deliver a notification in humanized format (`1s` or `15ms`, etc).",
"type": "string"
},
"lastNotifyAttemptError": {
"description": "Error string for the last attempt to deliver a notification. Empty if the last attempt was successful.",
"type": "string"
},
"name": {
"description": "name",
"type": "string"
},
"sendResolved": {
"description": "send resolved",
"type": "boolean"
}
},
"required": [
"name",
"sendResolved"
],
"type": "object"
},
"labelSet": {
"additionalProperties": {
"type": "string"
@@ -3688,6 +3651,7 @@
"type": "array"
},
"postableSilence": {
"description": "PostableSilence postable silence",
"properties": {
"comment": {
"description": "comment",
@@ -3725,14 +3689,26 @@
"type": "object"
},
"receiver": {
"description": "Receiver receiver",
"properties": {
"active": {
"description": "active",
"type": "boolean"
},
"integrations": {
"description": "integrations",
"items": {
"$ref": "#/definitions/integration"
},
"type": "array"
},
"name": {
"description": "name",
"type": "string"
}
},
"required": [
"active",
"integrations",
"name"
],
"type": "object"