mirror of
https://github.com/prometheus/prometheus
synced 2024-12-26 00:23:18 +00:00
Variable 'labels' collides with imported package name (#5012)
Signed-off-by: aixeshunter <aixeshunter@gmail.com>
This commit is contained in:
parent
d55bd57bdc
commit
fb8479a677
@ -495,22 +495,22 @@ func (r *AlertingRule) HTMLSnippet(pathPrefix string) html_template.HTML {
|
|||||||
alertNameLabel: model.LabelValue(r.name),
|
alertNameLabel: model.LabelValue(r.name),
|
||||||
}
|
}
|
||||||
|
|
||||||
labels := make(map[string]string, len(r.labels))
|
labelsMap := make(map[string]string, len(r.labels))
|
||||||
for _, l := range r.labels {
|
for _, l := range r.labels {
|
||||||
labels[l.Name] = html_template.HTMLEscapeString(l.Value)
|
labelsMap[l.Name] = html_template.HTMLEscapeString(l.Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
annotations := make(map[string]string, len(r.annotations))
|
annotationsMap := make(map[string]string, len(r.annotations))
|
||||||
for _, l := range r.annotations {
|
for _, l := range r.annotations {
|
||||||
annotations[l.Name] = html_template.HTMLEscapeString(l.Value)
|
annotationsMap[l.Name] = html_template.HTMLEscapeString(l.Value)
|
||||||
}
|
}
|
||||||
|
|
||||||
ar := rulefmt.Rule{
|
ar := rulefmt.Rule{
|
||||||
Alert: fmt.Sprintf("<a href=%q>%s</a>", pathPrefix+strutil.TableLinkForExpression(alertMetric.String()), r.name),
|
Alert: fmt.Sprintf("<a href=%q>%s</a>", pathPrefix+strutil.TableLinkForExpression(alertMetric.String()), r.name),
|
||||||
Expr: fmt.Sprintf("<a href=%q>%s</a>", pathPrefix+strutil.TableLinkForExpression(r.vector.String()), html_template.HTMLEscapeString(r.vector.String())),
|
Expr: fmt.Sprintf("<a href=%q>%s</a>", pathPrefix+strutil.TableLinkForExpression(r.vector.String()), html_template.HTMLEscapeString(r.vector.String())),
|
||||||
For: model.Duration(r.holdDuration),
|
For: model.Duration(r.holdDuration),
|
||||||
Labels: labels,
|
Labels: labelsMap,
|
||||||
Annotations: annotations,
|
Annotations: annotationsMap,
|
||||||
}
|
}
|
||||||
|
|
||||||
byt, err := yaml.Marshal(ar)
|
byt, err := yaml.Marshal(ar)
|
||||||
|
Loading…
Reference in New Issue
Block a user