Alerting: Notification URL points to alert view page instead of alert edit page (#47752)

Before this change, notifications generated by the Grafana Alertmanager
pointed to '/alerting/:ruleID/edit'. This change instead points them to
the view path '/alerting/grafana/:ruleID/view'. The view page has a
better UX, including timeseries display. It's also where many alert
state improvements will land in the next few versions of Grafana.

Fixes #45301

Signed-off-by: Joe Blubaugh <joe.blubaugh@grafana.com>
This commit is contained in:
Joe Blubaugh
2022-04-20 21:43:55 +08:00
committed by GitHub
parent 54962c2f0c
commit 3d91047e6e
6 changed files with 24 additions and 22 deletions
+1
View File
@@ -49,3 +49,4 @@ Scopes must have an order to ensure consistency and ease of search, this helps u
- [BUGFIX] (Legacy) Templates: Parse notification templates using all the matches of the alert rule when going from `Alerting` to `OK` in legacy alerting #47355
- [BUGFIX] Scheduler: Fix state manager to support OK option of `AlertRule.ExecErrState` #47670
- [ENHANCEMENT] Templates: Enable the use of classic condition values in templates #46971
- [CHANGE] Notification URL points to alert view page instead of alert edit page. #47752
+2 -2
View File
@@ -27,7 +27,7 @@ const (
// stateToPostableAlert converts a state to a model that is accepted by Alertmanager. Annotations and Labels are copied from the state.
// - if state has at least one result, a new label '__value_string__' is added to the label set
// - the alert's GeneratorURL is constructed to point to the alert edit page
// - the alert's GeneratorURL is constructed to point to the alert detail view
// - if evaluation state is either NoData or Error, the resulting set of labels is changed:
// - original alert name (label: model.AlertNameLabel) is backed up to OriginalAlertName
// - label model.AlertNameLabel is overwritten to either NoDataAlertName or ErrorAlertName
@@ -42,7 +42,7 @@ func stateToPostableAlert(alertState *state.State, appURL *url.URL) *models.Post
var urlStr string
if uid := nL[ngModels.RuleUIDLabel]; len(uid) > 0 && appURL != nil {
u := *appURL
u.Path = path.Join(u.Path, fmt.Sprintf("/alerting/%s/edit", uid))
u.Path = path.Join(u.Path, fmt.Sprintf("/alerting/grafana/%s/view", uid))
urlStr = u.String()
} else if appURL != nil {
urlStr = appURL.String()
+1 -1
View File
@@ -60,7 +60,7 @@ func Test_stateToPostableAlert(t *testing.T) {
alertState.Labels[ngModels.RuleUIDLabel] = alertState.AlertRuleUID
result := stateToPostableAlert(alertState, appURL)
u := *appURL
u.Path = u.Path + "/alerting/" + alertState.AlertRuleUID + "/edit"
u.Path = u.Path + "/alerting/grafana/" + alertState.AlertRuleUID + "/view"
require.Equal(t, u.String(), result.Alert.GeneratorURL.String())
})