Handle lables and annotations

This commit is contained in:
cubicroot 2022-04-21 18:52:57 +02:00
parent d1002b0488
commit 64583e3710
2 changed files with 6 additions and 4 deletions

View file

@ -63,7 +63,7 @@ formatting:
# This settings are only relevant if you want to use PushBits with alertmanager
alertmanager:
# The name of the entry in the alerts annotations that should be used for the title
# The name of the entry in the alerts annotations or lables that should be used for the title
annotationtitle: title
# The name of the entry in the alerts annotations that should be used for the message
# The name of the entry in the alerts annotations or labels that should be used for the message
annotationmessage: message

View file

@ -95,14 +95,16 @@ func (alert *alert) ToNotification(titleAnnotation, messageAnnotation string) mo
if titleString, ok := alert.Annotiations[titleAnnotation]; ok {
title.WriteString(titleString)
} else if titleString, ok := alert.Labels[titleAnnotation]; ok {
title.WriteString(titleString)
} else {
title.WriteString("Unknown Title")
}
title.WriteString(" - ")
title.WriteString(alert.StartsAt)
if messageString, ok := alert.Annotiations[messageAnnotation]; ok {
message.WriteString(messageString)
} else if messageString, ok := alert.Labels[messageAnnotation]; ok {
message.WriteString(messageString)
} else {
message.WriteString("Unknown Message")
}