{"record":{"id":"897e2997868f01e2","repo":"thanos-io/thanos","slug":"send-request-to-q","errorCode":null,"errorMessage":"send request to %q","messagePattern":"send request to %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/alert/alert.go","lineNumber":394,"sourceCode":"\t\tdispatcher: dispatcher,\n\t\ttimeout:    timeout,\n\t\tversion:    version,\n\t}\n}\n\nfunc (a *Alertmanager) postAlerts(ctx context.Context, u url.URL, r io.Reader) error {\n\treq, err := http.NewRequest(\"POST\", u.String(), r)\n\tif err != nil {\n\t\treturn err\n\t}\n\tctx, cancel := context.WithTimeout(ctx, a.timeout)\n\tdefer cancel()\n\treq = req.WithContext(ctx)\n\treq.Header.Set(\"Content-Type\", contentTypeJSON)\n\n\tresp, err := a.dispatcher.Do(req)\n\tif err != nil {\n\t\treturn errors.Wrapf(err, \"send request to %q\", u.String())\n\t}\n\tdefer runutil.ExhaustCloseWithLogOnErr(a.logger, resp.Body, \"send one alert\")\n\n\tif resp.StatusCode/100 != 2 {\n\t\treturn errors.Errorf(\"bad response status %v from %q\", resp.Status, u.String())\n\t}\n\treturn nil\n}\n","sourceCodeStart":376,"sourceCodeEnd":403,"githubUrl":"https://github.com/thanos-io/thanos/blob/35b8b991177def87ed52dcf10f9b6d87f07282c8/pkg/alert/alert.go#L376-L403","documentation":"postAlerts sends alert batches over HTTP to the configured Alertmanager replicas. When the HTTP request itself fails (dial error, timeout, connection reset, TLS failure), the dispatcher error is wrapped with the target URL, producing 'send request to %q'. The underlying cause remains wrapped via pkg/errors so errors.Is/As still work.","triggerScenarios":"a.dispatcher.Do(req) returns an error: DNS failure, connection refused, request context canceled by the send timeout (defer cancel()), or TLS handshake failure while pushing alerts from the ruler/alertmanager to peer Alertmanagers.","commonSituations":"Alertmanager endpoints unreachable (wrong -alertmanager.url / cluster peers down); network partitions; firewalls blocking egress; alerts timing out because target Alertmanagers are overloaded.","solutions":["Check the wrapped cause and target URL in the message; verify the Alertmanager is reachable (curl the URL from the same host/network).","Confirm DNS, firewall, and TLS configuration for the alertmanager URLs.","Check whether the request was canceled by the send timeout and raise the timeout if targets are slow.","Ensure dispatcher/client settings (TLS, proxy, HTTP/2) match the Alertmanager deployment."],"exampleFix":"// before\nresp, err := a.dispatcher.Do(req)\nif err != nil {\n    return errors.Wrapf(err, \"send request to %q\", u.String())\n}\n// after — caller-side guard\nif err := sender.postAlerts(ctx, alerts); err != nil {\n    var netErr net.Error\n    if errors.As(err, &netErr) && netErr.Timeout() {\n        level.Warn(logger).Log(\"msg\", \"alert send timed out, will retry\", \"err\", err)\n    }\n    return err\n}","handlingStrategy":"retry","validationCode":"u, err := url.Parse(amURL)\nif err != nil || u.Scheme == \"\" || u.Host == \"\" {\n    return fmt.Errorf(\"invalid alertmanager url %q\", amURL)\n}\n// optionally: probe reachability with a HEAD/GET before alert push","typeGuard":null,"tryCatchPattern":"var nerr net.Error\nif errors.As(err, &nerr) && nerr.Timeout() {\n    // retry with backoff\n} else if isConnRefused(err) {\n    // alertmanager down: alert on infra, backoff\n}","preventionTips":["Health-check Alertmanager URLs before dispatch.","Set explicit send timeouts and retry with backoff for transient errors.","Keep dispatcher TLS/auth config in sync with target Alertmanager.","Monitor alert send failure rates and queue depth."],"tags":["network","http","alerts"],"backgroundTag":"http-request-failed","analyzedSha":"35b8b991177def87ed52dcf10f9b6d87f07282c8","analyzedAt":"2026-09-07T01:49:59.689Z","contentChangedAt":"2026-09-07T01:49:59.689Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}