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

api/series: return an empty array iff no results #1327

Merged
merged 1 commit into from
Jul 15, 2019
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/query/api/v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ func (api *API) series(r *http.Request) (interface{}, []error, *ApiError) {

set := storage.NewMergeSeriesSet(sets, nil)

var metrics []labels.Labels
metrics := []labels.Labels{}
for set.Next() {
metrics = append(metrics, set.At().Labels())
}
Expand Down
16 changes: 12 additions & 4 deletions pkg/query/api/v1_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,14 @@ func TestEndpoints(t *testing.T) {
labels.FromStrings("__name__", "test_metric2", "foo", "boo"),
},
},
// Series that does not exist should return an empty array.
{
endpoint: api.series,
query: url.Values{
"match[]": []string{`foobar`},
},
response: []labels.Labels{},
},
{
endpoint: api.series,
query: url.Values{
Expand Down Expand Up @@ -337,7 +345,7 @@ func TestEndpoints(t *testing.T) {
"start": []string{"-2"},
"end": []string{"-1"},
},
response: []labels.Labels(nil),
response: []labels.Labels{},
},
// Start and end after series ends.
{
Expand All @@ -347,7 +355,7 @@ func TestEndpoints(t *testing.T) {
"start": []string{"100000"},
"end": []string{"100001"},
},
response: []labels.Labels(nil),
response: []labels.Labels{},
},
// Start before series starts, end after series ends.
{
Expand Down Expand Up @@ -458,7 +466,7 @@ func TestEndpoints(t *testing.T) {
"start": []string{"-2"},
"end": []string{"-1"},
},
response: []labels.Labels(nil),
response: []labels.Labels{},
},
// Start and end after series ends.
{
Expand All @@ -468,7 +476,7 @@ func TestEndpoints(t *testing.T) {
"start": []string{"100000"},
"end": []string{"100001"},
},
response: []labels.Labels(nil),
response: []labels.Labels{},
},
// Start before series starts, end after series ends.
{
Expand Down