mirror of
https://github.com/pushbits/server.git
synced 2025-05-05 21:26:25 +02:00
Handle lables and annotations
This commit is contained in:
parent
d1002b0488
commit
64583e3710
2 changed files with 6 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue