mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
NGAlert: Fix some TODOs in notification channels (#33739)
Signed-off-by: Ganesh Vernekar <ganeshvern@gmail.com>
This commit is contained in:
parent
34d81b7d13
commit
1b8c0ce88b
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"net/url"
|
||||
"path"
|
||||
|
||||
gokit_log "github.com/go-kit/kit/log"
|
||||
"github.com/pkg/errors"
|
||||
@ -59,7 +60,7 @@ func (dd *DingDingNotifier) Notify(ctx context.Context, as ...*types.Alert) (boo
|
||||
|
||||
q := url.Values{
|
||||
"pc_slide": {"false"},
|
||||
"url": {dd.tmpl.ExternalURL.String()}, // TODO: should this be rule URL according to original?
|
||||
"url": {path.Join(dd.tmpl.ExternalURL.String(), "/alerting/list")},
|
||||
}
|
||||
|
||||
// Use special link to auto open the message url outside of Dingding
|
||||
|
@ -49,7 +49,7 @@ func TestDingdingNotifier(t *testing.T) {
|
||||
expMsg: map[string]interface{}{
|
||||
"msgtype": "link",
|
||||
"link": map[string]interface{}{
|
||||
"messageUrl": "dingtalk://dingtalkclient/page/link?pc_slide=false&url=http%3A%2F%2Flocalhost",
|
||||
"messageUrl": "dingtalk://dingtalkclient/page/link?pc_slide=false&url=http%3A%2Flocalhost%2Falerting%2Flist",
|
||||
"text": "\n**Firing**\nLabels:\n - alertname = alert1\n - lbl1 = val1\nAnnotations:\n - ann1 = annv1\nSource: \n\n\n\n\n",
|
||||
"title": "[firing:1] (val1)",
|
||||
},
|
||||
@ -79,7 +79,7 @@ func TestDingdingNotifier(t *testing.T) {
|
||||
expMsg: map[string]interface{}{
|
||||
"actionCard": map[string]interface{}{
|
||||
"singleTitle": "More",
|
||||
"singleURL": "dingtalk://dingtalkclient/page/link?pc_slide=false&url=http%3A%2F%2Flocalhost",
|
||||
"singleURL": "dingtalk://dingtalkclient/page/link?pc_slide=false&url=http%3A%2Flocalhost%2Falerting%2Flist",
|
||||
"text": "2 alerts are firing, 0 are resolved",
|
||||
"title": "[firing:2] ",
|
||||
},
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"path"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
@ -256,7 +257,7 @@ func (sn *SlackNotifier) buildSlackMessage(ctx context.Context, as []*types.Aler
|
||||
Footer: "Grafana v" + setting.BuildVersion,
|
||||
FooterIcon: FooterIconURL,
|
||||
Ts: time.Now().Unix(),
|
||||
TitleLink: "TODO: rule URL",
|
||||
TitleLink: path.Join(sn.tmpl.ExternalURL.String(), "/alerting/list"),
|
||||
Text: tmpl(sn.Text),
|
||||
Fields: nil, // TODO. Should be a config.
|
||||
},
|
||||
|
@ -59,7 +59,7 @@ func TestSlackNotifier(t *testing.T) {
|
||||
Attachments: []attachment{
|
||||
{
|
||||
Title: "[FIRING:1] (val1)",
|
||||
TitleLink: "TODO: rule URL",
|
||||
TitleLink: "http:/localhost/alerting/list",
|
||||
Text: "",
|
||||
Fallback: "[FIRING:1] (val1)",
|
||||
Fields: nil,
|
||||
@ -95,7 +95,7 @@ func TestSlackNotifier(t *testing.T) {
|
||||
Attachments: []attachment{
|
||||
{
|
||||
Title: "[FIRING:1] (val1)",
|
||||
TitleLink: "TODO: rule URL",
|
||||
TitleLink: "http:/localhost/alerting/list",
|
||||
Text: "",
|
||||
Fallback: "[FIRING:1] (val1)",
|
||||
Fields: nil,
|
||||
@ -138,7 +138,7 @@ func TestSlackNotifier(t *testing.T) {
|
||||
Attachments: []attachment{
|
||||
{
|
||||
Title: "2 firing, 0 resolved",
|
||||
TitleLink: "TODO: rule URL",
|
||||
TitleLink: "http:/localhost/alerting/list",
|
||||
Text: "",
|
||||
Fallback: "2 firing, 0 resolved",
|
||||
Fields: nil,
|
||||
|
@ -3,6 +3,7 @@ package channels
|
||||
import (
|
||||
"context"
|
||||
"encoding/json"
|
||||
"path"
|
||||
|
||||
gokit_log "github.com/go-kit/kit/log"
|
||||
"github.com/pkg/errors"
|
||||
@ -75,7 +76,8 @@ func (tn *TeamsNotifier) Notify(ctx context.Context, as ...*types.Alert) (bool,
|
||||
"name": "View Rule",
|
||||
"targets": []map[string]interface{}{
|
||||
{
|
||||
"os": "default", "uri": "", // TODO: add the rule URL here.
|
||||
"os": "default",
|
||||
"uri": path.Join(tn.tmpl.ExternalURL.String(), "/alerting/list"),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
@ -63,7 +63,7 @@ func TestTeamsNotifier(t *testing.T) {
|
||||
"@context": "http://schema.org",
|
||||
"@type": "OpenUri",
|
||||
"name": "View Rule",
|
||||
"targets": []map[string]interface{}{{"os": "default", "uri": ""}},
|
||||
"targets": []map[string]interface{}{{"os": "default", "uri": "http:/localhost/alerting/list"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
@ -105,7 +105,7 @@ func TestTeamsNotifier(t *testing.T) {
|
||||
"@context": "http://schema.org",
|
||||
"@type": "OpenUri",
|
||||
"name": "View Rule",
|
||||
"targets": []map[string]interface{}{{"os": "default", "uri": ""}},
|
||||
"targets": []map[string]interface{}{{"os": "default", "uri": "http:/localhost/alerting/list"}},
|
||||
},
|
||||
},
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user