mirror of
https://github.com/prometheus/prometheus.git
synced 2025-02-02 08:31:11 -08:00
web: Fix federation for instance label
This commit is contained in:
parent
47b0b9f7b0
commit
8c768f2ca3
|
@ -167,7 +167,7 @@ func (h *Handler) federation(w http.ResponseWriter, req *http.Request) {
|
||||||
Name: proto.String(l.Name),
|
Name: proto.String(l.Name),
|
||||||
Value: proto.String(l.Value),
|
Value: proto.String(l.Value),
|
||||||
})
|
})
|
||||||
if _, ok := h.externalLabels[model.LabelName(l.Name)]; ok {
|
if _, ok := externalLabels[model.LabelName(l.Name)]; ok {
|
||||||
globalUsed[l.Name] = struct{}{}
|
globalUsed[l.Name] = struct{}{}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,8 @@ func (h *Handler) federation(w http.ResponseWriter, req *http.Request) {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
// Attach global labels if they do not exist yet.
|
// Attach global labels if they do not exist yet.
|
||||||
for ln, lv := range h.externalLabels {
|
for _, ln := range externalLabelNames {
|
||||||
|
lv := externalLabels[ln]
|
||||||
if _, ok := globalUsed[string(ln)]; !ok {
|
if _, ok := globalUsed[string(ln)]; !ok {
|
||||||
protMetric.Label = append(protMetric.Label, &dto.LabelPair{
|
protMetric.Label = append(protMetric.Label, &dto.LabelPair{
|
||||||
Name: proto.String(string(ln)),
|
Name: proto.String(string(ln)),
|
||||||
|
|
|
@ -204,7 +204,7 @@ func TestFederation(t *testing.T) {
|
||||||
t.Errorf("Scenario %q: got code %d, want %d", name, got, want)
|
t.Errorf("Scenario %q: got code %d, want %d", name, got, want)
|
||||||
}
|
}
|
||||||
if got, want := normalizeBody(res.Body), scenario.body; got != want {
|
if got, want := normalizeBody(res.Body), scenario.body; got != want {
|
||||||
t.Errorf("Scenario %q: got body %s, want %s", name, got, want)
|
t.Errorf("Scenario %q: got body\n%s\n, want\n%s\n", name, got, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue