mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
fix graph links with path prefix
This commit is contained in:
parent
ac4d63b833
commit
3e914a8cb1
|
@ -40,7 +40,7 @@ renderTemplate is the name of the template to use to render the value.
|
|||
*/}}
|
||||
{{ define "prom_query_drilldown" }}
|
||||
{{ $expr := .arg0 }}{{ $suffix := (or .arg1 "") }}{{ $renderTemplate := (or .arg2 "__prom_query_drilldown_noop") }}
|
||||
<a class="prom_query_drilldown" href="{{ graphLink $expr }}">{{ with query $expr }}{{tmpl $renderTemplate ( . | first | value )}}{{ $suffix }}{{ else }}-{{ end }}</a>
|
||||
<a class="prom_query_drilldown" href="{{ pathPrefix }}{{ graphLink $expr }}">{{ with query $expr }}{{tmpl $renderTemplate ( . | first | value )}}{{ $suffix }}{{ else }}-{{ end }}</a>
|
||||
{{ end }}
|
||||
|
||||
{{ define "prom_path" }}/consoles/{{ .Path }}?{{ range $param, $value := .Params }}{{ $param }}={{ $value }}&{{ end }}{{ end }}"
|
||||
|
|
|
@ -17,6 +17,7 @@ import (
|
|||
"fmt"
|
||||
"html/template"
|
||||
"reflect"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
|
@ -213,16 +214,16 @@ func (rule *AlertingRule) String() string {
|
|||
}
|
||||
|
||||
// HTMLSnippet returns an HTML snippet representing this alerting rule.
|
||||
func (rule *AlertingRule) HTMLSnippet() template.HTML {
|
||||
func (rule *AlertingRule) HTMLSnippet(pathPrefix string) template.HTML {
|
||||
alertMetric := clientmodel.Metric{
|
||||
clientmodel.MetricNameLabel: AlertMetricName,
|
||||
AlertNameLabel: clientmodel.LabelValue(rule.name),
|
||||
}
|
||||
return template.HTML(fmt.Sprintf(
|
||||
`ALERT <a href="%s">%s</a> IF <a href="%s">%s</a> FOR %s WITH %s`,
|
||||
utility.GraphLinkForExpression(alertMetric.String()),
|
||||
pathPrefix+strings.TrimLeft(utility.GraphLinkForExpression(alertMetric.String()), "/"),
|
||||
rule.name,
|
||||
utility.GraphLinkForExpression(rule.Vector.String()),
|
||||
pathPrefix+strings.TrimLeft(utility.GraphLinkForExpression(rule.Vector.String()), "/"),
|
||||
rule.Vector,
|
||||
utility.DurationToString(rule.holdDuration),
|
||||
rule.Labels))
|
||||
|
|
|
@ -17,6 +17,7 @@ import (
|
|||
"fmt"
|
||||
"html/template"
|
||||
"reflect"
|
||||
"strings"
|
||||
|
||||
clientmodel "github.com/prometheus/client_golang/model"
|
||||
|
||||
|
@ -85,13 +86,13 @@ func (rule RecordingRule) String() string {
|
|||
}
|
||||
|
||||
// HTMLSnippet returns an HTML snippet representing this rule.
|
||||
func (rule RecordingRule) HTMLSnippet() template.HTML {
|
||||
func (rule RecordingRule) HTMLSnippet(pathPrefix string) template.HTML {
|
||||
ruleExpr := rule.vector.String()
|
||||
return template.HTML(fmt.Sprintf(
|
||||
`<a href="%s">%s</a>%s = <a href="%s">%s</a>`,
|
||||
utility.GraphLinkForExpression(rule.name),
|
||||
pathPrefix+strings.TrimLeft(utility.GraphLinkForExpression(rule.name), "/"),
|
||||
rule.name,
|
||||
rule.labels,
|
||||
utility.GraphLinkForExpression(ruleExpr),
|
||||
pathPrefix+strings.TrimLeft(utility.GraphLinkForExpression(ruleExpr), "/"),
|
||||
ruleExpr))
|
||||
}
|
||||
|
|
|
@ -37,5 +37,5 @@ type Rule interface {
|
|||
String() string
|
||||
// HTMLSnippet returns a human-readable string representation of the rule,
|
||||
// decorated with HTML elements for use the web frontend.
|
||||
HTMLSnippet() template.HTML
|
||||
HTMLSnippet(pathPrefix string) template.HTML
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<tr class="alert_details">
|
||||
<td>
|
||||
<div class="alert_description">
|
||||
<span class="label alert_rule">{{.HTMLSnippet}}</span>
|
||||
<span class="label alert_rule">{{.HTMLSnippet pathPrefix}}</span>
|
||||
<a href="#" class="silence_children_link">Silence All Children…</a>
|
||||
</div>
|
||||
{{if $activeAlerts}}
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
<pre>{{.Config}}</pre>
|
||||
|
||||
<h2>Rules</h2>
|
||||
<pre>{{range .RuleManager.Rules}}{{.HTMLSnippet}}<br/>{{end}}</pre>
|
||||
<pre>{{range .RuleManager.Rules}}{{.HTMLSnippet pathPrefix}}<br/>{{end}}</pre>
|
||||
|
||||
<h2>Targets</h2>
|
||||
<table class="table table-condensed table-bordered table-striped table-hover">
|
||||
|
|
Loading…
Reference in a new issue