diff --git a/docs/querying/api.md b/docs/querying/api.md index 1366dc02c2..10f963f209 100644 --- a/docs/querying/api.md +++ b/docs/querying/api.md @@ -692,6 +692,7 @@ $ curl http://localhost:9090/api/v1/targets "__scrape_timeout__": "10s", "job": "node" }, + "scrapePool": "node" } ] } diff --git a/web/api/v1/api.go b/web/api/v1/api.go index 519433a78d..82aff1c940 100644 --- a/web/api/v1/api.go +++ b/web/api/v1/api.go @@ -1021,6 +1021,7 @@ type ScrapePoolsDiscovery struct { type DroppedTarget struct { // Labels before any processing. DiscoveredLabels labels.Labels `json:"discoveredLabels"` + ScrapePool string `json:"scrapePool"` } // TargetDiscovery has all the active targets. @@ -1181,6 +1182,7 @@ func (api *API) targets(r *http.Request) apiFuncResult { for _, target := range targetsDropped[pool] { res.DroppedTargets = append(res.DroppedTargets, &DroppedTarget{ DiscoveredLabels: target.DiscoveredLabels(builder), + ScrapePool: pool, }) } } diff --git a/web/api/v1/api_test.go b/web/api/v1/api_test.go index 1ef22b40a1..98c0e741a7 100644 --- a/web/api/v1/api_test.go +++ b/web/api/v1/api_test.go @@ -1767,6 +1767,7 @@ func testEndpoints(t *testing.T, api *API, tr *testTargetRetriever, es storage.E "__scrape_interval__", "30s", "__scrape_timeout__", "15s", ), + ScrapePool: "blackbox", }, }, DroppedTargetCounts: map[string]int{"blackbox": 1}, @@ -1816,6 +1817,7 @@ func testEndpoints(t *testing.T, api *API, tr *testTargetRetriever, es storage.E "__scrape_interval__", "30s", "__scrape_timeout__", "15s", ), + ScrapePool: "blackbox", }, }, DroppedTargetCounts: map[string]int{"blackbox": 1}, @@ -1875,6 +1877,7 @@ func testEndpoints(t *testing.T, api *API, tr *testTargetRetriever, es storage.E "__scrape_interval__", "30s", "__scrape_timeout__", "15s", ), + ScrapePool: "blackbox", }, }, DroppedTargetCounts: map[string]int{"blackbox": 1}, diff --git a/web/ui/mantine-ui/src/api/responseTypes/targets.ts b/web/ui/mantine-ui/src/api/responseTypes/targets.ts index cc0e891f05..c054247284 100644 --- a/web/ui/mantine-ui/src/api/responseTypes/targets.ts +++ b/web/ui/mantine-ui/src/api/responseTypes/targets.ts @@ -18,6 +18,7 @@ export type Target = { export interface DroppedTarget { discoveredLabels: Labels; + scrapePool: string; } // Result type for /api/v1/targets endpoint. diff --git a/web/ui/mantine-ui/src/pages/service-discovery/ServiceDiscoveryPoolsList.tsx b/web/ui/mantine-ui/src/pages/service-discovery/ServiceDiscoveryPoolsList.tsx index 798783da2f..6aec62fcc5 100644 --- a/web/ui/mantine-ui/src/pages/service-discovery/ServiceDiscoveryPoolsList.tsx +++ b/web/ui/mantine-ui/src/pages/service-discovery/ServiceDiscoveryPoolsList.tsx @@ -109,8 +109,7 @@ const buildPoolsData = ( } for (const target of droppedTargets) { - const { job: poolName } = target.discoveredLabels; - const pool = pools[poolName]; + const pool = pools[target.scrapePool]; if (!pool) { // TODO: Should we do better here? throw new Error( @@ -131,7 +130,7 @@ const buildPoolsData = ( .map((value) => value.original); for (const target of filteredDroppedTargets) { - pools[target.discoveredLabels.job].targets.push({ + pools[target.scrapePool].targets.push({ discoveredLabels: target.discoveredLabels, isDropped: true, labels: {},