Merge pull request #2548 from prometheus/sort-targets
Sort targets by instance within a job
This commit is contained in:
commit
9cc7b393c5
|
@ -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()
|
||||
|
|
|
@ -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
|
||||
}{
|
||||
|
|
Loading…
Reference in New Issue