Merge pull request #1475 from prometheus/fabxc/targetsort
Sort exported targets
This commit is contained in:
commit
84c421da8e
|
@ -15,6 +15,7 @@ package retrieval
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
@ -134,11 +135,11 @@ func (tm *TargetManager) reload() {
|
|||
}
|
||||
|
||||
// Pools returns the targets currently being scraped bucketed by their job name.
|
||||
func (tm *TargetManager) Pools() map[string][]*Target {
|
||||
func (tm *TargetManager) Pools() map[string]Targets {
|
||||
tm.mtx.RLock()
|
||||
defer tm.mtx.RUnlock()
|
||||
|
||||
pools := map[string][]*Target{}
|
||||
pools := map[string]Targets{}
|
||||
|
||||
// TODO(fabxc): this is just a hack to maintain compatibility for now.
|
||||
for _, ps := range tm.targetSets {
|
||||
|
@ -151,6 +152,9 @@ func (tm *TargetManager) Pools() map[string][]*Target {
|
|||
|
||||
ps.scrapePool.mtx.RUnlock()
|
||||
}
|
||||
for _, targets := range pools {
|
||||
sort.Sort(targets)
|
||||
}
|
||||
return pools
|
||||
}
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ type PrometheusStatus struct {
|
|||
|
||||
// A function that returns the current scrape targets pooled
|
||||
// by their job name.
|
||||
TargetPools func() map[string][]*retrieval.Target
|
||||
TargetPools func() map[string]retrieval.Targets
|
||||
// A function that returns all loaded rules.
|
||||
Rules func() []rules.Rule
|
||||
|
||||
|
|
Loading…
Reference in New Issue