web: Fix federation for instance label

pull/2643/head
Fabian Reinartz 8 years ago
parent 47b0b9f7b0
commit 8c768f2ca3
  1. 5
      web/federate.go
  2. 2
      web/federate_test.go

@ -167,7 +167,7 @@ func (h *Handler) federation(w http.ResponseWriter, req *http.Request) {
Name: proto.String(l.Name),
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{}{}
}
}
@ -176,7 +176,8 @@ func (h *Handler) federation(w http.ResponseWriter, req *http.Request) {
continue
}
// 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 {
protMetric.Label = append(protMetric.Label, &dto.LabelPair{
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)
}
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…
Cancel
Save