mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-26 14:09:41 -08:00
api/v1: deduplicate selected series
This commit is contained in:
parent
4e41987bcb
commit
f56644e3ae
|
@ -337,21 +337,25 @@ func (api *API) series(r *http.Request) (interface{}, *apiError) {
|
||||||
}
|
}
|
||||||
defer q.Close()
|
defer q.Close()
|
||||||
|
|
||||||
// TODO(fabxc): expose merge functionality in storage interface.
|
var set storage.SeriesSet
|
||||||
// We just concatenate results for all sets of matchers, which may produce
|
|
||||||
// duplicated results.
|
|
||||||
metrics := []labels.Labels{}
|
|
||||||
|
|
||||||
for _, mset := range matcherSets {
|
for _, mset := range matcherSets {
|
||||||
series := q.Select(mset...)
|
if set == nil {
|
||||||
for series.Next() {
|
set = q.Select(mset...)
|
||||||
metrics = append(metrics, series.At().Labels())
|
} else {
|
||||||
}
|
set = storage.DeduplicateSeriesSet(set, q.Select(mset...))
|
||||||
if series.Err() != nil {
|
|
||||||
return nil, &apiError{errorExec, series.Err()}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
metrics := []labels.Labels{}
|
||||||
|
|
||||||
|
for set.Next() {
|
||||||
|
metrics = append(metrics, set.At().Labels())
|
||||||
|
}
|
||||||
|
if set.Err() != nil {
|
||||||
|
return nil, &apiError{errorExec, set.Err()}
|
||||||
|
}
|
||||||
|
|
||||||
return metrics, nil
|
return metrics, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -310,7 +310,6 @@ func TestEndpoints(t *testing.T) {
|
||||||
},
|
},
|
||||||
response: []labels.Labels{
|
response: []labels.Labels{
|
||||||
labels.FromStrings("__name__", "test_metric1", "foo", "boo"),
|
labels.FromStrings("__name__", "test_metric1", "foo", "boo"),
|
||||||
labels.FromStrings("__name__", "test_metric1", "foo", "boo"), // TODO(fabxc): see comment in implementation.
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue