Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing fields to targets API #856

Merged
merged 1 commit into from Apr 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 9 additions & 6 deletions api/prometheus/v1/api.go
Expand Up @@ -380,12 +380,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.
Expand Down
22 changes: 14 additions & 8 deletions api/prometheus/v1/api_test.go
Expand Up @@ -871,10 +871,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{}{
Expand All @@ -901,10 +904,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{
Expand Down