From 3f4c9879c9df430a07843fb52a5cd046574d2e66 Mon Sep 17 00:00:00 2001 From: Santiago Date: Wed, 8 Oct 2025 13:13:02 +0200 Subject: [PATCH] Remote Alertmanager: Add timeout to the remoteClient (#112157) --- pkg/services/ngalert/remote/alertmanager.go | 1 + pkg/services/ngalert/remote/client/mimir.go | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/services/ngalert/remote/alertmanager.go b/pkg/services/ngalert/remote/alertmanager.go index 8cde9ee198f..78fbbfe3a5b 100644 --- a/pkg/services/ngalert/remote/alertmanager.go +++ b/pkg/services/ngalert/remote/alertmanager.go @@ -139,6 +139,7 @@ func NewAlertmanager(ctx context.Context, cfg AlertmanagerConfig, store stateSto Logger: logger, Password: cfg.BasicAuthPassword, TenantID: cfg.TenantID, + Timeout: cfg.Timeout, URL: u, } mc, err := remoteClient.New(mcCfg, metrics, tracer) diff --git a/pkg/services/ngalert/remote/client/mimir.go b/pkg/services/ngalert/remote/client/mimir.go index 6e19d5eb65f..c2e89aa1c53 100644 --- a/pkg/services/ngalert/remote/client/mimir.go +++ b/pkg/services/ngalert/remote/client/mimir.go @@ -11,6 +11,7 @@ import ( "net/url" "path" "strings" + "time" alertingNotify "github.com/grafana/alerting/notify" @@ -65,7 +66,8 @@ type Config struct { TenantID string Password string - Logger log.Logger + Logger log.Logger + Timeout time.Duration } // successResponse represents a successful response from the Mimir API. @@ -98,6 +100,7 @@ func New(cfg *Config, metrics *metrics.RemoteAlertmanager, tracer tracing.Tracer c := &http.Client{ Transport: rt, + Timeout: cfg.Timeout, } tc := alertingInstrument.NewTimedClient(c, metrics.RequestLatency) trc := alertingInstrument.NewTracedClient(tc, tracer, "remote.alertmanager.client")