mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
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 {
|
func (tm *TargetManager) Targets() []*Target {
|
||||||
tm.mtx.RLock()
|
tm.mtx.RLock()
|
||||||
defer tm.mtx.RUnlock()
|
defer tm.mtx.RUnlock()
|
||||||
|
|
|
@ -379,6 +379,12 @@ func (h *Handler) targets(w http.ResponseWriter, r *http.Request) {
|
||||||
tps[job] = append(tps[job], t)
|
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 {
|
h.executeTemplate(w, "targets.html", struct {
|
||||||
TargetPools map[string][]*retrieval.Target
|
TargetPools map[string][]*retrieval.Target
|
||||||
}{
|
}{
|
||||||
|
|
Loading…
Reference in a new issue