diff --git a/README.md b/README.md index cb139c4f..60f43dae 100644 --- a/README.md +++ b/README.md @@ -779,6 +779,7 @@ Here's an example of what the notifications look like: | `alerting.telegram.token` | Telegram Bot Token | Required `""` | | `alerting.telegram.id` | Telegram User ID | Required `""` | | `alerting.telegram.api-url` | Telegram API URL | `https://api.telegram.org` | +| `alerting.telegram.client` | Client configuration.
See [Client configuration](#client-configuration). | `{}` | | `alerting.telegram.default-alert` | Default alert configuration.
See [Setting a default alert](#setting-a-default-alert) | N/A | ```yaml diff --git a/alerting/provider/telegram/telegram.go b/alerting/provider/telegram/telegram.go index 963b5f79..bfa5209d 100644 --- a/alerting/provider/telegram/telegram.go +++ b/alerting/provider/telegram/telegram.go @@ -19,12 +19,18 @@ type AlertProvider struct { ID string `yaml:"id"` APIURL string `yaml:"api-url"` + // ClientConfig is the configuration of the client used to communicate with the provider's target + ClientConfig *client.Config `yaml:"client,omitempty"` + // DefaultAlert is the default alert configuration to use for endpoints with an alert of the appropriate type DefaultAlert *alert.Alert `yaml:"default-alert,omitempty"` } // IsValid returns whether the provider's configuration is valid func (provider *AlertProvider) IsValid() bool { + if provider.ClientConfig == nil { + provider.ClientConfig = client.GetDefaultConfig() + } return len(provider.Token) > 0 && len(provider.ID) > 0 } @@ -40,7 +46,7 @@ func (provider *AlertProvider) Send(endpoint *core.Endpoint, alert *alert.Alert, return err } request.Header.Set("Content-Type", "application/json") - response, err := client.GetHTTPClient(nil).Do(request) + response, err := client.GetHTTPClient(provider.ClientConfig).Do(request) if err != nil { return err }