Sort targets by instance within a job
Fixes https://github.com/prometheus/prometheus/issues/2536
This commit is contained in:
parent
336c7870ea
commit
947c83be3b
|
@ -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