Alerting: Ignore external alert sending errors when shutting down. (#102705)

This commit is contained in:
Steve Simpson
2025-03-25 13:50:23 +02:00
committed by GitHub
parent c34394f385
commit 0ffb7518cd
+3 -1
View File
@@ -10,6 +10,7 @@ import (
"bytes"
"context"
"encoding/json"
"errors"
"fmt"
"io"
"net/http"
@@ -145,7 +146,8 @@ func (n *Manager) sendAll(alerts ...*Alert) bool {
// Extension: added headers parameter.
go func(client *http.Client, url string, headers http.Header) {
if err := n.sendOne(ctx, client, url, payload, headers); err != nil {
// Treat cancellations as a success, so that we don't increment error or dropped counters.
if err := n.sendOne(ctx, client, url, payload, headers); err != nil && !errors.Is(err, context.Canceled) {
level.Error(n.logger).Log("alertmanager", url, "count", len(alerts), "msg", "Error sending alert", "err", err)
n.metrics.errors.WithLabelValues(url).Inc()
} else {