-
Notifications
You must be signed in to change notification settings - Fork 455
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
[query] Restrict query by header tag #2053
Changes from 5 commits
f6fe230
405d842
f6640a1
fd66d0a
991a838
bfaca7d
1ca734e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,6 +36,7 @@ import ( | |
"github.com/m3db/m3/src/query/models" | ||
xpromql "github.com/m3db/m3/src/query/parser/promql" | ||
"github.com/m3db/m3/src/query/storage" | ||
"github.com/m3db/m3/src/query/ts" | ||
"github.com/m3db/m3/src/query/util" | ||
"github.com/m3db/m3/src/query/util/json" | ||
xhttp "github.com/m3db/m3/src/x/net/http" | ||
|
@@ -632,3 +633,22 @@ type PromDebug struct { | |
Input Response `json:"input"` | ||
Results Response `json:"results"` | ||
} | ||
|
||
// FilterSeriesByOptions removes series tags based on options. | ||
func FilterSeriesByOptions( | ||
series []*ts.Series, | ||
opts *storage.FetchOptions, | ||
) []*ts.Series { | ||
if opts == nil { | ||
return series | ||
} | ||
|
||
keys := opts.RestrictQueryOptions.GetRestrictByTag().GetFilterByNames() | ||
if len(keys) > 0 { | ||
for i, s := range series { | ||
series[i].Tags = s.Tags.TagsWithoutKeys(keys) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we ever push these filters down to the dbnode? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We push them down through the FetchOptions, e.g. in the This is actually on the path back from |
||
} | ||
} | ||
|
||
return series | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -96,7 +96,9 @@ func (h *PromReadInstantHandler) ServeHTTP(w http.ResponseWriter, r *http.Reques | |
QueryContextOptions: models.QueryContextOptions{ | ||
LimitMaxTimeseries: fetchOpts.Limit, | ||
}} | ||
if restrictOpts := fetchOpts.RestrictFetchOptions; restrictOpts != nil { | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does the result from There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Moved it to a common file. |
||
restrictOpts := fetchOpts.RestrictQueryOptions.GetRestrictByType() | ||
if restrictOpts != nil { | ||
restrict := &models.RestrictFetchTypeQueryContextOptions{ | ||
MetricsType: uint(restrictOpts.MetricsType), | ||
StoragePolicy: restrictOpts.StoragePolicy, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably update the header name to match how the header reads (to be consistent with other headers defined here).
So
QueryOptionsJSONHeader
->RestrictByTagsJSONHeader
?