|
|
|
@ -46,7 +46,7 @@ func TestDiscordNotifier(t *testing.T) { |
|
|
|
|
"embeds": []interface{}{map[string]interface{}{ |
|
|
|
|
"color": 1.4037554e+07, |
|
|
|
|
"footer": map[string]interface{}{ |
|
|
|
|
"icon_url": "https://grafana.com/assets/img/fav32.png", |
|
|
|
|
"icon_url": "https://grafana.com/static/assets/img/fav32.png", |
|
|
|
|
"text": "Grafana v" + setting.BuildVersion, |
|
|
|
|
}, |
|
|
|
|
"title": "[FIRING:1] (val1)", |
|
|
|
@ -73,7 +73,7 @@ func TestDiscordNotifier(t *testing.T) { |
|
|
|
|
"embeds": []interface{}{map[string]interface{}{ |
|
|
|
|
"color": 1.4037554e+07, |
|
|
|
|
"footer": map[string]interface{}{ |
|
|
|
|
"icon_url": "https://grafana.com/assets/img/fav32.png", |
|
|
|
|
"icon_url": "https://grafana.com/static/assets/img/fav32.png", |
|
|
|
|
"text": "Grafana v" + setting.BuildVersion, |
|
|
|
|
}, |
|
|
|
|
"title": "Alerts firing: 1", |
|
|
|
@ -87,7 +87,7 @@ func TestDiscordNotifier(t *testing.T) { |
|
|
|
|
{ |
|
|
|
|
name: "Missing field in template", |
|
|
|
|
settings: `{ |
|
|
|
|
"avatar_url": "https://grafana.com/assets/img/fav32.png", |
|
|
|
|
"avatar_url": "https://grafana.com/static/assets/img/fav32.png", |
|
|
|
|
"url": "http://localhost", |
|
|
|
|
"message": "I'm a custom template {{ .NotAField }} bad template" |
|
|
|
|
}`, |
|
|
|
@ -100,12 +100,12 @@ func TestDiscordNotifier(t *testing.T) { |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
expMsg: map[string]interface{}{ |
|
|
|
|
"avatar_url": "https://grafana.com/assets/img/fav32.png", |
|
|
|
|
"avatar_url": "https://grafana.com/static/assets/img/fav32.png", |
|
|
|
|
"content": "I'm a custom template ", |
|
|
|
|
"embeds": []interface{}{map[string]interface{}{ |
|
|
|
|
"color": 1.4037554e+07, |
|
|
|
|
"footer": map[string]interface{}{ |
|
|
|
|
"icon_url": "https://grafana.com/assets/img/fav32.png", |
|
|
|
|
"icon_url": "https://grafana.com/static/assets/img/fav32.png", |
|
|
|
|
"text": "Grafana v" + setting.BuildVersion, |
|
|
|
|
}, |
|
|
|
|
"title": "[FIRING:1] (val1)", |
|
|
|
@ -119,7 +119,7 @@ func TestDiscordNotifier(t *testing.T) { |
|
|
|
|
{ |
|
|
|
|
name: "Invalid message template", |
|
|
|
|
settings: `{ |
|
|
|
|
"avatar_url": "https://grafana.com/assets/img/fav32.png", |
|
|
|
|
"avatar_url": "https://grafana.com/static/assets/img/fav32.png", |
|
|
|
|
"url": "http://localhost", |
|
|
|
|
"message": "{{ template \"invalid.template\" }}" |
|
|
|
|
}`, |
|
|
|
@ -132,12 +132,12 @@ func TestDiscordNotifier(t *testing.T) { |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
expMsg: map[string]interface{}{ |
|
|
|
|
"avatar_url": "https://grafana.com/assets/img/fav32.png", |
|
|
|
|
"avatar_url": "https://grafana.com/static/assets/img/fav32.png", |
|
|
|
|
"content": "", |
|
|
|
|
"embeds": []interface{}{map[string]interface{}{ |
|
|
|
|
"color": 1.4037554e+07, |
|
|
|
|
"footer": map[string]interface{}{ |
|
|
|
|
"icon_url": "https://grafana.com/assets/img/fav32.png", |
|
|
|
|
"icon_url": "https://grafana.com/static/assets/img/fav32.png", |
|
|
|
|
"text": "Grafana v" + setting.BuildVersion, |
|
|
|
|
}, |
|
|
|
|
"title": "[FIRING:1] (val1)", |
|
|
|
@ -169,7 +169,7 @@ func TestDiscordNotifier(t *testing.T) { |
|
|
|
|
"embeds": []interface{}{map[string]interface{}{ |
|
|
|
|
"color": 1.4037554e+07, |
|
|
|
|
"footer": map[string]interface{}{ |
|
|
|
|
"icon_url": "https://grafana.com/assets/img/fav32.png", |
|
|
|
|
"icon_url": "https://grafana.com/static/assets/img/fav32.png", |
|
|
|
|
"text": "Grafana v" + setting.BuildVersion, |
|
|
|
|
}, |
|
|
|
|
"title": "[FIRING:1] (val1)", |
|
|
|
@ -183,7 +183,7 @@ func TestDiscordNotifier(t *testing.T) { |
|
|
|
|
{ |
|
|
|
|
name: "Invalid URL template", |
|
|
|
|
settings: `{ |
|
|
|
|
"avatar_url": "https://grafana.com/assets/img/fav32.png", |
|
|
|
|
"avatar_url": "https://grafana.com/static/assets/img/fav32.png", |
|
|
|
|
"url": "http://localhost?q={{invalid }}}", |
|
|
|
|
"message": "valid message" |
|
|
|
|
}`, |
|
|
|
@ -196,12 +196,12 @@ func TestDiscordNotifier(t *testing.T) { |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
expMsg: map[string]interface{}{ |
|
|
|
|
"avatar_url": "https://grafana.com/assets/img/fav32.png", |
|
|
|
|
"avatar_url": "https://grafana.com/static/assets/img/fav32.png", |
|
|
|
|
"content": "valid message", |
|
|
|
|
"embeds": []interface{}{map[string]interface{}{ |
|
|
|
|
"color": 1.4037554e+07, |
|
|
|
|
"footer": map[string]interface{}{ |
|
|
|
|
"icon_url": "https://grafana.com/assets/img/fav32.png", |
|
|
|
|
"icon_url": "https://grafana.com/static/assets/img/fav32.png", |
|
|
|
|
"text": "Grafana v" + setting.BuildVersion, |
|
|
|
|
}, |
|
|
|
|
"title": "[FIRING:1] (val1)", |
|
|
|
@ -215,7 +215,7 @@ func TestDiscordNotifier(t *testing.T) { |
|
|
|
|
{ |
|
|
|
|
name: "Custom config with multiple alerts", |
|
|
|
|
settings: `{ |
|
|
|
|
"avatar_url": "https://grafana.com/assets/img/fav32.png", |
|
|
|
|
"avatar_url": "https://grafana.com/static/assets/img/fav32.png", |
|
|
|
|
"url": "http://localhost", |
|
|
|
|
"message": "{{ len .Alerts.Firing }} alerts are firing, {{ len .Alerts.Resolved }} are resolved" |
|
|
|
|
}`, |
|
|
|
@ -233,12 +233,12 @@ func TestDiscordNotifier(t *testing.T) { |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
expMsg: map[string]interface{}{ |
|
|
|
|
"avatar_url": "https://grafana.com/assets/img/fav32.png", |
|
|
|
|
"avatar_url": "https://grafana.com/static/assets/img/fav32.png", |
|
|
|
|
"content": "2 alerts are firing, 0 are resolved", |
|
|
|
|
"embeds": []interface{}{map[string]interface{}{ |
|
|
|
|
"color": 1.4037554e+07, |
|
|
|
|
"footer": map[string]interface{}{ |
|
|
|
|
"icon_url": "https://grafana.com/assets/img/fav32.png", |
|
|
|
|
"icon_url": "https://grafana.com/static/assets/img/fav32.png", |
|
|
|
|
"text": "Grafana v" + setting.BuildVersion, |
|
|
|
|
}, |
|
|
|
|
"title": "[FIRING:2] ", |
|
|
|
@ -273,7 +273,7 @@ func TestDiscordNotifier(t *testing.T) { |
|
|
|
|
"embeds": []interface{}{map[string]interface{}{ |
|
|
|
|
"color": 1.4037554e+07, |
|
|
|
|
"footer": map[string]interface{}{ |
|
|
|
|
"icon_url": "https://grafana.com/assets/img/fav32.png", |
|
|
|
|
"icon_url": "https://grafana.com/static/assets/img/fav32.png", |
|
|
|
|
"text": "Grafana v" + setting.BuildVersion, |
|
|
|
|
}, |
|
|
|
|
"title": "[FIRING:1] (val1)", |
|
|
|
|