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. // ActiveTarget models an active Prometheus scrape target.
type ActiveTarget struct { type ActiveTarget struct {
DiscoveredLabels map[string]string `json:"discoveredLabels"` DiscoveredLabels map[string]string `json:"discoveredLabels"`
Labels model.LabelSet `json:"labels"` Labels model.LabelSet `json:"labels"`
ScrapeURL string `json:"scrapeUrl"` ScrapePool string `json:"scrapePool"`
LastError string `json:"lastError"` ScrapeURL string `json:"scrapeUrl"`
LastScrape time.Time `json:"lastScrape"` GlobalURL string `json:"globalUrl"`
Health HealthStatus `json:"health"` LastError string `json:"lastError"`
LastScrape time.Time `json:"lastScrape"`
LastScrapeDuration float64 `json:"lastScrapeDuration"`
Health HealthStatus `json:"health"`
} }
// DroppedTarget models a dropped Prometheus scrape target. // DroppedTarget models a dropped Prometheus scrape target.

View File

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