Merge pull request #856 from yeya24/targets-field

Add missing fields to targets API
This commit is contained in:
Björn Rabenstein 2021-04-12 22:30:20 +02:00 committed by GitHub
commit 4a22844c5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 14 deletions

View File

@ -385,12 +385,15 @@ type TargetsResult struct {
// ActiveTarget models an active Prometheus scrape target.
type ActiveTarget struct {
DiscoveredLabels map[string]string `json:"discoveredLabels"`
Labels model.LabelSet `json:"labels"`
ScrapeURL string `json:"scrapeUrl"`
LastError string `json:"lastError"`
LastScrape time.Time `json:"lastScrape"`
Health HealthStatus `json:"health"`
DiscoveredLabels map[string]string `json:"discoveredLabels"`
Labels model.LabelSet `json:"labels"`
ScrapePool string `json:"scrapePool"`
ScrapeURL string `json:"scrapeUrl"`
GlobalURL string `json:"globalUrl"`
LastError string `json:"lastError"`
LastScrape time.Time `json:"lastScrape"`
LastScrapeDuration float64 `json:"lastScrapeDuration"`
Health HealthStatus `json:"health"`
}
// DroppedTarget models a dropped Prometheus scrape target.

View File

@ -976,10 +976,13 @@ func TestAPIs(t *testing.T) {
"instance": "127.0.0.1:9090",
"job": "prometheus",
},
"scrapeUrl": "http://127.0.0.1:9090",
"lastError": "error while scraping target",
"lastScrape": testTime.UTC().Format(time.RFC3339Nano),
"health": "up",
"scrapePool": "prometheus",
"scrapeUrl": "http://127.0.0.1:9090",
"globalUrl": "http://127.0.0.1:9090",
"lastError": "error while scraping target",
"lastScrape": testTime.UTC().Format(time.RFC3339Nano),
"lastScrapeDuration": 0.001146115,
"health": "up",
},
},
"droppedTargets": []map[string]interface{}{
@ -1006,10 +1009,13 @@ func TestAPIs(t *testing.T) {
"instance": "127.0.0.1:9090",
"job": "prometheus",
},
ScrapeURL: "http://127.0.0.1:9090",
LastError: "error while scraping target",
LastScrape: testTime.UTC(),
Health: HealthGood,
ScrapePool: "prometheus",
ScrapeURL: "http://127.0.0.1:9090",
GlobalURL: "http://127.0.0.1:9090",
LastError: "error while scraping target",
LastScrape: testTime.UTC(),
LastScrapeDuration: 0.001146115,
Health: HealthGood,
},
},
Dropped: []DroppedTarget{