Skip to content

SigNoz is an open-source, OpenTelemetry-native observability platform for your team and their AI agents. Get logs, metrics, and traces in one tool with features like APM, distributed tracing, log management, infra monitoring, etc. Combined with SigNoz MCP and a native AI teammate (in SigNoz Cloud) it helps you build more resilient apps.

fix(alertmanager): remove threading from google chat notifier (#12609)

Nikhil Mantri7e2cd441f2ec
diff --git a/pkg/alertmanager/alertmanagernotify/googlechat/googlechat.go b/pkg/alertmanager/alertmanagernotify/googlechat/googlechat.go
index 25875bf627..765e4586f0 100644
--- a/pkg/alertmanager/alertmanagernotify/googlechat/googlechat.go
+++ b/pkg/alertmanager/alertmanagernotify/googlechat/googlechat.go
@@ -7,7 +7,6 @@ import (
"fmt"
"log/slog"
"net/http"
- "net/url"
"unicode/utf8"
"github.com/SigNoz/signoz/pkg/alertmanager/alertmanagertemplate"
@@ -186,18 +185,7 @@ func (n *Notifier) Notify(ctx context.Context, alerts ...*types.Alert) (bool, er
}
}
- // Thread same-rule alerts together: threadKey is a stable hash of the
- // alert group key. Changing a rule's grouping starts a new thread.
- u, err := url.Parse(n.conf.WebhookURL.String())
- if err != nil {
- return false, errors.WrapInternalf(err, errors.CodeInternal, "parse google chat webhook url")
- }
- q := u.Query()
- q.Set("threadKey", key.Hash())
- q.Set("messageReplyOption", "REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD")
- u.RawQuery = q.Encode()
-
- resp, err := notify.PostJSON(ctx, n.client, u.String(), buf) //nolint:bodyclose
+ resp, err := notify.PostJSON(ctx, n.client, n.conf.WebhookURL.String(), buf) //nolint:bodyclose
if err != nil {
return true, notify.RedactURL(err)
}
diff --git a/pkg/alertmanager/alertmanagernotify/googlechat/googlechat_test.go b/pkg/alertmanager/alertmanagernotify/googlechat/googlechat_test.go
index 335fcbde0e..d4bc656f16 100644
--- a/pkg/alertmanager/alertmanagernotify/googlechat/googlechat_test.go
+++ b/pkg/alertmanager/alertmanagernotify/googlechat/googlechat_test.go
@@ -245,7 +245,7 @@ func TestGoogleChatMessageSizeLimit(t *testing.T) {
assert.LessOrEqual(t, bodyLen, maxMessageBytes, "posted body must be within the size limit")
}
-func TestGoogleChatThreading(t *testing.T) {
+func TestGoogleChatWebhookURLVerbatim(t *testing.T) {
var query url.Values
server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
query = r.URL.Query()
@@ -253,25 +253,11 @@ func TestGoogleChatThreading(t *testing.T) {
}))
defer server.Close()
- cases := []struct{ name, groupKey string }{
- {"rule a", "{ruleId=\"aaa\"}"},
- {"rule b", "{ruleId=\"bbb\"}"},
- }
- seen := map[string]string{}
- for _, c := range cases {
- t.Run(c.name, func(t *testing.T) {
- n := newTestNotifier(t, server.URL, "T", "")
- ctx := notify.WithGroupKey(context.Background(), c.groupKey)
- _, err := n.Notify(ctx, newTestAlerts("X")...)
- require.NoError(t, err)
+ n := newTestNotifier(t, server.URL+"?key=abc&token=xyz", "T", "")
+ _, err := n.Notify(newTestContext(), newTestAlerts("X")...)
+ require.NoError(t, err)
- assert.Equal(t, "REPLY_MESSAGE_FALLBACK_TO_NEW_THREAD", query.Get("messageReplyOption"))
- threadKey := query.Get("threadKey")
- assert.Equal(t, notify.Key(c.groupKey).Hash(), threadKey, "threadKey must be the group key hash")
- seen[c.name] = threadKey
- })
- }
- assert.NotEqual(t, seen["rule a"], seen["rule b"], "distinct group keys must yield distinct threadKeys")
+ assert.Equal(t, url.Values{"key": {"abc"}, "token": {"xyz"}}, query, "configured webhook URL must be posted verbatim, with no params added")
}
func TestGoogleChatCustomTemplateMarkdown(t *testing.T) {