mirror of https://github.com/prometheus/prometheus
Merge pull request #3205 from prometheus/beorn7/ui
Make all rule links link to the "Console" tab rather than "Graph"pull/3116/merge
commit
398fa4fd02
|
@ -332,8 +332,8 @@ func (r *AlertingRule) HTMLSnippet(pathPrefix string) html_template.HTML {
|
||||||
model.MetricNameLabel: alertMetricName,
|
model.MetricNameLabel: alertMetricName,
|
||||||
alertNameLabel: model.LabelValue(r.name),
|
alertNameLabel: model.LabelValue(r.name),
|
||||||
}
|
}
|
||||||
s := fmt.Sprintf("ALERT <a href=%q>%s</a>", pathPrefix+strutil.GraphLinkForExpression(alertMetric.String()), r.name)
|
s := fmt.Sprintf("ALERT <a href=%q>%s</a>", pathPrefix+strutil.TableLinkForExpression(alertMetric.String()), r.name)
|
||||||
s += fmt.Sprintf("\n IF <a href=%q>%s</a>", pathPrefix+strutil.GraphLinkForExpression(r.vector.String()), html_template.HTMLEscapeString(r.vector.String()))
|
s += fmt.Sprintf("\n IF <a href=%q>%s</a>", pathPrefix+strutil.TableLinkForExpression(r.vector.String()), html_template.HTMLEscapeString(r.vector.String()))
|
||||||
if r.holdDuration > 0 {
|
if r.holdDuration > 0 {
|
||||||
s += fmt.Sprintf("\n FOR %s", model.Duration(r.holdDuration))
|
s += fmt.Sprintf("\n FOR %s", model.Duration(r.holdDuration))
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,8 +27,8 @@ func TestAlertingRuleHTMLSnippet(t *testing.T) {
|
||||||
}
|
}
|
||||||
rule := NewAlertingRule("testrule", expr, 0, model.LabelSet{"html": "<b>BOLD</b>"}, model.LabelSet{"html": "<b>BOLD</b>"})
|
rule := NewAlertingRule("testrule", expr, 0, model.LabelSet{"html": "<b>BOLD</b>"}, model.LabelSet{"html": "<b>BOLD</b>"})
|
||||||
|
|
||||||
const want = `ALERT <a href="/test/prefix/graph?g0.expr=ALERTS%7Balertname%3D%22testrule%22%7D&g0.tab=0">testrule</a>
|
const want = `ALERT <a href="/test/prefix/graph?g0.expr=ALERTS%7Balertname%3D%22testrule%22%7D&g0.tab=1">testrule</a>
|
||||||
IF <a href="/test/prefix/graph?g0.expr=foo%7Bhtml%3D%22%3Cb%3EBOLD%3Cb%3E%22%7D&g0.tab=0">foo{html="<b>BOLD<b>"}</a>
|
IF <a href="/test/prefix/graph?g0.expr=foo%7Bhtml%3D%22%3Cb%3EBOLD%3Cb%3E%22%7D&g0.tab=1">foo{html="<b>BOLD<b>"}</a>
|
||||||
LABELS {html="<b>BOLD</b>"}
|
LABELS {html="<b>BOLD</b>"}
|
||||||
ANNOTATIONS {html="<b>BOLD</b>"}`
|
ANNOTATIONS {html="<b>BOLD</b>"}`
|
||||||
|
|
||||||
|
|
|
@ -331,7 +331,7 @@ func (g *Group) sendAlerts(rule *AlertingRule, timestamp model.Time) error {
|
||||||
StartsAt: alert.ActiveAt.Add(rule.holdDuration).Time(),
|
StartsAt: alert.ActiveAt.Add(rule.holdDuration).Time(),
|
||||||
Labels: alert.Labels,
|
Labels: alert.Labels,
|
||||||
Annotations: alert.Annotations,
|
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 {
|
if alert.ResolvedAt != 0 {
|
||||||
a.EndsAt = alert.ResolvedAt.Time()
|
a.EndsAt = alert.ResolvedAt.Time()
|
||||||
|
|
|
@ -106,9 +106,9 @@ func (rule RecordingRule) HTMLSnippet(pathPrefix string) template.HTML {
|
||||||
ruleExpr := rule.vector.String()
|
ruleExpr := rule.vector.String()
|
||||||
return template.HTML(fmt.Sprintf(
|
return template.HTML(fmt.Sprintf(
|
||||||
`<a href="%s">%s</a>%s = <a href="%s">%s</a>`,
|
`<a href="%s">%s</a>%s = <a href="%s">%s</a>`,
|
||||||
pathPrefix+strutil.GraphLinkForExpression(rule.name),
|
pathPrefix+strutil.TableLinkForExpression(rule.name),
|
||||||
rule.name,
|
rule.name,
|
||||||
template.HTMLEscapeString(rule.labels.String()),
|
template.HTMLEscapeString(rule.labels.String()),
|
||||||
pathPrefix+strutil.GraphLinkForExpression(ruleExpr),
|
pathPrefix+strutil.TableLinkForExpression(ruleExpr),
|
||||||
template.HTMLEscapeString(ruleExpr)))
|
template.HTMLEscapeString(ruleExpr)))
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,7 +80,7 @@ func TestRecordingRuleHTMLSnippet(t *testing.T) {
|
||||||
}
|
}
|
||||||
rule := NewRecordingRule("testrule", expr, model.LabelSet{"html": "<b>BOLD</b>"})
|
rule := NewRecordingRule("testrule", expr, model.LabelSet{"html": "<b>BOLD</b>"})
|
||||||
|
|
||||||
const want = `<a href="/test/prefix/graph?g0.expr=testrule&g0.tab=0">testrule</a>{html="<b>BOLD</b>"} = <a href="/test/prefix/graph?g0.expr=foo%7Bhtml%3D%22%3Cb%3EBOLD%3Cb%3E%22%7D&g0.tab=0">foo{html="<b>BOLD<b>"}</a>`
|
const want = `<a href="/test/prefix/graph?g0.expr=testrule&g0.tab=1">testrule</a>{html="<b>BOLD</b>"} = <a href="/test/prefix/graph?g0.expr=foo%7Bhtml%3D%22%3Cb%3EBOLD%3Cb%3E%22%7D&g0.tab=1">foo{html="<b>BOLD<b>"}</a>`
|
||||||
|
|
||||||
got := rule.HTMLSnippet("/test/prefix")
|
got := rule.HTMLSnippet("/test/prefix")
|
||||||
if got != want {
|
if got != want {
|
||||||
|
|
Loading…
Reference in New Issue