|
|
|
|
@ -55,8 +55,8 @@ import ( |
|
|
|
|
"github.com/prometheus/prometheus/notifier" |
|
|
|
|
"github.com/prometheus/prometheus/pkg/labels" |
|
|
|
|
"github.com/prometheus/prometheus/promql" |
|
|
|
|
"github.com/prometheus/prometheus/retrieval" |
|
|
|
|
"github.com/prometheus/prometheus/rules" |
|
|
|
|
"github.com/prometheus/prometheus/scrape" |
|
|
|
|
"github.com/prometheus/prometheus/storage" |
|
|
|
|
"github.com/prometheus/prometheus/template" |
|
|
|
|
"github.com/prometheus/prometheus/util/httputil" |
|
|
|
|
@ -71,7 +71,7 @@ var localhostRepresentations = []string{"127.0.0.1", "localhost"} |
|
|
|
|
type Handler struct { |
|
|
|
|
logger log.Logger |
|
|
|
|
|
|
|
|
|
scrapeManager *retrieval.ScrapeManager |
|
|
|
|
scrapeManager *scrape.ScrapeManager |
|
|
|
|
ruleManager *rules.Manager |
|
|
|
|
queryEngine *promql.Engine |
|
|
|
|
context context.Context |
|
|
|
|
@ -125,7 +125,7 @@ type Options struct { |
|
|
|
|
TSDB func() *tsdb.DB |
|
|
|
|
Storage storage.Storage |
|
|
|
|
QueryEngine *promql.Engine |
|
|
|
|
ScrapeManager *retrieval.ScrapeManager |
|
|
|
|
ScrapeManager *scrape.ScrapeManager |
|
|
|
|
RuleManager *rules.Manager |
|
|
|
|
Notifier *notifier.Manager |
|
|
|
|
Version *PrometheusVersion |
|
|
|
|
@ -404,7 +404,7 @@ func (h *Handler) Run(ctx context.Context) error { |
|
|
|
|
h.options.TSDB, |
|
|
|
|
h.options.QueryEngine, |
|
|
|
|
h.options.Storage.Querier, |
|
|
|
|
func() []*retrieval.Target { |
|
|
|
|
func() []*scrape.Target { |
|
|
|
|
return h.options.ScrapeManager.Targets() |
|
|
|
|
}, |
|
|
|
|
func() []*url.URL { |
|
|
|
|
@ -594,7 +594,7 @@ func (h *Handler) serviceDiscovery(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
sort.Strings(index) |
|
|
|
|
scrapeConfigData := struct { |
|
|
|
|
Index []string |
|
|
|
|
Targets map[string][]*retrieval.Target |
|
|
|
|
Targets map[string][]*scrape.Target |
|
|
|
|
}{ |
|
|
|
|
Index: index, |
|
|
|
|
Targets: targets, |
|
|
|
|
@ -604,7 +604,7 @@ func (h *Handler) serviceDiscovery(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
|
|
|
|
|
func (h *Handler) targets(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
// Bucket targets by job label
|
|
|
|
|
tps := map[string][]*retrieval.Target{} |
|
|
|
|
tps := map[string][]*scrape.Target{} |
|
|
|
|
for _, t := range h.scrapeManager.Targets() { |
|
|
|
|
job := t.Labels().Get(model.JobLabel) |
|
|
|
|
tps[job] = append(tps[job], t) |
|
|
|
|
@ -617,7 +617,7 @@ func (h *Handler) targets(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
h.executeTemplate(w, "targets.html", struct { |
|
|
|
|
TargetPools map[string][]*retrieval.Target |
|
|
|
|
TargetPools map[string][]*scrape.Target |
|
|
|
|
}{ |
|
|
|
|
TargetPools: tps, |
|
|
|
|
}) |
|
|
|
|
@ -707,21 +707,21 @@ func tmplFuncs(consolesPath string, opts *Options) template_text.FuncMap { |
|
|
|
|
} |
|
|
|
|
return u |
|
|
|
|
}, |
|
|
|
|
"numHealthy": func(pool []*retrieval.Target) int { |
|
|
|
|
"numHealthy": func(pool []*scrape.Target) int { |
|
|
|
|
alive := len(pool) |
|
|
|
|
for _, p := range pool { |
|
|
|
|
if p.Health() != retrieval.HealthGood { |
|
|
|
|
if p.Health() != scrape.HealthGood { |
|
|
|
|
alive-- |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return alive |
|
|
|
|
}, |
|
|
|
|
"healthToClass": func(th retrieval.TargetHealth) string { |
|
|
|
|
"healthToClass": func(th scrape.TargetHealth) string { |
|
|
|
|
switch th { |
|
|
|
|
case retrieval.HealthUnknown: |
|
|
|
|
case scrape.HealthUnknown: |
|
|
|
|
return "warning" |
|
|
|
|
case retrieval.HealthGood: |
|
|
|
|
case scrape.HealthGood: |
|
|
|
|
return "success" |
|
|
|
|
default: |
|
|
|
|
return "danger" |
|
|
|
|
|