alerting
alerting copied to clipboard
Add support for custom dialers with remaining integrations
Followup to https://github.com/grafana/alerting/pull/317 with support for mqtt, sns, slack, and prometheus-alertmanager.
This was split out because each of these has some non-standard http.Client that needs to be extended or standardized to use the same Client as the other integrations.
Draft for now as it needs some more testing. More easily reviewed by commit.
- MQTT: Can't use an
http.clientdirectly, requires passing in the actualDialer. This is the reason we usenet.Dialerinstead ofDialContextFuncin client configuration. 892915ab9a8c773cf5340e3f5473ebd356998f36 - Slack: Was instrumented with a series of functions, one for each request type, and used a global
http.Client. We swap the global client for a passed in one retrieved from the standardWebhookSender. This allows minimal changes in the implementation. Also, re-organized the individual send functions into an interface for easier testability. 99d2029775a01354d8c3de77344bd08773fcce29 - Alertmanager: Was using a completely separate
SendHTTPRequestfunction. Replaced with the standardClient. f0e9f8dc2ecbc1a1ea1762c41e3d245e10b8077f - SNS: Passes in an
http.Clientretrieved from the standardWebhookSender, this can be passed in via config to use as the base client for theSNSclient. This in particular needs more testing. 9764c81d982db6bd3dcf78a10996d25a2cab6e75 - Jira: Includes a small refactor to remove the
ForkedSenderused byJira. It existed mostly to addGETsupport for only that integration, instead we extend the baseClientand allowGETwith aClientOptiononly used byJira. 335e6f7684c3f822faf1156dc92d857a9f8cbd57
These changes help improve the standardization of clients across various integrations. Further efforts, such as standardizing <integration>.New() functions, moving more common integration configurations into receivers.Base, and unifying TLS, HMAC, and similar settings, will enhance consistency even more.