grafana/alerting

ruleURL should open the alert rule page and not list the rules, previously it used to open the dashboard

panikdkernel opened this issue · 8 comments

This seems to have been done intentionally at the beginning of unified alerting grafana/grafana#33739. In legacy alerting it points to the dashboard panel https://github.com/grafana/grafana/blob/40feee0d17c72421bfd0e9dc5deebc83f7e3bb68/pkg/services/alerting/notifiers/slack.go#L212

Is there a way to pass it as a config var ? Maybe Something like slackTitleURL or can we modify this behaviour using notifications templates?

The reason for that behavior is that unified alerting notification component (Alertmanager) supports grouping alerts by labels, and therefore integration can receive multiple alerts

func (sn *Notifier) createSlackMessage(ctx context.Context, alerts []*types.Alert) (*slackMessage, error) {
var tmplErr error
tmpl, _ := templates.TmplText(ctx, sn.tmpl, alerts, sn.log, &tmplErr)
ruleURL := receivers.JoinURLPath(sn.tmpl.ExternalURL.String(), "/alerting/list", sn.log)

Therefore, it is not clear to which alert rule the slack message should refer to.

Is there a way to pass it as a config var ?

Unfortunately, I do not see any way you can change that URL. We can make it configurable, though and use the current behavior as the default.

Alternative is to check if there is one alert in the group and create proper URL to the rule

Alternative is to check if there is one alert in the group and create proper URL to the rule

Yes, currently we have single alert in the group as we migrated from the legacy alerts

I tried grouping the alerts using group overrides in notifications policy and now ruleURL value does make sense, the only way currently I see to access alert is through notification templates

Though it would be really handy if we could also config slack title url.

jquick commented

I also ran into this. We currently have all our slack alerts ungrouped so this would be amazing!

jquick commented

There is a work around for this. If you format a title in the slack link format:

<https://myLink|myTitle>

It will override the titleLink sent with the payload on slack. You can use a template to generate this just make sure you do not have any newlines.

This is done for Slack but might happen for other messages, leaving this issue open.