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

Accept match[] in series API #1862

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions pkg/loghttp/series.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ func ParseSeriesQuery(r *http.Request) (*logproto.SeriesRequest, error) {
}

xs := r.Form["match"]
xs = append(xs, r.Form["match[]"]...)

// ensure matchers are valid before fanning out to ingesters/store as well as returning valuable parsing errors
// instead of 500s
Expand Down
11 changes: 11 additions & 0 deletions pkg/loghttp/series_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ func TestParseSeriesQuery(t *testing.T) {
false,
mkSeriesRequest(t, "1000", "2000", []string{`{a="1"}`, `{b="2", c=~"3", d!="4"}`}),
},
{
"accept match[]",
withForm(url.Values{
"start": []string{"1000"},
"end": []string{"2000"},
"match": []string{`{a="1"}`},
"match[]": []string{`{b="2", c=~"3", d!="4"}`},
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a test with multiple string value from match[].

Just to ensure we support this use case where multiple matches are provided using that new match[].

Like this

curl -g 'http://localhost:9090/api/v1/series?' --data-urlencode 'match[]=up' --data-urlencode 'match[]=process_start_time_seconds{job="prometheus"}'

I think you can do that simply by adding to the array:

"match[]": []string{`{b="2", c=~"3", d!="4"}`,`{a="1"}`},

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure

}),
false,
mkSeriesRequest(t, "1000", "2000", []string{`{a="1"}`, `{b="2", c=~"3", d!="4"}`}),
},
} {
t.Run(tc.desc, func(t *testing.T) {
out, err := ParseSeriesQuery(tc.input)
Expand Down