Remote Alertmanager: Make timeout configurable in alert senders (#105599)
This commit is contained in:
@@ -167,7 +167,7 @@ func NewAlertmanager(ctx context.Context, cfg AlertmanagerConfig, store stateSto
|
||||
return nil, err
|
||||
}
|
||||
s.Run()
|
||||
err = s.ApplyConfig(cfg.OrgID, 0, []sender.ExternalAMcfg{{URL: cfg.URL + "/alertmanager"}})
|
||||
err = s.ApplyConfig(cfg.OrgID, 0, []sender.ExternalAMcfg{{URL: cfg.URL + "/alertmanager", Timeout: cfg.Timeout}})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -46,6 +46,7 @@ type ExternalAlertmanager struct {
|
||||
type ExternalAMcfg struct {
|
||||
URL string
|
||||
Headers http.Header
|
||||
Timeout time.Duration
|
||||
}
|
||||
|
||||
type Option func(*ExternalAlertmanager)
|
||||
@@ -229,11 +230,16 @@ func buildNotifierConfig(alertmanagers []ExternalAMcfg) (*config.Config, map[str
|
||||
},
|
||||
}
|
||||
|
||||
timeout := am.Timeout
|
||||
if timeout == 0 {
|
||||
timeout = defaultTimeout
|
||||
}
|
||||
|
||||
amConfig := &config.AlertmanagerConfig{
|
||||
APIVersion: config.AlertmanagerAPIVersionV2,
|
||||
Scheme: u.Scheme,
|
||||
PathPrefix: u.Path,
|
||||
Timeout: model.Duration(defaultTimeout),
|
||||
Timeout: model.Duration(timeout),
|
||||
ServiceDiscoveryConfigs: sdConfig,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user