Merge pull request #2548 from prometheus/sort-targets

Sort targets by instance within a job
This commit is contained in:
Julius Volz 2017-04-01 00:07:31 +02:00 committed by GitHub
commit 9cc7b393c5
2 changed files with 7 additions and 1 deletions

View file

@ -131,7 +131,7 @@ func (tm *TargetManager) reload() {
}
}
// Targets returns the targets currently being scraped bucketed by their job name.
// Targets returns the targets currently being scraped.
func (tm *TargetManager) Targets() []*Target {
tm.mtx.RLock()
defer tm.mtx.RUnlock()

View file

@ -379,6 +379,12 @@ func (h *Handler) targets(w http.ResponseWriter, r *http.Request) {
tps[job] = append(tps[job], t)
}
for _, targets := range tps {
sort.Slice(targets, func(i, j int) bool {
return targets[i].Labels()[model.InstanceLabel] < targets[j].Labels()[model.InstanceLabel]
})
}
h.executeTemplate(w, "targets.html", struct {
TargetPools map[string][]*retrieval.Target
}{