Skip to content

Commit 4a22844

Browse files
authored
Merge pull request #856 from yeya24/targets-field
Add missing fields to targets API
2 parents 28ea8c2 + 45efe82 commit 4a22844

File tree

2 files changed

+23
-14
lines changed

2 files changed

+23
-14
lines changed

api/prometheus/v1/api.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -385,12 +385,15 @@ type TargetsResult struct {
385385

386386
// ActiveTarget models an active Prometheus scrape target.
387387
type ActiveTarget struct {
388-
DiscoveredLabels map[string]string `json:"discoveredLabels"`
389-
Labels model.LabelSet `json:"labels"`
390-
ScrapeURL string `json:"scrapeUrl"`
391-
LastError string `json:"lastError"`
392-
LastScrape time.Time `json:"lastScrape"`
393-
Health HealthStatus `json:"health"`
388+
DiscoveredLabels map[string]string `json:"discoveredLabels"`
389+
Labels model.LabelSet `json:"labels"`
390+
ScrapePool string `json:"scrapePool"`
391+
ScrapeURL string `json:"scrapeUrl"`
392+
GlobalURL string `json:"globalUrl"`
393+
LastError string `json:"lastError"`
394+
LastScrape time.Time `json:"lastScrape"`
395+
LastScrapeDuration float64 `json:"lastScrapeDuration"`
396+
Health HealthStatus `json:"health"`
394397
}
395398

396399
// DroppedTarget models a dropped Prometheus scrape target.

api/prometheus/v1/api_test.go

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -976,10 +976,13 @@ func TestAPIs(t *testing.T) {
976976
"instance": "127.0.0.1:9090",
977977
"job": "prometheus",
978978
},
979-
"scrapeUrl": "http://127.0.0.1:9090",
980-
"lastError": "error while scraping target",
981-
"lastScrape": testTime.UTC().Format(time.RFC3339Nano),
982-
"health": "up",
979+
"scrapePool": "prometheus",
980+
"scrapeUrl": "http://127.0.0.1:9090",
981+
"globalUrl": "http://127.0.0.1:9090",
982+
"lastError": "error while scraping target",
983+
"lastScrape": testTime.UTC().Format(time.RFC3339Nano),
984+
"lastScrapeDuration": 0.001146115,
985+
"health": "up",
983986
},
984987
},
985988
"droppedTargets": []map[string]interface{}{
@@ -1006,10 +1009,13 @@ func TestAPIs(t *testing.T) {
10061009
"instance": "127.0.0.1:9090",
10071010
"job": "prometheus",
10081011
},
1009-
ScrapeURL: "http://127.0.0.1:9090",
1010-
LastError: "error while scraping target",
1011-
LastScrape: testTime.UTC(),
1012-
Health: HealthGood,
1012+
ScrapePool: "prometheus",
1013+
ScrapeURL: "http://127.0.0.1:9090",
1014+
GlobalURL: "http://127.0.0.1:9090",
1015+
LastError: "error while scraping target",
1016+
LastScrape: testTime.UTC(),
1017+
LastScrapeDuration: 0.001146115,
1018+
Health: HealthGood,
10131019
},
10141020
},
10151021
Dropped: []DroppedTarget{

0 commit comments

Comments
 (0)