From c2e9a151abe8ed0ab27b447b858b1d09a4c8373b Mon Sep 17 00:00:00 2001 From: beorn7 Date: Thu, 21 Sep 2017 17:56:02 +0200 Subject: [PATCH] Make all rule links link to the "Console" tab rather than "Graph" Clicking on a rule, either the name or the expression, opens the rule result (or the corresponding expression, repsectively) in the expression browser. This should by default happen in the console tab, as, more often than not, displaying it in the graph tab runs into a timeout. --- rules/alerting.go | 4 ++-- rules/alerting_test.go | 4 ++-- rules/manager.go | 2 +- rules/recording.go | 4 ++-- rules/recording_test.go | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/rules/alerting.go b/rules/alerting.go index 6a489cfa8e..817a7078ee 100644 --- a/rules/alerting.go +++ b/rules/alerting.go @@ -332,8 +332,8 @@ func (r *AlertingRule) HTMLSnippet(pathPrefix string) html_template.HTML { model.MetricNameLabel: alertMetricName, alertNameLabel: model.LabelValue(r.name), } - s := fmt.Sprintf("ALERT %s", pathPrefix+strutil.GraphLinkForExpression(alertMetric.String()), r.name) - s += fmt.Sprintf("\n IF %s", pathPrefix+strutil.GraphLinkForExpression(r.vector.String()), html_template.HTMLEscapeString(r.vector.String())) + s := fmt.Sprintf("ALERT %s", pathPrefix+strutil.TableLinkForExpression(alertMetric.String()), r.name) + s += fmt.Sprintf("\n IF %s", pathPrefix+strutil.TableLinkForExpression(r.vector.String()), html_template.HTMLEscapeString(r.vector.String())) if r.holdDuration > 0 { s += fmt.Sprintf("\n FOR %s", model.Duration(r.holdDuration)) } diff --git a/rules/alerting_test.go b/rules/alerting_test.go index 3f7d4953f5..d12f0dec77 100644 --- a/rules/alerting_test.go +++ b/rules/alerting_test.go @@ -27,8 +27,8 @@ func TestAlertingRuleHTMLSnippet(t *testing.T) { } rule := NewAlertingRule("testrule", expr, 0, model.LabelSet{"html": "BOLD"}, model.LabelSet{"html": "BOLD"}) - const want = `ALERT testrule - IF foo{html="<b>BOLD<b>"} + const want = `ALERT testrule + IF foo{html="<b>BOLD<b>"} LABELS {html="<b>BOLD</b>"} ANNOTATIONS {html="<b>BOLD</b>"}` diff --git a/rules/manager.go b/rules/manager.go index 8b017c55ad..2d972a9cf1 100644 --- a/rules/manager.go +++ b/rules/manager.go @@ -331,7 +331,7 @@ func (g *Group) sendAlerts(rule *AlertingRule, timestamp model.Time) error { StartsAt: alert.ActiveAt.Add(rule.holdDuration).Time(), Labels: alert.Labels, Annotations: alert.Annotations, - GeneratorURL: g.opts.ExternalURL.String() + strutil.GraphLinkForExpression(rule.vector.String()), + GeneratorURL: g.opts.ExternalURL.String() + strutil.TableLinkForExpression(rule.vector.String()), } if alert.ResolvedAt != 0 { a.EndsAt = alert.ResolvedAt.Time() diff --git a/rules/recording.go b/rules/recording.go index 70fd75582d..442986ea6f 100644 --- a/rules/recording.go +++ b/rules/recording.go @@ -106,9 +106,9 @@ func (rule RecordingRule) HTMLSnippet(pathPrefix string) template.HTML { ruleExpr := rule.vector.String() return template.HTML(fmt.Sprintf( `%s%s = %s`, - pathPrefix+strutil.GraphLinkForExpression(rule.name), + pathPrefix+strutil.TableLinkForExpression(rule.name), rule.name, template.HTMLEscapeString(rule.labels.String()), - pathPrefix+strutil.GraphLinkForExpression(ruleExpr), + pathPrefix+strutil.TableLinkForExpression(ruleExpr), template.HTMLEscapeString(ruleExpr))) } diff --git a/rules/recording_test.go b/rules/recording_test.go index 472eeef4d2..730548d5e6 100644 --- a/rules/recording_test.go +++ b/rules/recording_test.go @@ -80,7 +80,7 @@ func TestRecordingRuleHTMLSnippet(t *testing.T) { } rule := NewRecordingRule("testrule", expr, model.LabelSet{"html": "BOLD"}) - const want = `testrule{html="<b>BOLD</b>"} = foo{html="<b>BOLD<b>"}` + const want = `testrule{html="<b>BOLD</b>"} = foo{html="<b>BOLD<b>"}` got := rule.HTMLSnippet("/test/prefix") if got != want {