diff --git a/config.example.yml b/config.example.yml index 3c5ccc2..526457e 100644 --- a/config.example.yml +++ b/config.example.yml @@ -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 diff --git a/internal/api/alertmanager/handler.go b/internal/api/alertmanager/handler.go index 07436b8..cb634a9 100644 --- a/internal/api/alertmanager/handler.go +++ b/internal/api/alertmanager/handler.go @@ -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") }