alerting icon indicating copy to clipboard operation
alerting copied to clipboard

Add support for custom dialers with remaining integrations

Open JacobsonMT opened this issue 7 months ago • 0 comments

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.client directly, requires passing in the actual Dialer. This is the reason we use net.Dialer instead of DialContextFunc in 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 standard WebhookSender. 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 SendHTTPRequest function. Replaced with the standard Client. f0e9f8dc2ecbc1a1ea1762c41e3d245e10b8077f
  • SNS: Passes in an http.Client retrieved from the standard WebhookSender, this can be passed in via config to use as the base client for the SNS client. This in particular needs more testing. 9764c81d982db6bd3dcf78a10996d25a2cab6e75
  • Jira: Includes a small refactor to remove the ForkedSender used by Jira. It existed mostly to add GET support for only that integration, instead we extend the base Client and allow GET with a ClientOption only used by Jira. 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.

JacobsonMT avatar May 01 '25 20:05 JacobsonMT