Skip to content

Commit

Permalink
Use a map to describe discovered labels, as they are not validated by…
Browse files Browse the repository at this point in the history
… the server (#529)

Signed-off-by: Oleksandr Kushchenko <[email protected]>
  • Loading branch information
okushchenko authored and krasi-georgiev committed Jan 23, 2019
1 parent 26e258b commit d5f6310
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions api/prometheus/v1/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,17 +231,17 @@ type TargetsResult struct {

// ActiveTarget models an active Prometheus scrape target.
type ActiveTarget struct {
DiscoveredLabels model.LabelSet `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"`
ScrapeURL string `json:"scrapeUrl"`
LastError string `json:"lastError"`
LastScrape time.Time `json:"lastScrape"`
Health HealthStatus `json:"health"`
}

// DroppedTarget models a dropped Prometheus scrape target.
type DroppedTarget struct {
DiscoveredLabels model.LabelSet `json:"discoveredLabels"`
DiscoveredLabels map[string]string `json:"discoveredLabels"`
}

// queryResult contains result data for a query.
Expand Down
4 changes: 2 additions & 2 deletions api/prometheus/v1/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,7 +605,7 @@ func TestAPIs(t *testing.T) {
res: TargetsResult{
Active: []ActiveTarget{
{
DiscoveredLabels: model.LabelSet{
DiscoveredLabels: map[string]string{
"__address__": "127.0.0.1:9090",
"__metrics_path__": "/metrics",
"__scheme__": "http",
Expand All @@ -623,7 +623,7 @@ func TestAPIs(t *testing.T) {
},
Dropped: []DroppedTarget{
{
DiscoveredLabels: model.LabelSet{
DiscoveredLabels: map[string]string{
"__address__": "127.0.0.1:9100",
"__metrics_path__": "/metrics",
"__scheme__": "http",
Expand Down

0 comments on commit d5f6310

Please sign in to comment.