mirror of
https://github.com/prometheus/alertmanager
synced 2025-02-16 10:37:09 +00:00
Avoid logging the entire message after truncation
Signed-off-by: Alex Weaver <weaver.alex.d@gmail.com>
This commit is contained in:
parent
bb5804eca9
commit
ed3cfbb124
@ -174,7 +174,7 @@ func (n *Notifier) createRequests(ctx context.Context, as ...*types.Alert) ([]*h
|
||||
// https://docs.opsgenie.com/docs/alert-api - 130 characters meaning runes.
|
||||
message, truncated := notify.TruncateInRunes(tmpl(n.conf.Message), 130)
|
||||
if truncated {
|
||||
level.Warn(n.logger).Log("msg", "truncated message", "truncated_message", message, "alert", key)
|
||||
level.Debug(n.logger).Log("msg", "Truncated message", "alert", key)
|
||||
}
|
||||
|
||||
createEndpointURL := n.conf.APIURL.Copy()
|
||||
|
@ -152,7 +152,7 @@ func (n *Notifier) notifyV1(
|
||||
// https://developer.pagerduty.com/docs/ZG9jOjExMDI5NTgx-send-an-alert-event - 1204 characters or runes.
|
||||
description, truncated := notify.TruncateInRunes(tmpl(n.conf.Description), 1024)
|
||||
if truncated {
|
||||
level.Warn(n.logger).Log("msg", "Truncated description", "description", description, "key", key)
|
||||
level.Warn(n.logger).Log("msg", "Truncated description", "key", key)
|
||||
}
|
||||
|
||||
serviceKey := string(n.conf.ServiceKey)
|
||||
@ -218,7 +218,7 @@ func (n *Notifier) notifyV2(
|
||||
// https://developer.pagerduty.com/docs/ZG9jOjExMDI5NTgx-send-an-alert-event - 1204 characters or runes.
|
||||
summary, truncated := notify.TruncateInRunes(tmpl(n.conf.Description), 1024)
|
||||
if truncated {
|
||||
level.Warn(n.logger).Log("msg", "Truncated summary", "summary", summary, "key", key)
|
||||
level.Warn(n.logger).Log("msg", "Truncated summary", "key", key)
|
||||
}
|
||||
|
||||
routingKey := string(n.conf.RoutingKey)
|
||||
|
@ -81,7 +81,7 @@ func (n *Notifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)
|
||||
// https://pushover.net/api#limits - 250 characters or runes.
|
||||
title, truncated := notify.TruncateInRunes(tmpl(n.conf.Title), 250)
|
||||
if truncated {
|
||||
level.Warn(n.logger).Log("msg", "Truncated title", "truncated_title", title, "incident", key)
|
||||
level.Warn(n.logger).Log("msg", "Truncated title", "incident", key)
|
||||
}
|
||||
parameters.Add("title", title)
|
||||
|
||||
@ -95,7 +95,7 @@ func (n *Notifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)
|
||||
// https://pushover.net/api#limits - 1024 characters or runes.
|
||||
message, truncated = notify.TruncateInRunes(message, 1024)
|
||||
if truncated {
|
||||
level.Warn(n.logger).Log("msg", "Truncated message", "truncated_message", message, "incident", key)
|
||||
level.Warn(n.logger).Log("msg", "Truncated message", "incident", key)
|
||||
}
|
||||
message = strings.TrimSpace(message)
|
||||
if message == "" {
|
||||
@ -107,7 +107,7 @@ func (n *Notifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)
|
||||
// https://pushover.net/api#limits - 512 characters or runes.
|
||||
supplementaryURL, truncated := notify.TruncateInRunes(tmpl(n.conf.URL), 512)
|
||||
if truncated {
|
||||
level.Warn(n.logger).Log("msg", "Truncated URL", "truncated_url", supplementaryURL, "incident", key)
|
||||
level.Warn(n.logger).Log("msg", "Truncated URL", "incident", key)
|
||||
}
|
||||
parameters.Add("url", supplementaryURL)
|
||||
parameters.Add("url_title", tmpl(n.conf.URLTitle))
|
||||
|
@ -106,7 +106,7 @@ func (n *Notifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
level.Warn(n.logger).Log("msg", "Truncated title", "text", title, "key", key)
|
||||
level.Warn(n.logger).Log("msg", "Truncated title", "key", key)
|
||||
}
|
||||
att := &attachment{
|
||||
Title: title,
|
||||
|
@ -68,7 +68,7 @@ func (n *Notifier) Notify(ctx context.Context, alert ...*types.Alert) (bool, err
|
||||
// Telegram supports 4096 chars max - from https://limits.tginfo.me/en.
|
||||
messageText, truncated := notify.TruncateInRunes(tmpl(n.conf.Message), 4096)
|
||||
if truncated {
|
||||
level.Warn(n.logger).Log("msg", "truncated message", "truncated_message", messageText)
|
||||
level.Warn(n.logger).Log("msg", "Truncated message")
|
||||
}
|
||||
|
||||
message, err := n.client.Send(telebot.ChatID(n.conf.ChatID), messageText, &telebot.SendOptions{
|
||||
|
@ -137,7 +137,7 @@ func (n *Notifier) createVictorOpsPayload(ctx context.Context, as ...*types.Aler
|
||||
// https://help.victorops.com/knowledge-base/incident-fields-glossary/ - 20480 characters.
|
||||
stateMessage, truncated := notify.TruncateInRunes(stateMessage, 20480)
|
||||
if truncated {
|
||||
level.Warn(n.logger).Log("msg", "truncated stateMessage", "truncated_state_message", stateMessage, "incident", key)
|
||||
level.Warn(n.logger).Log("msg", "truncated stateMessage", "incident", key)
|
||||
}
|
||||
|
||||
msg := map[string]string{
|
||||
|
Loading…
Reference in New Issue
Block a user