From d5f63107bfcac90d692baa94bd0064132e1f1d0d Mon Sep 17 00:00:00 2001 From: Oleksandr Kushchenko Date: Wed, 23 Jan 2019 15:39:45 +0000 Subject: [PATCH] Use a map to describe discovered labels, as they are not validated by the server (#529) Signed-off-by: Oleksandr Kushchenko --- api/prometheus/v1/api.go | 14 +++++++------- api/prometheus/v1/api_test.go | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/api/prometheus/v1/api.go b/api/prometheus/v1/api.go index 345c0de..5078df1 100644 --- a/api/prometheus/v1/api.go +++ b/api/prometheus/v1/api.go @@ -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. diff --git a/api/prometheus/v1/api_test.go b/api/prometheus/v1/api_test.go index c95ab3e..fec170e 100644 --- a/api/prometheus/v1/api_test.go +++ b/api/prometheus/v1/api_test.go @@ -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", @@ -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",