Skip to content

Commit 45efe82

Browse files
committed
add missing fields to targets API
Signed-off-by: yeya24 <[email protected]>
1 parent 17e98a7 commit 45efe82

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
@@ -380,12 +380,15 @@ type TargetsResult struct {
380380

381381
// ActiveTarget models an active Prometheus scrape target.
382382
type ActiveTarget struct {
383-
DiscoveredLabels map[string]string `json:"discoveredLabels"`
384-
Labels model.LabelSet `json:"labels"`
385-
ScrapeURL string `json:"scrapeUrl"`
386-
LastError string `json:"lastError"`
387-
LastScrape time.Time `json:"lastScrape"`
388-
Health HealthStatus `json:"health"`
383+
DiscoveredLabels map[string]string `json:"discoveredLabels"`
384+
Labels model.LabelSet `json:"labels"`
385+
ScrapePool string `json:"scrapePool"`
386+
ScrapeURL string `json:"scrapeUrl"`
387+
GlobalURL string `json:"globalUrl"`
388+
LastError string `json:"lastError"`
389+
LastScrape time.Time `json:"lastScrape"`
390+
LastScrapeDuration float64 `json:"lastScrapeDuration"`
391+
Health HealthStatus `json:"health"`
389392
}
390393

391394
// 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
@@ -871,10 +871,13 @@ func TestAPIs(t *testing.T) {
871871
"instance": "127.0.0.1:9090",
872872
"job": "prometheus",
873873
},
874-
"scrapeUrl": "http://127.0.0.1:9090",
875-
"lastError": "error while scraping target",
876-
"lastScrape": testTime.UTC().Format(time.RFC3339Nano),
877-
"health": "up",
874+
"scrapePool": "prometheus",
875+
"scrapeUrl": "http://127.0.0.1:9090",
876+
"globalUrl": "http://127.0.0.1:9090",
877+
"lastError": "error while scraping target",
878+
"lastScrape": testTime.UTC().Format(time.RFC3339Nano),
879+
"lastScrapeDuration": 0.001146115,
880+
"health": "up",
878881
},
879882
},
880883
"droppedTargets": []map[string]interface{}{
@@ -901,10 +904,13 @@ func TestAPIs(t *testing.T) {
901904
"instance": "127.0.0.1:9090",
902905
"job": "prometheus",
903906
},
904-
ScrapeURL: "http://127.0.0.1:9090",
905-
LastError: "error while scraping target",
906-
LastScrape: testTime.UTC(),
907-
Health: HealthGood,
907+
ScrapePool: "prometheus",
908+
ScrapeURL: "http://127.0.0.1:9090",
909+
GlobalURL: "http://127.0.0.1:9090",
910+
LastError: "error while scraping target",
911+
LastScrape: testTime.UTC(),
912+
LastScrapeDuration: 0.001146115,
913+
Health: HealthGood,
908914
},
909915
},
910916
Dropped: []DroppedTarget{

0 commit comments

Comments
 (0)