|
|
@ -1009,6 +1009,7 @@ func (api *API) targets(r *http.Request) apiFuncResult {
|
|
|
|
targetsActive := api.targetRetriever(r.Context()).TargetsActive()
|
|
|
|
targetsActive := api.targetRetriever(r.Context()).TargetsActive()
|
|
|
|
activeKeys, numTargets := sortKeys(targetsActive)
|
|
|
|
activeKeys, numTargets := sortKeys(targetsActive)
|
|
|
|
res.ActiveTargets = make([]*Target, 0, numTargets)
|
|
|
|
res.ActiveTargets = make([]*Target, 0, numTargets)
|
|
|
|
|
|
|
|
builder := labels.NewScratchBuilder(0)
|
|
|
|
|
|
|
|
|
|
|
|
for _, key := range activeKeys {
|
|
|
|
for _, key := range activeKeys {
|
|
|
|
if scrapePool != "" && key != scrapePool {
|
|
|
|
if scrapePool != "" && key != scrapePool {
|
|
|
@ -1025,7 +1026,7 @@ func (api *API) targets(r *http.Request) apiFuncResult {
|
|
|
|
|
|
|
|
|
|
|
|
res.ActiveTargets = append(res.ActiveTargets, &Target{
|
|
|
|
res.ActiveTargets = append(res.ActiveTargets, &Target{
|
|
|
|
DiscoveredLabels: target.DiscoveredLabels(),
|
|
|
|
DiscoveredLabels: target.DiscoveredLabels(),
|
|
|
|
Labels: target.Labels(),
|
|
|
|
Labels: target.Labels(&builder),
|
|
|
|
ScrapePool: key,
|
|
|
|
ScrapePool: key,
|
|
|
|
ScrapeURL: target.URL().String(),
|
|
|
|
ScrapeURL: target.URL().String(),
|
|
|
|
GlobalURL: globalURL.String(),
|
|
|
|
GlobalURL: globalURL.String(),
|
|
|
@ -1101,6 +1102,7 @@ func (api *API) targetMetadata(r *http.Request) apiFuncResult {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
builder := labels.NewScratchBuilder(0)
|
|
|
|
metric := r.FormValue("metric")
|
|
|
|
metric := r.FormValue("metric")
|
|
|
|
res := []metricMetadata{}
|
|
|
|
res := []metricMetadata{}
|
|
|
|
for _, tt := range api.targetRetriever(r.Context()).TargetsActive() {
|
|
|
|
for _, tt := range api.targetRetriever(r.Context()).TargetsActive() {
|
|
|
@ -1108,15 +1110,16 @@ func (api *API) targetMetadata(r *http.Request) apiFuncResult {
|
|
|
|
if limit >= 0 && len(res) >= limit {
|
|
|
|
if limit >= 0 && len(res) >= limit {
|
|
|
|
break
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
targetLabels := t.Labels(&builder)
|
|
|
|
// Filter targets that don't satisfy the label matchers.
|
|
|
|
// Filter targets that don't satisfy the label matchers.
|
|
|
|
if matchTarget != "" && !matchLabels(t.Labels(), matchers) {
|
|
|
|
if matchTarget != "" && !matchLabels(targetLabels, matchers) {
|
|
|
|
continue
|
|
|
|
continue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// If no metric is specified, get the full list for the target.
|
|
|
|
// If no metric is specified, get the full list for the target.
|
|
|
|
if metric == "" {
|
|
|
|
if metric == "" {
|
|
|
|
for _, md := range t.ListMetadata() {
|
|
|
|
for _, md := range t.ListMetadata() {
|
|
|
|
res = append(res, metricMetadata{
|
|
|
|
res = append(res, metricMetadata{
|
|
|
|
Target: t.Labels(),
|
|
|
|
Target: targetLabels,
|
|
|
|
Metric: md.Metric,
|
|
|
|
Metric: md.Metric,
|
|
|
|
Type: md.Type,
|
|
|
|
Type: md.Type,
|
|
|
|
Help: md.Help,
|
|
|
|
Help: md.Help,
|
|
|
@ -1128,7 +1131,7 @@ func (api *API) targetMetadata(r *http.Request) apiFuncResult {
|
|
|
|
// Get metadata for the specified metric.
|
|
|
|
// Get metadata for the specified metric.
|
|
|
|
if md, ok := t.GetMetadata(metric); ok {
|
|
|
|
if md, ok := t.GetMetadata(metric); ok {
|
|
|
|
res = append(res, metricMetadata{
|
|
|
|
res = append(res, metricMetadata{
|
|
|
|
Target: t.Labels(),
|
|
|
|
Target: targetLabels,
|
|
|
|
Type: md.Type,
|
|
|
|
Type: md.Type,
|
|
|
|
Help: md.Help,
|
|
|
|
Help: md.Help,
|
|
|
|
Unit: md.Unit,
|
|
|
|
Unit: md.Unit,
|
|
|
|