mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-25 21:54:10 -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()
|
||||
|
||||
// TODO(fabxc): expose merge functionality in storage interface.
|
||||
// We just concatenate results for all sets of matchers, which may produce
|
||||
// duplicated results.
|
||||
metrics := []labels.Labels{}
|
||||
var set storage.SeriesSet
|
||||
|
||||
for _, mset := range matcherSets {
|
||||
series := q.Select(mset...)
|
||||
for series.Next() {
|
||||
metrics = append(metrics, series.At().Labels())
|
||||
}
|
||||
if series.Err() != nil {
|
||||
return nil, &apiError{errorExec, series.Err()}
|
||||
if set == nil {
|
||||
set = q.Select(mset...)
|
||||
} else {
|
||||
set = storage.DeduplicateSeriesSet(set, q.Select(mset...))
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
|
|
|
@ -310,7 +310,6 @@ func TestEndpoints(t *testing.T) {
|
|||
},
|
||||
response: []labels.Labels{
|
||||
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