@@ -240,23 +240,23 @@ func (n *Notifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)
240
240
},
241
241
{
242
242
Title : "Alert" ,
243
- Value : data .CommonLabels [ "alertname" ] ,
243
+ Value : extractKV ( data .CommonLabels , "alertname" ) ,
244
244
},
245
245
{
246
246
Title : "Summary" ,
247
- Value : data .CommonAnnotations [ "summary" ] ,
247
+ Value : extractKV ( data .CommonAnnotations , "summary" ) ,
248
248
},
249
249
{
250
250
Title : "Severity" ,
251
251
Value : renderSeverity (data .CommonLabels ["severity" ]),
252
252
},
253
253
{
254
254
Title : "In Host" ,
255
- Value : data .CommonLabels [ "instance" ] ,
255
+ Value : extractKV ( data .CommonLabels , "instance" ) ,
256
256
},
257
257
{
258
258
Title : "Description" ,
259
- Value : data .CommonAnnotations [ "description" ] ,
259
+ Value : extractKV ( data .CommonAnnotations , "description" ) ,
260
260
},
261
261
{
262
262
Title : "Common Labels" ,
@@ -273,14 +273,16 @@ func (n *Notifier) Notify(ctx context.Context, as ...*types.Alert) (bool, error)
273
273
{
274
274
Type : "Action.OpenUrl" ,
275
275
Title : "View details" ,
276
- URL : data .CommonAnnotations [ "runbook_url" ] ,
276
+ URL : extractKV ( data .CommonAnnotations , "runbook_url" ) ,
277
277
},
278
278
},
279
279
},
280
280
},
281
281
},
282
282
}
283
283
284
+ // Check if summary exists in CommonLabels
285
+
284
286
if err = json .NewEncoder (& payload ).Encode (t ); err != nil {
285
287
return false , err
286
288
}
@@ -335,3 +337,10 @@ func renderCommonAnnotations(commonLabels template.KV) string {
335
337
336
338
return commonLabels .Remove (removeList ).String ()
337
339
}
340
+
341
+ func extractKV (kv template.KV , key string ) string {
342
+ if v , ok := kv [key ]; ok {
343
+ return v
344
+ }
345
+ return ""
346
+ }
0 commit comments