From f6fe23081ae07a5bcb89a99c3c65063bd5341b47 Mon Sep 17 00:00:00 2001 From: Rob Skillington Date: Wed, 27 Nov 2019 16:07:42 -0500 Subject: [PATCH 1/7] [query] WIP add ability to restrict all fetches for a query by labels and strip certain labels from results --- src/query/api/v1/handler/fetch_options.go | 10 +++++ src/query/api/v1/handler/headers.go | 6 +++ src/query/executor/engine.go | 15 ++++++- src/query/storage/index.go | 1 + src/query/storage/types.go | 50 +++++++++++++++++++++++ 5 files changed, 81 insertions(+), 1 deletion(-) diff --git a/src/query/api/v1/handler/fetch_options.go b/src/query/api/v1/handler/fetch_options.go index 2248381320..cffd8456da 100644 --- a/src/query/api/v1/handler/fetch_options.go +++ b/src/query/api/v1/handler/fetch_options.go @@ -32,6 +32,8 @@ import ( "github.com/m3db/m3/src/query/errors" "github.com/m3db/m3/src/query/storage" xhttp "github.com/m3db/m3/src/x/net/http" + + "github.com/prometheus/prometheus/promql" ) const ( @@ -124,6 +126,14 @@ func (b fetchOptionsBuilder) NewFetchOptions( fetchOpts.RestrictFetchOptions = newOrExistingRestrictFetchOptions(fetchOpts) fetchOpts.RestrictFetchOptions.StoragePolicy = sp } + if str := req.Header.Get(FetchRestrictLabels); str != "" { + promMatchers, err := promql.ParseMetricSelector(str) + if err != nil { + return nil, xhttp.NewParseError(err, http.StatusBadRequest) + } + fetchOpts.RestrictFetchOptions = newOrExistingRestrictFetchOptions(fetchOpts) + fetchOpts.RestrictFetchOptions.MustApplyMatchers = promMatchers + } if restrict := fetchOpts.RestrictFetchOptions; restrict != nil { if err := restrict.Validate(); err != nil { err = fmt.Errorf( diff --git a/src/query/api/v1/handler/headers.go b/src/query/api/v1/handler/headers.go index 7af42d0508..f6d27e49f7 100644 --- a/src/query/api/v1/handler/headers.go +++ b/src/query/api/v1/handler/headers.go @@ -56,6 +56,12 @@ const ( // metrics type. MetricsStoragePolicyHeader = "M3-Storage-Policy" + // FetchRestrictLabels restricts all fetches to match certain labels. + FetchRestrictLabels = "M3-Fetch-Restrict-Labels" + + // FetchStripLabels strips certain labels from the result. + FetchStripLabels = "M3-Fetch-Strip-Labels" + // UnaggregatedStoragePolicy specifies the unaggregated storage policy. UnaggregatedStoragePolicy = "unaggregated" diff --git a/src/query/executor/engine.go b/src/query/executor/engine.go index 079638bbba..dba5f4d054 100644 --- a/src/query/executor/engine.go +++ b/src/query/executor/engine.go @@ -115,7 +115,15 @@ func (e *engine) Execute( opts *QueryOptions, fetchOpts *storage.FetchOptions, ) (*storage.FetchResult, error) { - return e.opts.Store().Fetch(ctx, query, fetchOpts) + + // Here or elsewhere to apply the Restrict-Labels? + query = query.WithAppliedOptions(query) + + result, err := e.opts.Store().Fetch(ctx, query, fetchOpts) + + // TODO: Here or elsewhere to remove Strip-Labels from results? + + return result, err } func (e *engine) ExecuteExpr( @@ -125,6 +133,9 @@ func (e *engine) ExecuteExpr( fetchOpts *storage.FetchOptions, params models.RequestParams, ) (Result, error) { + + // Here or elsewhere to apply the Restrict-Labels? (how to hook into fetches cleanly?) + perQueryEnforcer := e.opts.GlobalEnforcer().Child(qcost.QueryLevel) defer perQueryEnforcer.Close() req := newRequest(e, params, fetchOpts, e.opts.InstrumentOptions()) @@ -160,6 +171,8 @@ func (e *engine) ExecuteExpr( } }() + // TODO: Here or elsewhere to remove Strip-Labels from results? + return result, nil } diff --git a/src/query/storage/index.go b/src/query/storage/index.go index 0cff5702dc..d42ee4503a 100644 --- a/src/query/storage/index.go +++ b/src/query/storage/index.go @@ -123,6 +123,7 @@ func FetchOptionsToAggregateOptions( // FetchQueryToM3Query converts an m3coordinator fetch query to an M3 query. func FetchQueryToM3Query( fetchQuery *FetchQuery, + options *FetchOptions, ) (index.Query, error) { matchers := fetchQuery.TagMatchers // If no matchers provided, explicitly set this to an AllQuery diff --git a/src/query/storage/types.go b/src/query/storage/types.go index 139bc59600..374b52b83d 100644 --- a/src/query/storage/types.go +++ b/src/query/storage/types.go @@ -21,6 +21,7 @@ package storage import ( + "bytes" "context" "errors" "fmt" @@ -33,6 +34,7 @@ import ( "github.com/m3db/m3/src/query/models" "github.com/m3db/m3/src/query/ts" xtime "github.com/m3db/m3/src/x/time" + "github.com/prometheus/prometheus/pkg/labels" "github.com/uber-go/tally" ) @@ -107,6 +109,46 @@ type FetchQuery struct { Interval time.Duration `json:"interval"` } +// WithAppliedOptions returns a copy of the fetch query applied options +// that restricts the fetch with respect to labels that must be applied. +func (q *FetchQuery) WithAppliedOptions( + opts *FetchOptions, +) *FetchQuery { + result := *q + if opts == nil { + return &result + } + + if restrictOpts := opts.RestrictFetchOptions; restrictOpts != nil { + mustApplyMatchers := restrictOpts.MustApplyMatchers + if n := len(mustApplyMatchers); n > 0 { + existing := result.TagMatchers + result.TagMatchers = make(models.Matchers, 0, len(existing)+n) + // Since must apply matchers will always be small (usually 1) + // it's better to not allocate intermediate datastructure and just + // perform n^2 matching. + for _, existingMatcher := range existing { + willBeOverridden := false + for _, mustApplyMatcher := range mustApplyMatchers { + if bytes.Equal(existingMatcher.Name, mustApplyMatcher.Name) { + willBeOverridden = true + break + } + } + if willBeOverridden { + // We'll override this when we append the must apply matchers. + continue + } + result.TagMatchers = append(result.TagMatchers, existingMatcher) + } + // Now append the must apply matchers. + result.TagMatchers = append(result.TagMatchers, mustApplyMatchers...) + } + } + + return &result +} + func (q *FetchQuery) String() string { return q.Raw } @@ -227,6 +269,10 @@ type RestrictFetchOptions struct { // StoragePolicy is required if metrics type is not unaggregated // to specify which storage policy metrics should be returned from. StoragePolicy policy.StoragePolicy + // MustApplyMatchers is a set of override matchers to apply to a fetch + // regardless of the existing fetch matchers, they should replace any + // existing matchers part of a fetch if they collide. + MustApplyMatchers []*labels.Matcher } // NewRestrictFetchOptionsFromProto returns a restrict fetch options from @@ -258,6 +304,8 @@ func NewRestrictFetchOptionsFromProto( result.StoragePolicy = storagePolicy } + // TODO: deserialize must apply matchers + // Validate the resulting options. if err := result.Validate(); err != nil { return result, err @@ -315,6 +363,8 @@ func (o RestrictFetchOptions) Proto() (*rpcpb.RestrictFetchOptions, error) { } result.MetricsStoragePolicy = storagePolicyProto + + // TODO: serialize must apply matchers } return result, nil From 405d842c46aed2d2be192b2d0687cb6402df6325 Mon Sep 17 00:00:00 2001 From: Artem Date: Wed, 27 Nov 2019 20:50:18 -0500 Subject: [PATCH 2/7] Hook up header label propagation --- src/query/api/v1/handler/fetch_options.go | 17 +- src/query/api/v1/handler/prometheus/common.go | 27 ++ .../api/v1/handler/prometheus/native/read.go | 3 +- .../api/v1/handler/prometheus/remote/read.go | 4 + src/query/api/v1/handler/types.go | 8 +- src/query/executor/engine.go | 12 - src/query/generated/proto/rpcpb/query.pb.go | 356 ++++++++++-------- src/query/generated/proto/rpcpb/query.proto | 1 + src/query/storage/fanout/storage.go | 34 ++ src/query/storage/index.go | 5 +- src/query/storage/index_test.go | 2 +- src/query/storage/m3/storage.go | 6 +- src/query/storage/types.go | 78 +--- src/query/storage/types_test.go | 214 ----------- src/query/tsdb/remote/codecs.go | 94 ++++- src/query/tsdb/remote/codecs_test.go | 224 +++++++++++ 16 files changed, 619 insertions(+), 466 deletions(-) delete mode 100644 src/query/storage/types_test.go diff --git a/src/query/api/v1/handler/fetch_options.go b/src/query/api/v1/handler/fetch_options.go index cffd8456da..0dfe70babe 100644 --- a/src/query/api/v1/handler/fetch_options.go +++ b/src/query/api/v1/handler/fetch_options.go @@ -30,6 +30,8 @@ import ( "github.com/m3db/m3/src/metrics/policy" "github.com/m3db/m3/src/query/errors" + "github.com/m3db/m3/src/query/models" + parser "github.com/m3db/m3/src/query/parser/promql" "github.com/m3db/m3/src/query/storage" xhttp "github.com/m3db/m3/src/x/net/http" @@ -105,6 +107,7 @@ func (b fetchOptionsBuilder) NewFetchOptions( if err != nil { return nil, xhttp.NewParseError(err, http.StatusBadRequest) } + fetchOpts.Limit = limit if str := req.Header.Get(MetricsTypeHeader); str != "" { mt, err := storage.ParseMetricsType(str) @@ -113,9 +116,11 @@ func (b fetchOptionsBuilder) NewFetchOptions( "could not parse metrics type: input=%s, err=%v", str, err) return nil, xhttp.NewParseError(err, http.StatusBadRequest) } + fetchOpts.RestrictFetchOptions = newOrExistingRestrictFetchOptions(fetchOpts) fetchOpts.RestrictFetchOptions.MetricsType = mt } + if str := req.Header.Get(MetricsStoragePolicyHeader); str != "" { sp, err := policy.ParseStoragePolicy(str) if err != nil { @@ -123,17 +128,27 @@ func (b fetchOptionsBuilder) NewFetchOptions( "could not parse storage policy: input=%s, err=%v", str, err) return nil, xhttp.NewParseError(err, http.StatusBadRequest) } + fetchOpts.RestrictFetchOptions = newOrExistingRestrictFetchOptions(fetchOpts) fetchOpts.RestrictFetchOptions.StoragePolicy = sp } + if str := req.Header.Get(FetchRestrictLabels); str != "" { promMatchers, err := promql.ParseMetricSelector(str) if err != nil { return nil, xhttp.NewParseError(err, http.StatusBadRequest) } + fetchOpts.RestrictFetchOptions = newOrExistingRestrictFetchOptions(fetchOpts) - fetchOpts.RestrictFetchOptions.MustApplyMatchers = promMatchers + // TODO: filter through TagOptions + m3Matchers, err := parser.LabelMatchersToModelMatcher(promMatchers, models.NewTagOptions()) + if err != nil { + return nil, xhttp.NewParseError(err, http.StatusBadRequest) + } + + fetchOpts.RestrictFetchOptions.MustApplyMatchers = m3Matchers } + if restrict := fetchOpts.RestrictFetchOptions; restrict != nil { if err := restrict.Validate(); err != nil { err = fmt.Errorf( diff --git a/src/query/api/v1/handler/prometheus/common.go b/src/query/api/v1/handler/prometheus/common.go index 59b17d3ba8..e4de39ebc0 100644 --- a/src/query/api/v1/handler/prometheus/common.go +++ b/src/query/api/v1/handler/prometheus/common.go @@ -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,29 @@ 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 || opts.RestrictFetchOptions == nil { + return series + } + + matchers := opts.RestrictFetchOptions.MustApplyMatchers + if len(matchers) == 0 { + return series + } + + keys := make([][]byte, 0, len(matchers)) + for _, m := range matchers { + keys = append(keys, m.Name) + } + + for i, s := range series { + series[i].Tags = s.Tags.TagsWithoutKeys(keys) + } + + return series +} diff --git a/src/query/api/v1/handler/prometheus/native/read.go b/src/query/api/v1/handler/prometheus/native/read.go index a4aa942a65..0c056f72e0 100644 --- a/src/query/api/v1/handler/prometheus/native/read.go +++ b/src/query/api/v1/handler/prometheus/native/read.go @@ -218,7 +218,8 @@ func (h *PromReadHandler) ServeHTTPWithEngine( // TODO: Support multiple result types w.Header().Set("Content-Type", "application/json") handler.AddWarningHeaders(w, result.meta) - return result.series, params, nil + series := prometheus.FilterSeriesByOptions(result.series, fetchOpts) + return series, params, nil } func (h *PromReadHandler) validateRequest(params *models.RequestParams) error { diff --git a/src/query/api/v1/handler/prometheus/remote/read.go b/src/query/api/v1/handler/prometheus/remote/read.go index a4280bd4ff..b8121c9fd9 100644 --- a/src/query/api/v1/handler/prometheus/remote/read.go +++ b/src/query/api/v1/handler/prometheus/remote/read.go @@ -232,6 +232,10 @@ func (h *PromReadHandler) read( mu.Lock() meta = meta.CombineMetadata(result.Metadata) mu.Unlock() + result.SeriesList = prometheus.FilterSeriesByOptions( + result.SeriesList, + fetchOpts, + ) promRes := storage.FetchResultToPromResult(result, h.keepEmpty) promResults[i] = promRes }() diff --git a/src/query/api/v1/handler/types.go b/src/query/api/v1/handler/types.go index c1dab5d06a..54a6a605ae 100644 --- a/src/query/api/v1/handler/types.go +++ b/src/query/api/v1/handler/types.go @@ -20,16 +20,16 @@ package handler -// HeaderKeyType is the type for the header key +// HeaderKeyType is the type for the header key. type HeaderKeyType int const ( - // HeaderKey is the key which headers will be added to in the request context + // HeaderKey is the key which headers will be added to in the request context. HeaderKey HeaderKeyType = iota - // RoutePrefixV1 is the v1 prefix for all coordinator routes + // RoutePrefixV1 is the v1 prefix for all coordinator routes. RoutePrefixV1 = "/api/v1" - // RoutePrefixExperimenta is the experimental prefix for all coordinator routes + // RoutePrefixExperimental is the experimental prefix for all coordinator routes. RoutePrefixExperimental = "/api/experimental" ) diff --git a/src/query/executor/engine.go b/src/query/executor/engine.go index dba5f4d054..d4e1e1c0c1 100644 --- a/src/query/executor/engine.go +++ b/src/query/executor/engine.go @@ -115,14 +115,7 @@ func (e *engine) Execute( opts *QueryOptions, fetchOpts *storage.FetchOptions, ) (*storage.FetchResult, error) { - - // Here or elsewhere to apply the Restrict-Labels? - query = query.WithAppliedOptions(query) - result, err := e.opts.Store().Fetch(ctx, query, fetchOpts) - - // TODO: Here or elsewhere to remove Strip-Labels from results? - return result, err } @@ -133,9 +126,6 @@ func (e *engine) ExecuteExpr( fetchOpts *storage.FetchOptions, params models.RequestParams, ) (Result, error) { - - // Here or elsewhere to apply the Restrict-Labels? (how to hook into fetches cleanly?) - perQueryEnforcer := e.opts.GlobalEnforcer().Child(qcost.QueryLevel) defer perQueryEnforcer.Close() req := newRequest(e, params, fetchOpts, e.opts.InstrumentOptions()) @@ -171,8 +161,6 @@ func (e *engine) ExecuteExpr( } }() - // TODO: Here or elsewhere to remove Strip-Labels from results? - return result, nil } diff --git a/src/query/generated/proto/rpcpb/query.pb.go b/src/query/generated/proto/rpcpb/query.pb.go index cac72df3d1..66e8cb275a 100644 --- a/src/query/generated/proto/rpcpb/query.pb.go +++ b/src/query/generated/proto/rpcpb/query.pb.go @@ -459,6 +459,7 @@ func (m *FetchOptions) GetIncludeResolution() bool { type RestrictFetchOptions struct { MetricsType MetricsType `protobuf:"varint,1,opt,name=metricsType,proto3,enum=rpc.MetricsType" json:"metricsType,omitempty"` MetricsStoragePolicy *policypb.StoragePolicy `protobuf:"bytes,2,opt,name=metricsStoragePolicy" json:"metricsStoragePolicy,omitempty"` + MustApplyMatchers *TagMatchers `protobuf:"bytes,3,opt,name=mustApplyMatchers" json:"mustApplyMatchers,omitempty"` } func (m *RestrictFetchOptions) Reset() { *m = RestrictFetchOptions{} } @@ -480,6 +481,13 @@ func (m *RestrictFetchOptions) GetMetricsStoragePolicy() *policypb.StoragePolicy return nil } +func (m *RestrictFetchOptions) GetMustApplyMatchers() *TagMatchers { + if m != nil { + return m.MustApplyMatchers + } + return nil +} + type FetchResponse struct { Series []*Series `protobuf:"bytes,1,rep,name=series" json:"series,omitempty"` Meta *ResultMetadata `protobuf:"bytes,2,opt,name=meta" json:"meta,omitempty"` @@ -2116,6 +2124,16 @@ func (m *RestrictFetchOptions) MarshalTo(dAtA []byte) (int, error) { } i += n5 } + if m.MustApplyMatchers != nil { + dAtA[i] = 0x1a + i++ + i = encodeVarintQuery(dAtA, i, uint64(m.MustApplyMatchers.Size())) + n6, err := m.MustApplyMatchers.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n6 + } return i, nil } @@ -2150,11 +2168,11 @@ func (m *FetchResponse) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x12 i++ i = encodeVarintQuery(dAtA, i, uint64(m.Meta.Size())) - n6, err := m.Meta.MarshalTo(dAtA[i:]) + n7, err := m.Meta.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n6 + i += n7 } return i, nil } @@ -2178,18 +2196,18 @@ func (m *Series) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintQuery(dAtA, i, uint64(m.Meta.Size())) - n7, err := m.Meta.MarshalTo(dAtA[i:]) + n8, err := m.Meta.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n7 + i += n8 } if m.Value != nil { - nn8, err := m.Value.MarshalTo(dAtA[i:]) + nn9, err := m.Value.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += nn8 + i += nn9 } return i, nil } @@ -2200,11 +2218,11 @@ func (m *Series_Decompressed) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x12 i++ i = encodeVarintQuery(dAtA, i, uint64(m.Decompressed.Size())) - n9, err := m.Decompressed.MarshalTo(dAtA[i:]) + n10, err := m.Decompressed.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n9 + i += n10 } return i, nil } @@ -2214,11 +2232,11 @@ func (m *Series_Compressed) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x1a i++ i = encodeVarintQuery(dAtA, i, uint64(m.Compressed.Size())) - n10, err := m.Compressed.MarshalTo(dAtA[i:]) + n11, err := m.Compressed.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n10 + i += n11 } return i, nil } @@ -2442,11 +2460,11 @@ func (m *M3Segments) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintQuery(dAtA, i, uint64(m.Merged.Size())) - n11, err := m.Merged.MarshalTo(dAtA[i:]) + n12, err := m.Merged.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n11 + i += n12 } if len(m.Unmerged) > 0 { for _, msg := range m.Unmerged { @@ -2519,11 +2537,11 @@ func (m *SearchRequest) MarshalTo(dAtA []byte) (int, error) { var l int _ = l if m.Matchers != nil { - nn12, err := m.Matchers.MarshalTo(dAtA[i:]) + nn13, err := m.Matchers.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += nn12 + i += nn13 } if m.Start != 0 { dAtA[i] = 0x10 @@ -2539,11 +2557,11 @@ func (m *SearchRequest) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x22 i++ i = encodeVarintQuery(dAtA, i, uint64(m.Options.Size())) - n13, err := m.Options.MarshalTo(dAtA[i:]) + n14, err := m.Options.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n13 + i += n14 } return i, nil } @@ -2554,11 +2572,11 @@ func (m *SearchRequest_TagMatchers) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintQuery(dAtA, i, uint64(m.TagMatchers.Size())) - n14, err := m.TagMatchers.MarshalTo(dAtA[i:]) + n15, err := m.TagMatchers.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n14 + i += n15 } return i, nil } @@ -2698,21 +2716,21 @@ func (m *SearchResponse) MarshalTo(dAtA []byte) (int, error) { var l int _ = l if m.Value != nil { - nn15, err := m.Value.MarshalTo(dAtA[i:]) + nn16, err := m.Value.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += nn15 + i += nn16 } if m.Meta != nil { dAtA[i] = 0x1a i++ i = encodeVarintQuery(dAtA, i, uint64(m.Meta.Size())) - n16, err := m.Meta.MarshalTo(dAtA[i:]) + n17, err := m.Meta.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n16 + i += n17 } return i, nil } @@ -2723,11 +2741,11 @@ func (m *SearchResponse_Decompressed) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintQuery(dAtA, i, uint64(m.Decompressed.Size())) - n17, err := m.Decompressed.MarshalTo(dAtA[i:]) + n18, err := m.Decompressed.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n17 + i += n18 } return i, nil } @@ -2737,11 +2755,11 @@ func (m *SearchResponse_Compressed) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x12 i++ i = encodeVarintQuery(dAtA, i, uint64(m.Compressed.Size())) - n18, err := m.Compressed.MarshalTo(dAtA[i:]) + n19, err := m.Compressed.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n18 + i += n19 } return i, nil } @@ -2787,11 +2805,11 @@ func (m *CompleteTagsRequestOptions) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x2a i++ i = encodeVarintQuery(dAtA, i, uint64(m.Options.Size())) - n19, err := m.Options.MarshalTo(dAtA[i:]) + n20, err := m.Options.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n19 + i += n20 } return i, nil } @@ -2812,21 +2830,21 @@ func (m *CompleteTagsRequest) MarshalTo(dAtA []byte) (int, error) { var l int _ = l if m.Matchers != nil { - nn20, err := m.Matchers.MarshalTo(dAtA[i:]) + nn21, err := m.Matchers.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += nn20 + i += nn21 } if m.Options != nil { dAtA[i] = 0x12 i++ i = encodeVarintQuery(dAtA, i, uint64(m.Options.Size())) - n21, err := m.Options.MarshalTo(dAtA[i:]) + n22, err := m.Options.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n21 + i += n22 } return i, nil } @@ -2837,11 +2855,11 @@ func (m *CompleteTagsRequest_TagMatchers) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintQuery(dAtA, i, uint64(m.TagMatchers.Size())) - n22, err := m.TagMatchers.MarshalTo(dAtA[i:]) + n23, err := m.TagMatchers.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n22 + i += n23 } return i, nil } @@ -2949,21 +2967,21 @@ func (m *CompleteTagsResponse) MarshalTo(dAtA []byte) (int, error) { var l int _ = l if m.Value != nil { - nn23, err := m.Value.MarshalTo(dAtA[i:]) + nn24, err := m.Value.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += nn23 + i += nn24 } if m.Meta != nil { dAtA[i] = 0x1a i++ i = encodeVarintQuery(dAtA, i, uint64(m.Meta.Size())) - n24, err := m.Meta.MarshalTo(dAtA[i:]) + n25, err := m.Meta.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n24 + i += n25 } return i, nil } @@ -2974,11 +2992,11 @@ func (m *CompleteTagsResponse_Default) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintQuery(dAtA, i, uint64(m.Default.Size())) - n25, err := m.Default.MarshalTo(dAtA[i:]) + n26, err := m.Default.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n25 + i += n26 } return i, nil } @@ -2988,11 +3006,11 @@ func (m *CompleteTagsResponse_NamesOnly) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x12 i++ i = encodeVarintQuery(dAtA, i, uint64(m.NamesOnly.Size())) - n26, err := m.NamesOnly.MarshalTo(dAtA[i:]) + n27, err := m.NamesOnly.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n26 + i += n27 } return i, nil } @@ -3034,22 +3052,22 @@ func (m *ResultMetadata) MarshalTo(dAtA []byte) (int, error) { } } if len(m.Resolutions) > 0 { - dAtA28 := make([]byte, len(m.Resolutions)*10) - var j27 int + dAtA29 := make([]byte, len(m.Resolutions)*10) + var j28 int for _, num1 := range m.Resolutions { num := uint64(num1) for num >= 1<<7 { - dAtA28[j27] = uint8(uint64(num)&0x7f | 0x80) + dAtA29[j28] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j27++ + j28++ } - dAtA28[j27] = uint8(num) - j27++ + dAtA29[j28] = uint8(num) + j28++ } dAtA[i] = 0x1a i++ - i = encodeVarintQuery(dAtA, i, uint64(j27)) - i += copy(dAtA[i:], dAtA28[:j27]) + i = encodeVarintQuery(dAtA, i, uint64(j28)) + i += copy(dAtA[i:], dAtA29[:j28]) } return i, nil } @@ -3207,6 +3225,10 @@ func (m *RestrictFetchOptions) Size() (n int) { l = m.MetricsStoragePolicy.Size() n += 1 + l + sovQuery(uint64(l)) } + if m.MustApplyMatchers != nil { + l = m.MustApplyMatchers.Size() + n += 1 + l + sovQuery(uint64(l)) + } return n } @@ -4451,6 +4473,39 @@ func (m *RestrictFetchOptions) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field MustApplyMatchers", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.MustApplyMatchers == nil { + m.MustApplyMatchers = &TagMatchers{} + } + if err := m.MustApplyMatchers.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -7385,104 +7440,105 @@ func init() { } var fileDescriptorQuery = []byte{ - // 1579 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x57, 0xdb, 0x52, 0x1b, 0x47, - 0x1a, 0xd6, 0x68, 0xd0, 0xe9, 0xd7, 0x01, 0xb9, 0x61, 0xd7, 0x82, 0xf5, 0xb2, 0xd4, 0xec, 0xae, - 0x97, 0xc5, 0x5e, 0x64, 0x83, 0xbd, 0x8e, 0x53, 0x95, 0x83, 0x00, 0x19, 0x28, 0x83, 0x84, 0x5b, - 0x43, 0xec, 0xa4, 0x92, 0x22, 0xad, 0x51, 0x5b, 0x4c, 0xa1, 0x39, 0x78, 0xa6, 0xe5, 0x18, 0x57, - 0x1e, 0x22, 0x95, 0x9b, 0x3c, 0x40, 0x2a, 0x79, 0x02, 0x3f, 0x42, 0x2e, 0x72, 0x99, 0x47, 0x48, - 0x39, 0xb9, 0xc8, 0x63, 0xa4, 0xba, 0xa7, 0xe7, 0x24, 0x89, 0xb2, 0xcb, 0x77, 0xd3, 0xff, 0xb1, - 0xff, 0xbf, 0xbf, 0xfe, 0xfe, 0x1e, 0xf8, 0x70, 0x68, 0xb2, 0xb3, 0x71, 0x7f, 0xc3, 0x70, 0xac, - 0xa6, 0xb5, 0x35, 0xe8, 0x37, 0xad, 0xad, 0xa6, 0xef, 0x19, 0xcd, 0x67, 0x63, 0xea, 0x5d, 0x34, - 0x87, 0xd4, 0xa6, 0x1e, 0x61, 0x74, 0xd0, 0x74, 0x3d, 0x87, 0x39, 0x4d, 0xcf, 0x35, 0xdc, 0x7e, - 0xa0, 0xdb, 0x10, 0x12, 0xa4, 0x7a, 0xae, 0xb1, 0xb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37, - 0xe7, 0x27, 0xb2, 0xa7, 0x52, 0x6b, 0x9f, 0x03, 0xc4, 0x2a, 0x84, 0x60, 0xce, 0x26, 0x16, 0x15, - 0x55, 0x56, 0xb0, 0xf8, 0xe6, 0xa5, 0x3f, 0x27, 0xa3, 0x31, 0x15, 0x65, 0x56, 0x70, 0xb0, 0x40, - 0xff, 0x82, 0x39, 0x76, 0xe1, 0x52, 0x51, 0x61, 0x4d, 0x56, 0x28, 0xa3, 0xe8, 0x17, 0x2e, 0xc5, - 0x42, 0xab, 0xfd, 0x9e, 0x95, 0x7d, 0x94, 0x55, 0xf0, 0x60, 0x23, 0xd3, 0x32, 0xa3, 0x3e, 0x8a, - 0x05, 0xba, 0x0b, 0x45, 0x8f, 0xfa, 0x1c, 0x19, 0x4c, 0x64, 0x29, 0x6f, 0x2e, 0x89, 0x80, 0x58, - 0x0a, 0x53, 0x8d, 0x88, 0x4c, 0xd1, 0x3a, 0xd4, 0x47, 0x8e, 0x73, 0xde, 0x27, 0xc6, 0x79, 0x74, - 0xfa, 0xaa, 0x88, 0x3b, 0x25, 0x47, 0x77, 0xa1, 0x32, 0xb6, 0xc9, 0x70, 0xe8, 0xd1, 0x21, 0x87, - 0x9d, 0xe8, 0x73, 0x2d, 0xec, 0x33, 0xb1, 0x9d, 0x31, 0x0b, 0xe2, 0xe3, 0x94, 0x19, 0xba, 0x0d, - 0x90, 0x70, 0xca, 0x5d, 0xe6, 0x94, 0x30, 0x42, 0x3b, 0xb0, 0x10, 0xaf, 0xb8, 0xde, 0x32, 0x5f, - 0xd2, 0x41, 0x23, 0x7f, 0x99, 0xef, 0x2c, 0x6b, 0x0e, 0x57, 0xd3, 0x36, 0x46, 0xe3, 0x01, 0xc5, - 0xd4, 0x77, 0x46, 0x63, 0x51, 0x5b, 0x61, 0x55, 0x59, 0x2b, 0xe2, 0x69, 0x85, 0xf6, 0x9d, 0x02, - 0x8b, 0xb3, 0x7a, 0x85, 0x36, 0xa1, 0x2c, 0x6f, 0x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09, 0x3f, 0xeb, 0xa7, - 0xe6, 0x88, 0x51, 0xaf, 0x43, 0x2c, 0xaa, 0x87, 0x34, 0x57, 0xc1, 0x13, 0xd2, 0x18, 0x95, 0xea, - 0x0c, 0x54, 0xce, 0xcd, 0x44, 0x65, 0xee, 0x4d, 0xa8, 0xd4, 0xbe, 0x55, 0x60, 0x61, 0x46, 0x19, - 0xef, 0x78, 0x71, 0xee, 0xc7, 0xa9, 0x83, 0xde, 0xff, 0x63, 0xaa, 0xf0, 0x74, 0x9f, 0x66, 0x5f, - 0x8f, 0x55, 0x28, 0xea, 0x64, 0xc8, 0x0b, 0x17, 0x55, 0x73, 0x22, 0x0e, 0xb0, 0x54, 0xc1, 0xc1, - 0x42, 0xbb, 0x23, 0x2c, 0x04, 0xfb, 0xbd, 0x01, 0xad, 0x6a, 0x02, 0xad, 0x9b, 0x50, 0x0a, 0xbd, - 0x7c, 0xf4, 0xef, 0xc8, 0x28, 0x40, 0x69, 0x35, 0x2c, 0x4e, 0xe8, 0x23, 0x9f, 0xef, 0x15, 0x58, - 0x4c, 0xef, 0x5f, 0x82, 0x74, 0x1d, 0x0a, 0x03, 0xfa, 0x94, 0x8c, 0x47, 0x2c, 0x45, 0x99, 0x51, - 0x82, 0xfd, 0x0c, 0x0e, 0x0d, 0xd0, 0xff, 0xa0, 0x24, 0xf6, 0xdd, 0xb5, 0x47, 0xe1, 0xbb, 0x25, - 0x4a, 0x27, 0xca, 0xdc, 0xcf, 0xe0, 0xd8, 0xe2, 0x1d, 0xd0, 0xf8, 0x35, 0xd4, 0xd2, 0x06, 0x68, - 0x05, 0x80, 0xbe, 0x38, 0x23, 0x63, 0x9f, 0x99, 0xcf, 0x03, 0x18, 0x16, 0x71, 0x42, 0x82, 0xd6, - 0xa0, 0xf8, 0x15, 0xf1, 0x6c, 0xd3, 0x8e, 0xc6, 0x6a, 0x45, 0xe4, 0x79, 0x1c, 0x08, 0x71, 0xa4, - 0x45, 0xab, 0x50, 0xf6, 0xa2, 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0x2b, 0xdc, 0x2c, 0x10, 0xed, 0x1e, 0xf4, - 0x02, 0x59, 0x76, 0xfd, 0x26, 0xd4, 0x27, 0xb9, 0x02, 0x95, 0xa1, 0x20, 0xc3, 0xd5, 0x33, 0x7c, - 0xa1, 0xb7, 0xf6, 0x3a, 0xad, 0xa3, 0x76, 0x5d, 0xd9, 0xfc, 0x43, 0x81, 0xdc, 0x23, 0xfe, 0xbf, - 0x8b, 0x6e, 0x43, 0x3e, 0xf8, 0x1b, 0x45, 0x01, 0x57, 0xa6, 0xfe, 0x55, 0x97, 0x17, 0x52, 0x32, - 0x89, 0xe2, 0x5b, 0x90, 0x13, 0xc4, 0x80, 0x12, 0x24, 0x11, 0x3a, 0xa0, 0xa4, 0x28, 0xb0, 0xbf, - 0xa5, 0xa0, 0x2d, 0xfe, 0xc2, 0xe5, 0x74, 0x2d, 0x93, 0xa4, 0x06, 0xee, 0xf2, 0x42, 0x4a, 0x16, - 0x39, 0xb5, 0xa1, 0x92, 0xac, 0x08, 0x35, 0x2e, 0xe3, 0x85, 0xe5, 0xa5, 0x19, 0x9a, 0x30, 0xcc, - 0xf6, 0xd5, 0x9f, 0x5f, 0xaf, 0x28, 0xbf, 0xbc, 0x5e, 0x51, 0x7e, 0x7d, 0xbd, 0xa2, 0x7c, 0xf3, - 0xdb, 0x4a, 0xe6, 0xb3, 0x9c, 0xf8, 0xdf, 0xef, 0xe7, 0xc5, 0xff, 0xf9, 0xd6, 0x9f, 0x01, 0x00, - 0x00, 0xff, 0xff, 0xf3, 0x1f, 0xfe, 0x09, 0x2c, 0x10, 0x00, 0x00, + // 1596 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x58, 0xdd, 0x72, 0x1b, 0xc5, + 0x12, 0xd6, 0x6a, 0xad, 0xbf, 0xd6, 0x8f, 0xe5, 0xb1, 0xcf, 0x89, 0xec, 0x93, 0xe3, 0xe3, 0x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 0xff, 0x21, 0xef, 0x13, 0xcf, 0x20, 0x61, 0x77, 0x97, 0xb9, 0x97, 0x1e, + 0x17, 0x61, 0xa1, 0x42, 0xef, 0xc1, 0x8c, 0x45, 0xa8, 0x26, 0xb6, 0x3c, 0x1f, 0xf6, 0xd2, 0xc8, + 0xa4, 0x87, 0x84, 0x6a, 0x03, 0x8d, 0x6a, 0x98, 0x03, 0x94, 0x57, 0x12, 0xe4, 0x7b, 0x69, 0x1b, + 0x29, 0x61, 0x13, 0xa8, 0xd2, 0x36, 0xe8, 0x13, 0xa8, 0x0c, 0x88, 0xee, 0x58, 0xae, 0x47, 0x7c, + 0x9f, 0x0c, 0xa2, 0xba, 0x30, 0x83, 0x9d, 0x84, 0x22, 0x30, 0xde, 0xcb, 0xe0, 0x14, 0x1c, 0xdd, + 0x03, 0x48, 0x18, 0xcb, 0x09, 0xe3, 0xc3, 0xcd, 0xed, 0x49, 0xe3, 0x04, 0x78, 0xab, 0x20, 0x6e, + 0xa2, 0xf2, 0x04, 0x6a, 0xe9, 0xad, 0xa1, 0x1a, 0x64, 0x8d, 0x81, 0xb8, 0xb6, 0x59, 0x63, 0x80, + 0xae, 0x42, 0x89, 0x53, 0x94, 0x6a, 0x58, 0x44, 0xf0, 0x53, 0x2c, 0x40, 0x0d, 0x28, 0x10, 0x7b, + 0xc0, 0x75, 0xc1, 0x7d, 0x09, 0x97, 0x4a, 0x1f, 0xd0, 0x64, 0x0e, 0x68, 0x1d, 0x80, 0x45, 0x71, + 0x1d, 0xc3, 0xa6, 0x61, 0xe1, 0x6b, 0x41, 0xc2, 0xa1, 0x18, 0x27, 0x10, 0xe8, 0x2a, 0xcc, 0x50, + 0x6d, 0xc8, 0xf8, 0x95, 0x21, 0x8b, 0xe1, 0x41, 0x63, 0x2e, 0x55, 0x3e, 0x85, 0x52, 0x64, 0xc6, + 0x36, 0xca, 0xc8, 0xd7, 0xa7, 0x9a, 0xe5, 0x0a, 0x52, 0x88, 0x05, 0x69, 0xee, 0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0x89, 0xa7, 0xeb, 0x34, 0xfd, + 0x7a, 0xac, 0x40, 0x51, 0xd5, 0x86, 0x2c, 0x71, 0x9e, 0x35, 0x23, 0xe2, 0xa0, 0x97, 0x2a, 0x38, + 0x58, 0x28, 0xb7, 0x39, 0x82, 0xb3, 0xdf, 0x25, 0xdd, 0x2a, 0x27, 0xba, 0x75, 0x03, 0x4a, 0xa1, + 0x95, 0x8f, 0xde, 0x8d, 0x40, 0x41, 0x97, 0x56, 0xc3, 0xe4, 0xb8, 0x3e, 0xb2, 0xf9, 0x51, 0x82, + 0x85, 0xf4, 0xfe, 0x45, 0x93, 0xae, 0x41, 0x61, 0x40, 0x9e, 0x6a, 0x23, 0x93, 0xa6, 0x28, 0x33, + 0x0a, 0xb0, 0x97, 0xc1, 0x21, 0x00, 0x7d, 0x00, 0x25, 0xbe, 0xef, 0xae, 0x6d, 0x86, 0xef, 0x9e, + 0x28, 0x1c, 0x4f, 0x73, 0x2f, 0x83, 0x63, 0xc4, 0x5b, 0x74, 0xe3, 0x77, 0x50, 0x4b, 0x03, 0xd0, + 0x32, 0x00, 0x79, 0x71, 0xaa, 0x8d, 0x7c, 0x6a, 0x3c, 0x0f, 0xda, 0xb0, 0x88, 0x13, 0x12, 0xb4, + 0x0a, 0xc5, 0x6f, 0x35, 0xcf, 0x36, 0xec, 0x68, 0xac, 0x56, 0x78, 0x9c, 0xc7, 0x81, 0x10, 0x47, + 0x5a, 0xb4, 0x02, 0x65, 0x2f, 0x7a, 0x1a, 0xb2, 0xc7, 0x96, 0xbc, 0x2a, 0xe3, 0xa4, 0x48, 0xb9, + 0x0b, 0x05, 0x61, 0x36, 0x75, 0x86, 0x36, 0xa0, 0x60, 0x11, 0xdf, 0xd7, 0x86, 0xe1, 0x14, 0x0d, + 0x97, 0x6b, 0x04, 0xca, 0x89, 0x37, 0x3e, 0x2a, 0x41, 0xae, 0xfd, 0xe8, 0xb8, 0x75, 0x50, 0xcf, + 0xa0, 0x0a, 0x14, 0x3b, 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xb7, 0xee, 0xd2, 0x7c, 0x4a, + 0x26, 0xba, 0xf8, 0x26, 0xe4, 0x38, 0x31, 0xa0, 0x04, 0x49, 0x84, 0x06, 0x28, 0x29, 0x0a, 0xf0, + 0x37, 0x25, 0xb4, 0xc9, 0x5e, 0xb8, 0x8c, 0xae, 0x45, 0x90, 0xd4, 0xc0, 0x5d, 0x9a, 0x4f, 0xc9, + 0x22, 0xa3, 0x36, 0x54, 0x92, 0x19, 0xa1, 0xc6, 0x45, 0xbc, 0xb0, 0xb4, 0x38, 0x45, 0x13, 0xba, + 0xd9, 0xba, 0xf2, 0xeb, 0xeb, 0x65, 0xe9, 0xb7, 0xd7, 0xcb, 0xd2, 0x1f, 0xaf, 0x97, 0xa5, 0xef, + 0xff, 0x5c, 0xce, 0x7c, 0x99, 0xe3, 0xff, 0x17, 0xf4, 0xf3, 0xfc, 0xf7, 0xfd, 0xe6, 0x3f, 0x01, + 0x00, 0x00, 0xff, 0xff, 0x05, 0x61, 0xfd, 0x0e, 0x6c, 0x10, 0x00, 0x00, } diff --git a/src/query/generated/proto/rpcpb/query.proto b/src/query/generated/proto/rpcpb/query.proto index acc3fa2f6f..904c99e274 100644 --- a/src/query/generated/proto/rpcpb/query.proto +++ b/src/query/generated/proto/rpcpb/query.proto @@ -67,6 +67,7 @@ message FetchOptions { message RestrictFetchOptions { MetricsType metricsType = 1; policypb.StoragePolicy metricsStoragePolicy = 2; + TagMatchers mustApplyMatchers = 3; } enum MetricsType { diff --git a/src/query/storage/fanout/storage.go b/src/query/storage/fanout/storage.go index a2062739ea..23c2744d4d 100644 --- a/src/query/storage/fanout/storage.go +++ b/src/query/storage/fanout/storage.go @@ -21,6 +21,7 @@ package fanout import ( + "bytes" "context" "fmt" "sync" @@ -332,9 +333,42 @@ func (s *fanoutStorage) CompleteTags( built := accumulatedTags.Build() built.Metadata = metadata + built = applyOptions(built, options) return &built, nil } +func applyOptions( + result storage.CompleteTagsResult, + opts *storage.FetchOptions, +) storage.CompleteTagsResult { + if opts.RestrictFetchOptions == nil { + return result + } + + matchers := opts.RestrictFetchOptions.MustApplyMatchers + if len(matchers) > 0 { + // Filter out unwanted tags inplace. + filteredList := result.CompletedTags[:0] + for _, s := range result.CompletedTags { + skip := false + for _, filter := range matchers { + if bytes.Equal(s.Name, filter.Name) { + skip = true + break + } + } + + if skip { + continue + } + + filteredList = append(filteredList, s) + } + } + + return result +} + func (s *fanoutStorage) Write(ctx context.Context, query *storage.WriteQuery) error { // TODO: Consider removing this lookup on every write by maintaining diff --git a/src/query/storage/index.go b/src/query/storage/index.go index d42ee4503a..f07b558264 100644 --- a/src/query/storage/index.go +++ b/src/query/storage/index.go @@ -125,8 +125,9 @@ func FetchQueryToM3Query( fetchQuery *FetchQuery, options *FetchOptions, ) (index.Query, error) { - matchers := fetchQuery.TagMatchers - // If no matchers provided, explicitly set this to an AllQuery + withOpts := fetchQuery.WithAppliedOptions(options) + matchers := withOpts.TagMatchers + // If no matchers provided, explicitly set this to an AllQuery. if len(matchers) == 0 { return index.Query{ Query: idx.NewAllQuery(), diff --git a/src/query/storage/index_test.go b/src/query/storage/index_test.go index c1138063a5..9d7cedbf5d 100644 --- a/src/query/storage/index_test.go +++ b/src/query/storage/index_test.go @@ -201,7 +201,7 @@ func TestFetchQueryToM3Query(t *testing.T) { Interval: 15 * time.Second, } - m3Query, err := FetchQueryToM3Query(fetchQuery) + m3Query, err := FetchQueryToM3Query(fetchQuery, nil) require.NoError(t, err) assert.Equal(t, test.expected, m3Query.String()) }) diff --git a/src/query/storage/m3/storage.go b/src/query/storage/m3/storage.go index fb488bd9c4..999ad4992e 100644 --- a/src/query/storage/m3/storage.go +++ b/src/query/storage/m3/storage.go @@ -286,7 +286,7 @@ func (s *m3storage) fetchCompressed( default: } - m3query, err := storage.FetchQueryToM3Query(query) + m3query, err := storage.FetchQueryToM3Query(query, options) if err != nil { return nil, err } @@ -425,7 +425,7 @@ func (s *m3storage) CompleteTags( TagMatchers: query.TagMatchers, } - m3query, err := storage.FetchQueryToM3Query(fetchQuery) + m3query, err := storage.FetchQueryToM3Query(fetchQuery, options) if err != nil { return nil, err } @@ -552,7 +552,7 @@ func (s *m3storage) SearchCompressed( default: } - m3query, err := storage.FetchQueryToM3Query(query) + m3query, err := storage.FetchQueryToM3Query(query, options) if err != nil { return tagResult, noop, err } diff --git a/src/query/storage/types.go b/src/query/storage/types.go index 374b52b83d..55215adfcb 100644 --- a/src/query/storage/types.go +++ b/src/query/storage/types.go @@ -23,26 +23,19 @@ package storage import ( "bytes" "context" - "errors" "fmt" "time" "github.com/m3db/m3/src/metrics/policy" "github.com/m3db/m3/src/query/block" "github.com/m3db/m3/src/query/cost" - "github.com/m3db/m3/src/query/generated/proto/rpcpb" "github.com/m3db/m3/src/query/models" "github.com/m3db/m3/src/query/ts" xtime "github.com/m3db/m3/src/x/time" - "github.com/prometheus/prometheus/pkg/labels" "github.com/uber-go/tally" ) -var ( - errNoRestrictFetchOptionsProtoMsg = errors.New("no restrict fetch options proto message") -) - // Type describes the type of storage. type Type int @@ -135,12 +128,15 @@ func (q *FetchQuery) WithAppliedOptions( break } } + if willBeOverridden { // We'll override this when we append the must apply matchers. continue } + result.TagMatchers = append(result.TagMatchers, existingMatcher) } + // Now append the must apply matchers. result.TagMatchers = append(result.TagMatchers, mustApplyMatchers...) } @@ -272,46 +268,7 @@ type RestrictFetchOptions struct { // MustApplyMatchers is a set of override matchers to apply to a fetch // regardless of the existing fetch matchers, they should replace any // existing matchers part of a fetch if they collide. - MustApplyMatchers []*labels.Matcher -} - -// NewRestrictFetchOptionsFromProto returns a restrict fetch options from -// protobuf message. -// TODO: (arnikola) extract these out of types.go -func NewRestrictFetchOptionsFromProto( - p *rpcpb.RestrictFetchOptions, -) (RestrictFetchOptions, error) { - var result RestrictFetchOptions - - if p == nil { - return result, errNoRestrictFetchOptionsProtoMsg - } - - switch p.MetricsType { - case rpcpb.MetricsType_UNAGGREGATED_METRICS_TYPE: - result.MetricsType = UnaggregatedMetricsType - case rpcpb.MetricsType_AGGREGATED_METRICS_TYPE: - result.MetricsType = AggregatedMetricsType - } - - if p.MetricsStoragePolicy != nil { - storagePolicy, err := policy.NewStoragePolicyFromProto( - p.MetricsStoragePolicy) - if err != nil { - return result, err - } - - result.StoragePolicy = storagePolicy - } - - // TODO: deserialize must apply matchers - - // Validate the resulting options. - if err := result.Validate(); err != nil { - return result, err - } - - return result, nil + MustApplyMatchers []models.Matcher } // Validate will validate the restrict fetch options. @@ -343,33 +300,6 @@ func (o RestrictFetchOptions) Validate() error { return nil } -// Proto returns the protobuf message that corresponds to RestrictFetchOptions. -func (o RestrictFetchOptions) Proto() (*rpcpb.RestrictFetchOptions, error) { - if err := o.Validate(); err != nil { - return nil, err - } - - result := &rpcpb.RestrictFetchOptions{} - - switch o.MetricsType { - case UnaggregatedMetricsType: - result.MetricsType = rpcpb.MetricsType_UNAGGREGATED_METRICS_TYPE - case AggregatedMetricsType: - result.MetricsType = rpcpb.MetricsType_AGGREGATED_METRICS_TYPE - - storagePolicyProto, err := o.StoragePolicy.Proto() - if err != nil { - return nil, err - } - - result.MetricsStoragePolicy = storagePolicyProto - - // TODO: serialize must apply matchers - } - - return result, nil -} - // Querier handles queries against a storage. type Querier interface { // Fetch fetches decompressed timeseries data based on a query. diff --git a/src/query/storage/types_test.go b/src/query/storage/types_test.go deleted file mode 100644 index 9774fd34e3..0000000000 --- a/src/query/storage/types_test.go +++ /dev/null @@ -1,214 +0,0 @@ -// Copyright (c) 2019 Uber Technologies, Inc. -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -package storage - -import ( - "fmt" - "math" - "strings" - "testing" - "time" - - "github.com/m3db/m3/src/metrics/generated/proto/policypb" - "github.com/m3db/m3/src/metrics/policy" - "github.com/m3db/m3/src/query/generated/proto/rpcpb" - xtime "github.com/m3db/m3/src/x/time" - - "github.com/stretchr/testify/assert" - "github.com/stretchr/testify/require" -) - -func TestNewRestrictFetchOptionsFromProto(t *testing.T) { - tests := []struct { - value *rpcpb.RestrictFetchOptions - expected RestrictFetchOptions - errContains string - }{ - { - value: &rpcpb.RestrictFetchOptions{ - MetricsType: rpcpb.MetricsType_UNAGGREGATED_METRICS_TYPE, - }, - expected: RestrictFetchOptions{ - MetricsType: UnaggregatedMetricsType, - }, - }, - { - value: &rpcpb.RestrictFetchOptions{ - MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, - MetricsStoragePolicy: &policypb.StoragePolicy{ - Resolution: &policypb.Resolution{ - WindowSize: int64(time.Minute), - Precision: int64(time.Second), - }, - Retention: &policypb.Retention{ - Period: int64(24 * time.Hour), - }, - }, - }, - expected: RestrictFetchOptions{ - MetricsType: AggregatedMetricsType, - StoragePolicy: policy.NewStoragePolicy(time.Minute, - xtime.Second, 24*time.Hour), - }, - }, - { - value: nil, - errContains: errNoRestrictFetchOptionsProtoMsg.Error(), - }, - { - value: &rpcpb.RestrictFetchOptions{ - MetricsType: rpcpb.MetricsType_UNKNOWN_METRICS_TYPE, - }, - errContains: "unknown metrics type:", - }, - { - value: &rpcpb.RestrictFetchOptions{ - MetricsType: rpcpb.MetricsType_UNAGGREGATED_METRICS_TYPE, - MetricsStoragePolicy: &policypb.StoragePolicy{ - Resolution: &policypb.Resolution{ - WindowSize: int64(time.Minute), - Precision: int64(time.Second), - }, - Retention: &policypb.Retention{ - Period: int64(24 * time.Hour), - }, - }, - }, - errContains: "expected no storage policy for unaggregated metrics", - }, - { - value: &rpcpb.RestrictFetchOptions{ - MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, - MetricsStoragePolicy: &policypb.StoragePolicy{ - Resolution: &policypb.Resolution{ - WindowSize: -1, - }, - }, - }, - errContains: "unable to convert from duration to time unit", - }, - { - value: &rpcpb.RestrictFetchOptions{ - MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, - MetricsStoragePolicy: &policypb.StoragePolicy{ - Resolution: &policypb.Resolution{ - WindowSize: int64(time.Minute), - Precision: int64(-1), - }, - }, - }, - errContains: "unable to convert from duration to time unit", - }, - { - value: &rpcpb.RestrictFetchOptions{ - MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, - MetricsStoragePolicy: &policypb.StoragePolicy{ - Resolution: &policypb.Resolution{ - WindowSize: int64(time.Minute), - Precision: int64(time.Second), - }, - Retention: &policypb.Retention{ - Period: int64(-1), - }, - }, - }, - errContains: "expected positive retention", - }, - } - for _, test := range tests { - t.Run(fmt.Sprintf("%s", test.value), func(t *testing.T) { - result, err := NewRestrictFetchOptionsFromProto(test.value) - if test.errContains == "" { - require.NoError(t, err) - assert.Equal(t, test.expected, result) - return - } - - require.Error(t, err) - assert.True(t, - strings.Contains(err.Error(), test.errContains), - fmt.Sprintf("err=%v, want_contains=%v", err.Error(), test.errContains)) - }) - } -} - -func TestRestrictFetchOptionsProto(t *testing.T) { - tests := []struct { - value RestrictFetchOptions - expected *rpcpb.RestrictFetchOptions - errContains string - }{ - { - value: RestrictFetchOptions{ - MetricsType: UnaggregatedMetricsType, - }, - expected: &rpcpb.RestrictFetchOptions{ - MetricsType: rpcpb.MetricsType_UNAGGREGATED_METRICS_TYPE, - }, - }, - { - value: RestrictFetchOptions{ - MetricsType: AggregatedMetricsType, - StoragePolicy: policy.NewStoragePolicy(time.Minute, - xtime.Second, 24*time.Hour), - }, - expected: &rpcpb.RestrictFetchOptions{ - MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, - MetricsStoragePolicy: &policypb.StoragePolicy{ - Resolution: &policypb.Resolution{ - WindowSize: int64(time.Minute), - Precision: int64(time.Second), - }, - Retention: &policypb.Retention{ - Period: int64(24 * time.Hour), - }, - }, - }, - }, - { - value: RestrictFetchOptions{ - MetricsType: MetricsType(uint(math.MaxUint16)), - }, - errContains: "unknown metrics type:", - }, - { - value: RestrictFetchOptions{ - MetricsType: UnaggregatedMetricsType, - StoragePolicy: policy.NewStoragePolicy(time.Minute, - xtime.Second, 24*time.Hour), - }, - errContains: "expected no storage policy for unaggregated metrics", - }, - } - for _, test := range tests { - t.Run(fmt.Sprintf("%s", test.value), func(t *testing.T) { - result, err := test.value.Proto() - if test.errContains == "" { - require.NoError(t, err) - assert.Equal(t, test.expected, result) - return - } - - require.Error(t, err) - assert.True(t, strings.Contains(err.Error(), test.errContains)) - }) - } -} diff --git a/src/query/tsdb/remote/codecs.go b/src/query/tsdb/remote/codecs.go index 773850a18d..e9fb66d374 100644 --- a/src/query/tsdb/remote/codecs.go +++ b/src/query/tsdb/remote/codecs.go @@ -22,13 +22,16 @@ package remote import ( "context" + "errors" "fmt" "net/http" "strings" "time" + "github.com/m3db/m3/src/metrics/policy" "github.com/m3db/m3/src/query/api/v1/handler" "github.com/m3db/m3/src/query/block" + "github.com/m3db/m3/src/query/generated/proto/rpcpb" rpc "github.com/m3db/m3/src/query/generated/proto/rpcpb" "github.com/m3db/m3/src/query/models" "github.com/m3db/m3/src/query/storage" @@ -121,6 +124,7 @@ func encodeFetchRequest( func encodeTagMatchers(modelMatchers models.Matchers) (*rpc.TagMatchers, error) { matchers := make([]*rpc.TagMatcher, len(modelMatchers)) for i, matcher := range modelMatchers { + fmt.Println("matcher", matcher) t, err := encodeMatcherTypeToProto(matcher.Type) if err != nil { return nil, err @@ -148,7 +152,7 @@ func encodeFanoutOption(opt storage.FanoutOption) (rpc.FanoutOption, error) { return rpc.FanoutOption_FORCE_ENABLED, nil } - return 0, fmt.Errorf("unknown fanout option for proto encoding: %v\n", opt) + return 0, fmt.Errorf("unknown fanout option for proto encoding: %v", opt) } func encodeFetchOptions(options *storage.FetchOptions) (*rpc.FetchOptions, error) { @@ -181,7 +185,7 @@ func encodeFetchOptions(options *storage.FetchOptions) (*rpc.FetchOptions, error result.AggregatedOptimized = aggOpt if v := options.RestrictFetchOptions; v != nil { - restrict, err := v.Proto() + restrict, err := encodeRestrictFetchOptions(v) if err != nil { return nil, err } @@ -196,6 +200,43 @@ func encodeFetchOptions(options *storage.FetchOptions) (*rpc.FetchOptions, error return result, nil } +func encodeRestrictFetchOptions( + o *storage.RestrictFetchOptions, +) (*rpcpb.RestrictFetchOptions, error) { + if err := o.Validate(); err != nil { + return nil, err + } + + result := &rpcpb.RestrictFetchOptions{} + + switch o.MetricsType { + case storage.UnaggregatedMetricsType: + result.MetricsType = rpcpb.MetricsType_UNAGGREGATED_METRICS_TYPE + case storage.AggregatedMetricsType: + result.MetricsType = rpcpb.MetricsType_AGGREGATED_METRICS_TYPE + + storagePolicyProto, err := o.StoragePolicy.Proto() + if err != nil { + return nil, err + } + + result.MetricsStoragePolicy = storagePolicyProto + } + + if len(o.MustApplyMatchers) > 0 { + fmt.Println("Applhying matchers", o.MustApplyMatchers) + matchers, err := encodeTagMatchers(o.MustApplyMatchers) + if err != nil { + return nil, err + } + fmt.Println(" matchers", matchers) + + result.MustApplyMatchers = matchers + } + + return result, nil +} + func encodeMatcherTypeToProto(t models.MatchType) (rpc.MatcherType, error) { switch t { case models.MatchEqual: @@ -302,7 +343,51 @@ func decodeFanoutOption(opt rpc.FanoutOption) (storage.FanoutOption, error) { return storage.FanoutForceEnable, nil } - return 0, fmt.Errorf("unknown fanout option for proto encoding: %v\n", opt) + return 0, fmt.Errorf("unknown fanout option for proto encoding: %v", opt) +} + +func decodeRestrictFetchOptions( + p *rpc.RestrictFetchOptions, +) (storage.RestrictFetchOptions, error) { + var result storage.RestrictFetchOptions + + if p == nil { + return result, errors.New("no restrict fetch options proto message") + } + + switch p.GetMetricsType() { + case rpcpb.MetricsType_UNAGGREGATED_METRICS_TYPE: + result.MetricsType = storage.UnaggregatedMetricsType + case rpcpb.MetricsType_AGGREGATED_METRICS_TYPE: + result.MetricsType = storage.AggregatedMetricsType + } + + if p.GetMetricsStoragePolicy() != nil { + storagePolicy, err := policy.NewStoragePolicyFromProto( + p.MetricsStoragePolicy) + if err != nil { + return result, err + } + + result.StoragePolicy = storagePolicy + } + + matchers := p.GetMustApplyMatchers() + if len(matchers.GetTagMatchers()) > 0 { + decodedMatchers, err := decodeTagMatchers(matchers) + if err != nil { + return result, err + } + + result.MustApplyMatchers = decodedMatchers + } + + // Validate the resulting options. + if err := result.Validate(); err != nil { + return result, err + } + + return result, nil } func decodeFetchOptions(rpcFetchOptions *rpc.FetchOptions) (*storage.FetchOptions, error) { @@ -336,10 +421,11 @@ func decodeFetchOptions(rpcFetchOptions *rpc.FetchOptions) (*storage.FetchOption } if v := rpcFetchOptions.Restrict; v != nil { - restrict, err := storage.NewRestrictFetchOptionsFromProto(v) + restrict, err := decodeRestrictFetchOptions(v) if err != nil { return nil, err } + result.RestrictFetchOptions = &restrict } diff --git a/src/query/tsdb/remote/codecs_test.go b/src/query/tsdb/remote/codecs_test.go index 1996f18e5c..2d467ef0c0 100644 --- a/src/query/tsdb/remote/codecs_test.go +++ b/src/query/tsdb/remote/codecs_test.go @@ -22,18 +22,24 @@ package remote import ( "context" + "fmt" + "math" "net/http" + "strings" "testing" "time" + "github.com/m3db/m3/src/metrics/generated/proto/policypb" "github.com/m3db/m3/src/metrics/policy" "github.com/m3db/m3/src/query/api/v1/handler" + "github.com/m3db/m3/src/query/generated/proto/rpcpb" rpc "github.com/m3db/m3/src/query/generated/proto/rpcpb" "github.com/m3db/m3/src/query/models" "github.com/m3db/m3/src/query/storage" "github.com/m3db/m3/src/query/test" "github.com/m3db/m3/src/query/util/logging" "github.com/m3db/m3/src/x/instrument" + xtime "github.com/m3db/m3/src/x/time" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -220,3 +226,221 @@ func TestRetrieveMetadata(t *testing.T) { require.Equal(t, requestID, logging.ReadContextID(encodedCtx)) } + +func TestNewRestrictFetchOptionsFromProto(t *testing.T) { + tests := []struct { + value *rpcpb.RestrictFetchOptions + expected storage.RestrictFetchOptions + errContains string + }{ + { + value: &rpcpb.RestrictFetchOptions{ + MetricsType: rpcpb.MetricsType_UNAGGREGATED_METRICS_TYPE, + }, + expected: storage.RestrictFetchOptions{ + MetricsType: storage.UnaggregatedMetricsType, + }, + }, + { + value: &rpcpb.RestrictFetchOptions{ + MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, + MetricsStoragePolicy: &policypb.StoragePolicy{ + Resolution: &policypb.Resolution{ + WindowSize: int64(time.Minute), + Precision: int64(time.Second), + }, + Retention: &policypb.Retention{ + Period: int64(24 * time.Hour), + }, + }, + MustApplyMatchers: &rpc.TagMatchers{ + TagMatchers: []*rpc.TagMatcher{ + newRPCMatcher(rpc.MatcherType_NOTREGEXP, "foo", "bar"), + newRPCMatcher(rpc.MatcherType_EQUAL, "baz", "qux"), + }, + }, + }, + expected: storage.RestrictFetchOptions{ + MetricsType: storage.AggregatedMetricsType, + StoragePolicy: policy.NewStoragePolicy(time.Minute, + xtime.Second, 24*time.Hour), + MustApplyMatchers: []models.Matcher{ + mustNewMatcher(models.MatchNotRegexp, "foo", "bar"), + mustNewMatcher(models.MatchEqual, "baz", "qux"), + }, + }, + }, + { + value: nil, + errContains: "no restrict fetch options proto message", + }, + { + value: &rpcpb.RestrictFetchOptions{ + MetricsType: rpcpb.MetricsType_UNKNOWN_METRICS_TYPE, + }, + errContains: "unknown metrics type:", + }, + { + value: &rpcpb.RestrictFetchOptions{ + MetricsType: rpcpb.MetricsType_UNAGGREGATED_METRICS_TYPE, + MetricsStoragePolicy: &policypb.StoragePolicy{ + Resolution: &policypb.Resolution{ + WindowSize: int64(time.Minute), + Precision: int64(time.Second), + }, + Retention: &policypb.Retention{ + Period: int64(24 * time.Hour), + }, + }, + }, + errContains: "expected no storage policy for unaggregated metrics", + }, + { + value: &rpcpb.RestrictFetchOptions{ + MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, + MetricsStoragePolicy: &policypb.StoragePolicy{ + Resolution: &policypb.Resolution{ + WindowSize: -1, + }, + }, + }, + errContains: "unable to convert from duration to time unit", + }, + { + value: &rpcpb.RestrictFetchOptions{ + MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, + MetricsStoragePolicy: &policypb.StoragePolicy{ + Resolution: &policypb.Resolution{ + WindowSize: int64(time.Minute), + Precision: int64(-1), + }, + }, + }, + errContains: "unable to convert from duration to time unit", + }, + { + value: &rpcpb.RestrictFetchOptions{ + MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, + MetricsStoragePolicy: &policypb.StoragePolicy{ + Resolution: &policypb.Resolution{ + WindowSize: int64(time.Minute), + Precision: int64(time.Second), + }, + Retention: &policypb.Retention{ + Period: int64(-1), + }, + }, + }, + errContains: "expected positive retention", + }, + } + for _, test := range tests { + t.Run(fmt.Sprintf("%s", test.value), func(t *testing.T) { + result, err := decodeRestrictFetchOptions(test.value) + if test.errContains == "" { + require.NoError(t, err) + assert.Equal(t, test.expected, result) + return + } + + require.Error(t, err) + assert.True(t, + strings.Contains(err.Error(), test.errContains), + fmt.Sprintf("err=%v, want_contains=%v", err.Error(), test.errContains)) + }) + } +} + +func mustNewMatcher(t models.MatchType, n, v string) models.Matcher { + matcher, err := models.NewMatcher(t, []byte(n), []byte(v)) + if err != nil { + panic(err) + } + + return matcher +} + +func newRPCMatcher(t rpc.MatcherType, n, v string) *rpc.TagMatcher { + return &rpc.TagMatcher{Name: []byte(n), Value: []byte(v), Type: t} +} + +func TestRestrictFetchOptionsProto(t *testing.T) { + tests := []struct { + value storage.RestrictFetchOptions + expected *rpcpb.RestrictFetchOptions + errContains string + }{ + { + value: storage.RestrictFetchOptions{ + MetricsType: storage.UnaggregatedMetricsType, + MustApplyMatchers: []models.Matcher{ + mustNewMatcher(models.MatchNotRegexp, "foo", "bar"), + }, + }, + expected: &rpcpb.RestrictFetchOptions{ + MetricsType: rpcpb.MetricsType_UNAGGREGATED_METRICS_TYPE, + MustApplyMatchers: &rpc.TagMatchers{ + TagMatchers: []*rpc.TagMatcher{ + newRPCMatcher(rpc.MatcherType_NOTREGEXP, "foo", "bar"), + }, + }, + }, + }, + { + value: storage.RestrictFetchOptions{ + MetricsType: storage.AggregatedMetricsType, + StoragePolicy: policy.NewStoragePolicy(time.Minute, + xtime.Second, 24*time.Hour), + MustApplyMatchers: []models.Matcher{ + mustNewMatcher(models.MatchNotRegexp, "foo", "bar"), + mustNewMatcher(models.MatchEqual, "baz", "qux"), + }, + }, + expected: &rpcpb.RestrictFetchOptions{ + MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, + MetricsStoragePolicy: &policypb.StoragePolicy{ + Resolution: &policypb.Resolution{ + WindowSize: int64(time.Minute), + Precision: int64(time.Second), + }, + Retention: &policypb.Retention{ + Period: int64(24 * time.Hour), + }, + }, + MustApplyMatchers: &rpc.TagMatchers{ + TagMatchers: []*rpc.TagMatcher{ + newRPCMatcher(rpc.MatcherType_NOTREGEXP, "foo", "bar"), + newRPCMatcher(rpc.MatcherType_EQUAL, "baz", "qux"), + }, + }, + }, + }, + { + value: storage.RestrictFetchOptions{ + MetricsType: storage.MetricsType(uint(math.MaxUint16)), + }, + errContains: "unknown metrics type:", + }, + { + value: storage.RestrictFetchOptions{ + MetricsType: storage.UnaggregatedMetricsType, + StoragePolicy: policy.NewStoragePolicy(time.Minute, + xtime.Second, 24*time.Hour), + }, + errContains: "expected no storage policy for unaggregated metrics", + }, + } + for _, test := range tests { + t.Run(fmt.Sprintf("%s", test.value), func(t *testing.T) { + result, err := encodeRestrictFetchOptions(&test.value) + if test.errContains == "" { + require.NoError(t, err) + require.Equal(t, test.expected, result) + return + } + + require.Error(t, err) + assert.True(t, strings.Contains(err.Error(), test.errContains)) + }) + } +} From f6640a1a287a86c611f9f14fdd62cf9d73096c45 Mon Sep 17 00:00:00 2001 From: Artem Date: Sat, 30 Nov 2019 20:59:04 -0500 Subject: [PATCH 3/7] PR response --- src/query/api/v1/handler/fetch_options.go | 34 +- .../api/v1/handler/fetch_options_test.go | 10 +- src/query/api/v1/handler/prometheus/common.go | 19 +- .../api/v1/handler/prometheus/native/read.go | 4 +- .../prometheus/native/read_instantaneous.go | 4 +- .../prometheus/validator/handler_test.go | 2 - src/query/functions/fetch_test.go | 7 +- src/query/generated/proto/rpcpb/query.pb.go | 724 +++++++++++++----- src/query/generated/proto/rpcpb/query.proto | 11 +- src/query/storage/fanout/storage.go | 8 +- src/query/storage/index.go | 4 +- src/query/storage/m3/cluster_resolver.go | 16 +- src/query/storage/m3/cluster_resolver_test.go | 30 +- src/query/storage/restrict_fetch_options.go | 163 ++++ .../storage/restrict_fetch_options_test.go | 53 ++ src/query/storage/types.go | 106 +-- src/query/tsdb/remote/codecs.go | 115 ++- src/query/tsdb/remote/codecs_test.go | 268 ++++--- 18 files changed, 1109 insertions(+), 469 deletions(-) create mode 100644 src/query/storage/restrict_fetch_options.go create mode 100644 src/query/storage/restrict_fetch_options_test.go diff --git a/src/query/api/v1/handler/fetch_options.go b/src/query/api/v1/handler/fetch_options.go index 0dfe70babe..ce7bddaef1 100644 --- a/src/query/api/v1/handler/fetch_options.go +++ b/src/query/api/v1/handler/fetch_options.go @@ -21,6 +21,7 @@ package handler import ( + "encoding/json" "fmt" "math" "net/http" @@ -30,12 +31,8 @@ import ( "github.com/m3db/m3/src/metrics/policy" "github.com/m3db/m3/src/query/errors" - "github.com/m3db/m3/src/query/models" - parser "github.com/m3db/m3/src/query/parser/promql" "github.com/m3db/m3/src/query/storage" xhttp "github.com/m3db/m3/src/x/net/http" - - "github.com/prometheus/prometheus/promql" ) const ( @@ -118,7 +115,9 @@ func (b fetchOptionsBuilder) NewFetchOptions( } fetchOpts.RestrictFetchOptions = newOrExistingRestrictFetchOptions(fetchOpts) - fetchOpts.RestrictFetchOptions.MetricsType = mt + fetchOpts.RestrictFetchOptions.RestrictByType = + newOrExistingRestrictFetchOptionsRestrictByType(fetchOpts) + fetchOpts.RestrictFetchOptions.RestrictByType.MetricsType = mt } if str := req.Header.Get(MetricsStoragePolicyHeader); str != "" { @@ -130,23 +129,19 @@ func (b fetchOptionsBuilder) NewFetchOptions( } fetchOpts.RestrictFetchOptions = newOrExistingRestrictFetchOptions(fetchOpts) - fetchOpts.RestrictFetchOptions.StoragePolicy = sp + fetchOpts.RestrictFetchOptions.RestrictByType = + newOrExistingRestrictFetchOptionsRestrictByType(fetchOpts) + fetchOpts.RestrictFetchOptions.RestrictByType.StoragePolicy = sp } if str := req.Header.Get(FetchRestrictLabels); str != "" { - promMatchers, err := promql.ParseMetricSelector(str) - if err != nil { + var opts *storage.RestrictFetchOptions + if err := json.Unmarshal([]byte(str), opts); err != nil { return nil, xhttp.NewParseError(err, http.StatusBadRequest) } fetchOpts.RestrictFetchOptions = newOrExistingRestrictFetchOptions(fetchOpts) - // TODO: filter through TagOptions - m3Matchers, err := parser.LabelMatchersToModelMatcher(promMatchers, models.NewTagOptions()) - if err != nil { - return nil, xhttp.NewParseError(err, http.StatusBadRequest) - } - - fetchOpts.RestrictFetchOptions.MustApplyMatchers = m3Matchers + fetchOpts.RestrictFetchOptions.RestrictByTag = opts.RestrictByTag } if restrict := fetchOpts.RestrictFetchOptions; restrict != nil { @@ -186,6 +181,15 @@ func newOrExistingRestrictFetchOptions( return &storage.RestrictFetchOptions{} } +func newOrExistingRestrictFetchOptionsRestrictByType( + fetchOpts *storage.FetchOptions, +) *storage.RestrictByType { + if v := fetchOpts.RestrictFetchOptions.RestrictByType; v != nil { + return v + } + return &storage.RestrictByType{} +} + // ParseStep parses the step duration for an HTTP request. func ParseStep(r *http.Request) (time.Duration, bool, error) { step := r.FormValue(StepParam) diff --git a/src/query/api/v1/handler/fetch_options_test.go b/src/query/api/v1/handler/fetch_options_test.go index d3acd770ae..13b3e87a02 100644 --- a/src/query/api/v1/handler/fetch_options_test.go +++ b/src/query/api/v1/handler/fetch_options_test.go @@ -79,7 +79,9 @@ func TestFetchOptionsBuilder(t *testing.T) { MetricsTypeHeader: storage.UnaggregatedMetricsType.String(), }, expectedRestrict: &storage.RestrictFetchOptions{ - MetricsType: storage.UnaggregatedMetricsType, + RestrictByType: &storage.RestrictByType{ + MetricsType: storage.UnaggregatedMetricsType, + }, }, }, { @@ -89,8 +91,10 @@ func TestFetchOptionsBuilder(t *testing.T) { MetricsStoragePolicyHeader: "1m:14d", }, expectedRestrict: &storage.RestrictFetchOptions{ - MetricsType: storage.AggregatedMetricsType, - StoragePolicy: policy.MustParseStoragePolicy("1m:14d"), + RestrictByType: &storage.RestrictByType{ + MetricsType: storage.AggregatedMetricsType, + StoragePolicy: policy.MustParseStoragePolicy("1m:14d"), + }, }, }, { diff --git a/src/query/api/v1/handler/prometheus/common.go b/src/query/api/v1/handler/prometheus/common.go index e4de39ebc0..a2d39fe2ba 100644 --- a/src/query/api/v1/handler/prometheus/common.go +++ b/src/query/api/v1/handler/prometheus/common.go @@ -639,22 +639,15 @@ func FilterSeriesByOptions( series []*ts.Series, opts *storage.FetchOptions, ) []*ts.Series { - if opts == nil || opts.RestrictFetchOptions == nil { + if opts == nil { return series } - matchers := opts.RestrictFetchOptions.MustApplyMatchers - if len(matchers) == 0 { - return series - } - - keys := make([][]byte, 0, len(matchers)) - for _, m := range matchers { - keys = append(keys, m.Name) - } - - for i, s := range series { - series[i].Tags = s.Tags.TagsWithoutKeys(keys) + keys := opts.RestrictFetchOptions.GetRestrictByTag().GetFilterByNames() + if len(keys) > 0 { + for i, s := range series { + series[i].Tags = s.Tags.TagsWithoutKeys(keys) + } } return series diff --git a/src/query/api/v1/handler/prometheus/native/read.go b/src/query/api/v1/handler/prometheus/native/read.go index 0c056f72e0..627dce52b0 100644 --- a/src/query/api/v1/handler/prometheus/native/read.go +++ b/src/query/api/v1/handler/prometheus/native/read.go @@ -146,7 +146,9 @@ func (h *PromReadHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { QueryContextOptions: models.QueryContextOptions{ LimitMaxTimeseries: fetchOpts.Limit, }} - if restrictOpts := fetchOpts.RestrictFetchOptions; restrictOpts != nil { + + restrictOpts := fetchOpts.RestrictFetchOptions.GetRestrictByType() + if restrictOpts != nil { restrict := &models.RestrictFetchTypeQueryContextOptions{ MetricsType: uint(restrictOpts.MetricsType), StoragePolicy: restrictOpts.StoragePolicy, diff --git a/src/query/api/v1/handler/prometheus/native/read_instantaneous.go b/src/query/api/v1/handler/prometheus/native/read_instantaneous.go index a8a13094f8..574223ec4a 100644 --- a/src/query/api/v1/handler/prometheus/native/read_instantaneous.go +++ b/src/query/api/v1/handler/prometheus/native/read_instantaneous.go @@ -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 { + + restrictOpts := fetchOpts.RestrictFetchOptions.GetRestrictByType() + if restrictOpts != nil { restrict := &models.RestrictFetchTypeQueryContextOptions{ MetricsType: uint(restrictOpts.MetricsType), StoragePolicy: restrictOpts.StoragePolicy, diff --git a/src/query/api/v1/handler/prometheus/validator/handler_test.go b/src/query/api/v1/handler/prometheus/validator/handler_test.go index 4c5254dc72..13e6494df6 100644 --- a/src/query/api/v1/handler/prometheus/validator/handler_test.go +++ b/src/query/api/v1/handler/prometheus/validator/handler_test.go @@ -22,7 +22,6 @@ package validator import ( "encoding/json" - "fmt" "io" "net/http" "net/http/httptest" @@ -335,7 +334,6 @@ func TestValidateEndpoint(t *testing.T) { recorder := httptest.NewRecorder() debugHandler.ServeHTTP(recorder, req) - fmt.Println(recorder.Body.String()) var mismatches MismatchesJSON require.NoError(t, json.Unmarshal(recorder.Body.Bytes(), &mismatches)) assert.False(t, mismatches.Correct) diff --git a/src/query/functions/fetch_test.go b/src/query/functions/fetch_test.go index e1832950bd..09230a17da 100644 --- a/src/query/functions/fetch_test.go +++ b/src/query/functions/fetch_test.go @@ -146,7 +146,8 @@ func TestFetchWithRestrictFetch(t *testing.T) { assert.Equal(t, expected, sink.Values) fetchOpts := mockStorage.LastFetchOptions() - require.NotNil(t, fetchOpts.RestrictFetchOptions) - assert.Equal(t, storage.AggregatedMetricsType, storage.MetricsType(fetchOpts.RestrictFetchOptions.MetricsType)) - assert.Equal(t, "10s:42d", fetchOpts.RestrictFetchOptions.StoragePolicy.String()) + restrictByType := fetchOpts.RestrictFetchOptions.GetRestrictByType() + require.NotNil(t, restrictByType) + assert.Equal(t, storage.AggregatedMetricsType, storage.MetricsType(restrictByType.MetricsType)) + assert.Equal(t, "10s:42d", restrictByType.StoragePolicy.String()) } diff --git a/src/query/generated/proto/rpcpb/query.pb.go b/src/query/generated/proto/rpcpb/query.pb.go index 66e8cb275a..10924c7842 100644 --- a/src/query/generated/proto/rpcpb/query.pb.go +++ b/src/query/generated/proto/rpcpb/query.pb.go @@ -35,6 +35,8 @@ TagMatcher FetchOptions RestrictFetchOptions + RestrictFetchType + RestrictFetchTags FetchResponse Series SeriesMetadata @@ -457,9 +459,8 @@ func (m *FetchOptions) GetIncludeResolution() bool { } type RestrictFetchOptions struct { - MetricsType MetricsType `protobuf:"varint,1,opt,name=metricsType,proto3,enum=rpc.MetricsType" json:"metricsType,omitempty"` - MetricsStoragePolicy *policypb.StoragePolicy `protobuf:"bytes,2,opt,name=metricsStoragePolicy" json:"metricsStoragePolicy,omitempty"` - MustApplyMatchers *TagMatchers `protobuf:"bytes,3,opt,name=mustApplyMatchers" json:"mustApplyMatchers,omitempty"` + RestrictFetchType *RestrictFetchType `protobuf:"bytes,1,opt,name=RestrictFetchType" json:"RestrictFetchType,omitempty"` + RestrictFetchTags *RestrictFetchTags `protobuf:"bytes,2,opt,name=RestrictFetchTags" json:"RestrictFetchTags,omitempty"` } func (m *RestrictFetchOptions) Reset() { *m = RestrictFetchOptions{} } @@ -467,23 +468,64 @@ func (m *RestrictFetchOptions) String() string { return proto.Compact func (*RestrictFetchOptions) ProtoMessage() {} func (*RestrictFetchOptions) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{6} } -func (m *RestrictFetchOptions) GetMetricsType() MetricsType { +func (m *RestrictFetchOptions) GetRestrictFetchType() *RestrictFetchType { + if m != nil { + return m.RestrictFetchType + } + return nil +} + +func (m *RestrictFetchOptions) GetRestrictFetchTags() *RestrictFetchTags { + if m != nil { + return m.RestrictFetchTags + } + return nil +} + +type RestrictFetchType struct { + MetricsType MetricsType `protobuf:"varint,1,opt,name=metricsType,proto3,enum=rpc.MetricsType" json:"metricsType,omitempty"` + MetricsStoragePolicy *policypb.StoragePolicy `protobuf:"bytes,2,opt,name=metricsStoragePolicy" json:"metricsStoragePolicy,omitempty"` +} + +func (m *RestrictFetchType) Reset() { *m = RestrictFetchType{} } +func (m *RestrictFetchType) String() string { return proto.CompactTextString(m) } +func (*RestrictFetchType) ProtoMessage() {} +func (*RestrictFetchType) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{7} } + +func (m *RestrictFetchType) GetMetricsType() MetricsType { if m != nil { return m.MetricsType } return MetricsType_UNKNOWN_METRICS_TYPE } -func (m *RestrictFetchOptions) GetMetricsStoragePolicy() *policypb.StoragePolicy { +func (m *RestrictFetchType) GetMetricsStoragePolicy() *policypb.StoragePolicy { if m != nil { return m.MetricsStoragePolicy } return nil } -func (m *RestrictFetchOptions) GetMustApplyMatchers() *TagMatchers { +type RestrictFetchTags struct { + Restrict *TagMatchers `protobuf:"bytes,1,opt,name=restrict" json:"restrict,omitempty"` + Strip [][]byte `protobuf:"bytes,2,rep,name=strip" json:"strip,omitempty"` +} + +func (m *RestrictFetchTags) Reset() { *m = RestrictFetchTags{} } +func (m *RestrictFetchTags) String() string { return proto.CompactTextString(m) } +func (*RestrictFetchTags) ProtoMessage() {} +func (*RestrictFetchTags) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{8} } + +func (m *RestrictFetchTags) GetRestrict() *TagMatchers { if m != nil { - return m.MustApplyMatchers + return m.Restrict + } + return nil +} + +func (m *RestrictFetchTags) GetStrip() [][]byte { + if m != nil { + return m.Strip } return nil } @@ -496,7 +538,7 @@ type FetchResponse struct { func (m *FetchResponse) Reset() { *m = FetchResponse{} } func (m *FetchResponse) String() string { return proto.CompactTextString(m) } func (*FetchResponse) ProtoMessage() {} -func (*FetchResponse) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{7} } +func (*FetchResponse) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{9} } func (m *FetchResponse) GetSeries() []*Series { if m != nil { @@ -523,7 +565,7 @@ type Series struct { func (m *Series) Reset() { *m = Series{} } func (m *Series) String() string { return proto.CompactTextString(m) } func (*Series) ProtoMessage() {} -func (*Series) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{8} } +func (*Series) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{10} } type isSeries_Value interface { isSeries_Value() @@ -652,7 +694,7 @@ type SeriesMetadata struct { func (m *SeriesMetadata) Reset() { *m = SeriesMetadata{} } func (m *SeriesMetadata) String() string { return proto.CompactTextString(m) } func (*SeriesMetadata) ProtoMessage() {} -func (*SeriesMetadata) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{9} } +func (*SeriesMetadata) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{11} } func (m *SeriesMetadata) GetId() []byte { if m != nil { @@ -683,7 +725,7 @@ type DecompressedSeries struct { func (m *DecompressedSeries) Reset() { *m = DecompressedSeries{} } func (m *DecompressedSeries) String() string { return proto.CompactTextString(m) } func (*DecompressedSeries) ProtoMessage() {} -func (*DecompressedSeries) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{10} } +func (*DecompressedSeries) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{12} } func (m *DecompressedSeries) GetDatapoints() []*Datapoint { if m != nil { @@ -707,7 +749,7 @@ type Datapoint struct { func (m *Datapoint) Reset() { *m = Datapoint{} } func (m *Datapoint) String() string { return proto.CompactTextString(m) } func (*Datapoint) ProtoMessage() {} -func (*Datapoint) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{11} } +func (*Datapoint) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{13} } func (m *Datapoint) GetTimestamp() int64 { if m != nil { @@ -731,7 +773,7 @@ type Tag struct { func (m *Tag) Reset() { *m = Tag{} } func (m *Tag) String() string { return proto.CompactTextString(m) } func (*Tag) ProtoMessage() {} -func (*Tag) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{12} } +func (*Tag) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{14} } func (m *Tag) GetName() []byte { if m != nil { @@ -755,7 +797,7 @@ type M3CompressedSeries struct { func (m *M3CompressedSeries) Reset() { *m = M3CompressedSeries{} } func (m *M3CompressedSeries) String() string { return proto.CompactTextString(m) } func (*M3CompressedSeries) ProtoMessage() {} -func (*M3CompressedSeries) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{13} } +func (*M3CompressedSeries) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{15} } func (m *M3CompressedSeries) GetCompressedTags() []byte { if m != nil { @@ -778,7 +820,7 @@ type M3CompressedValuesReplica struct { func (m *M3CompressedValuesReplica) Reset() { *m = M3CompressedValuesReplica{} } func (m *M3CompressedValuesReplica) String() string { return proto.CompactTextString(m) } func (*M3CompressedValuesReplica) ProtoMessage() {} -func (*M3CompressedValuesReplica) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{14} } +func (*M3CompressedValuesReplica) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{16} } func (m *M3CompressedValuesReplica) GetSegments() []*M3Segments { if m != nil { @@ -795,7 +837,7 @@ type M3Segments struct { func (m *M3Segments) Reset() { *m = M3Segments{} } func (m *M3Segments) String() string { return proto.CompactTextString(m) } func (*M3Segments) ProtoMessage() {} -func (*M3Segments) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{15} } +func (*M3Segments) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{17} } func (m *M3Segments) GetMerged() *M3Segment { if m != nil { @@ -821,7 +863,7 @@ type M3Segment struct { func (m *M3Segment) Reset() { *m = M3Segment{} } func (m *M3Segment) String() string { return proto.CompactTextString(m) } func (*M3Segment) ProtoMessage() {} -func (*M3Segment) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{16} } +func (*M3Segment) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{18} } func (m *M3Segment) GetHead() []byte { if m != nil { @@ -863,7 +905,7 @@ type SearchRequest struct { func (m *SearchRequest) Reset() { *m = SearchRequest{} } func (m *SearchRequest) String() string { return proto.CompactTextString(m) } func (*SearchRequest) ProtoMessage() {} -func (*SearchRequest) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{17} } +func (*SearchRequest) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{19} } type isSearchRequest_Matchers interface { isSearchRequest_Matchers() @@ -975,7 +1017,7 @@ type M3TagProperty struct { func (m *M3TagProperty) Reset() { *m = M3TagProperty{} } func (m *M3TagProperty) String() string { return proto.CompactTextString(m) } func (*M3TagProperty) ProtoMessage() {} -func (*M3TagProperty) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{18} } +func (*M3TagProperty) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{20} } func (m *M3TagProperty) GetId() []byte { if m != nil { @@ -998,7 +1040,7 @@ type M3TagProperties struct { func (m *M3TagProperties) Reset() { *m = M3TagProperties{} } func (m *M3TagProperties) String() string { return proto.CompactTextString(m) } func (*M3TagProperties) ProtoMessage() {} -func (*M3TagProperties) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{19} } +func (*M3TagProperties) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{21} } func (m *M3TagProperties) GetProperties() []*M3TagProperty { if m != nil { @@ -1015,7 +1057,7 @@ type TagProperty struct { func (m *TagProperty) Reset() { *m = TagProperty{} } func (m *TagProperty) String() string { return proto.CompactTextString(m) } func (*TagProperty) ProtoMessage() {} -func (*TagProperty) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{20} } +func (*TagProperty) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{22} } func (m *TagProperty) GetKey() []byte { if m != nil { @@ -1038,7 +1080,7 @@ type TagProperties struct { func (m *TagProperties) Reset() { *m = TagProperties{} } func (m *TagProperties) String() string { return proto.CompactTextString(m) } func (*TagProperties) ProtoMessage() {} -func (*TagProperties) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{21} } +func (*TagProperties) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{23} } func (m *TagProperties) GetProperties() []*TagProperty { if m != nil { @@ -1058,7 +1100,7 @@ type SearchResponse struct { func (m *SearchResponse) Reset() { *m = SearchResponse{} } func (m *SearchResponse) String() string { return proto.CompactTextString(m) } func (*SearchResponse) ProtoMessage() {} -func (*SearchResponse) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{22} } +func (*SearchResponse) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{24} } type isSearchResponse_Value interface { isSearchResponse_Value() @@ -1189,7 +1231,7 @@ type CompleteTagsRequestOptions struct { func (m *CompleteTagsRequestOptions) Reset() { *m = CompleteTagsRequestOptions{} } func (m *CompleteTagsRequestOptions) String() string { return proto.CompactTextString(m) } func (*CompleteTagsRequestOptions) ProtoMessage() {} -func (*CompleteTagsRequestOptions) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{23} } +func (*CompleteTagsRequestOptions) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{25} } func (m *CompleteTagsRequestOptions) GetType() CompleteTagsType { if m != nil { @@ -1236,7 +1278,7 @@ type CompleteTagsRequest struct { func (m *CompleteTagsRequest) Reset() { *m = CompleteTagsRequest{} } func (m *CompleteTagsRequest) String() string { return proto.CompactTextString(m) } func (*CompleteTagsRequest) ProtoMessage() {} -func (*CompleteTagsRequest) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{24} } +func (*CompleteTagsRequest) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{26} } type isCompleteTagsRequest_Matchers interface { isCompleteTagsRequest_Matchers() @@ -1333,7 +1375,7 @@ type TagNames struct { func (m *TagNames) Reset() { *m = TagNames{} } func (m *TagNames) String() string { return proto.CompactTextString(m) } func (*TagNames) ProtoMessage() {} -func (*TagNames) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{25} } +func (*TagNames) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{27} } func (m *TagNames) GetNames() [][]byte { if m != nil { @@ -1350,7 +1392,7 @@ type TagValue struct { func (m *TagValue) Reset() { *m = TagValue{} } func (m *TagValue) String() string { return proto.CompactTextString(m) } func (*TagValue) ProtoMessage() {} -func (*TagValue) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{26} } +func (*TagValue) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{28} } func (m *TagValue) GetKey() []byte { if m != nil { @@ -1373,7 +1415,7 @@ type TagValues struct { func (m *TagValues) Reset() { *m = TagValues{} } func (m *TagValues) String() string { return proto.CompactTextString(m) } func (*TagValues) ProtoMessage() {} -func (*TagValues) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{27} } +func (*TagValues) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{29} } func (m *TagValues) GetValues() []*TagValue { if m != nil { @@ -1393,7 +1435,7 @@ type CompleteTagsResponse struct { func (m *CompleteTagsResponse) Reset() { *m = CompleteTagsResponse{} } func (m *CompleteTagsResponse) String() string { return proto.CompactTextString(m) } func (*CompleteTagsResponse) ProtoMessage() {} -func (*CompleteTagsResponse) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{28} } +func (*CompleteTagsResponse) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{30} } type isCompleteTagsResponse_Value interface { isCompleteTagsResponse_Value() @@ -1522,7 +1564,7 @@ type ResultMetadata struct { func (m *ResultMetadata) Reset() { *m = ResultMetadata{} } func (m *ResultMetadata) String() string { return proto.CompactTextString(m) } func (*ResultMetadata) ProtoMessage() {} -func (*ResultMetadata) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{29} } +func (*ResultMetadata) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{31} } func (m *ResultMetadata) GetExhaustive() bool { if m != nil { @@ -1553,7 +1595,7 @@ type Warning struct { func (m *Warning) Reset() { *m = Warning{} } func (m *Warning) String() string { return proto.CompactTextString(m) } func (*Warning) ProtoMessage() {} -func (*Warning) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{30} } +func (*Warning) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{32} } func (m *Warning) GetName() []byte { if m != nil { @@ -1577,6 +1619,8 @@ func init() { proto.RegisterType((*TagMatcher)(nil), "rpc.TagMatcher") proto.RegisterType((*FetchOptions)(nil), "rpc.FetchOptions") proto.RegisterType((*RestrictFetchOptions)(nil), "rpc.RestrictFetchOptions") + proto.RegisterType((*RestrictFetchType)(nil), "rpc.RestrictFetchType") + proto.RegisterType((*RestrictFetchTags)(nil), "rpc.RestrictFetchTags") proto.RegisterType((*FetchResponse)(nil), "rpc.FetchResponse") proto.RegisterType((*Series)(nil), "rpc.Series") proto.RegisterType((*SeriesMetadata)(nil), "rpc.SeriesMetadata") @@ -2105,6 +2149,44 @@ func (m *RestrictFetchOptions) Marshal() (dAtA []byte, err error) { } func (m *RestrictFetchOptions) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.RestrictFetchType != nil { + dAtA[i] = 0xa + i++ + i = encodeVarintQuery(dAtA, i, uint64(m.RestrictFetchType.Size())) + n5, err := m.RestrictFetchType.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n5 + } + if m.RestrictFetchTags != nil { + dAtA[i] = 0x12 + i++ + i = encodeVarintQuery(dAtA, i, uint64(m.RestrictFetchTags.Size())) + n6, err := m.RestrictFetchTags.MarshalTo(dAtA[i:]) + if err != nil { + return 0, err + } + i += n6 + } + return i, nil +} + +func (m *RestrictFetchType) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RestrictFetchType) MarshalTo(dAtA []byte) (int, error) { var i int _ = i var l int @@ -2118,21 +2200,47 @@ func (m *RestrictFetchOptions) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x12 i++ i = encodeVarintQuery(dAtA, i, uint64(m.MetricsStoragePolicy.Size())) - n5, err := m.MetricsStoragePolicy.MarshalTo(dAtA[i:]) + n7, err := m.MetricsStoragePolicy.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n5 + i += n7 } - if m.MustApplyMatchers != nil { - dAtA[i] = 0x1a + return i, nil +} + +func (m *RestrictFetchTags) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalTo(dAtA) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RestrictFetchTags) MarshalTo(dAtA []byte) (int, error) { + var i int + _ = i + var l int + _ = l + if m.Restrict != nil { + dAtA[i] = 0xa i++ - i = encodeVarintQuery(dAtA, i, uint64(m.MustApplyMatchers.Size())) - n6, err := m.MustApplyMatchers.MarshalTo(dAtA[i:]) + i = encodeVarintQuery(dAtA, i, uint64(m.Restrict.Size())) + n8, err := m.Restrict.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n6 + i += n8 + } + if len(m.Strip) > 0 { + for _, b := range m.Strip { + dAtA[i] = 0x12 + i++ + i = encodeVarintQuery(dAtA, i, uint64(len(b))) + i += copy(dAtA[i:], b) + } } return i, nil } @@ -2168,11 +2276,11 @@ func (m *FetchResponse) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x12 i++ i = encodeVarintQuery(dAtA, i, uint64(m.Meta.Size())) - n7, err := m.Meta.MarshalTo(dAtA[i:]) + n9, err := m.Meta.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n7 + i += n9 } return i, nil } @@ -2196,18 +2304,18 @@ func (m *Series) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintQuery(dAtA, i, uint64(m.Meta.Size())) - n8, err := m.Meta.MarshalTo(dAtA[i:]) + n10, err := m.Meta.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n8 + i += n10 } if m.Value != nil { - nn9, err := m.Value.MarshalTo(dAtA[i:]) + nn11, err := m.Value.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += nn9 + i += nn11 } return i, nil } @@ -2218,11 +2326,11 @@ func (m *Series_Decompressed) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x12 i++ i = encodeVarintQuery(dAtA, i, uint64(m.Decompressed.Size())) - n10, err := m.Decompressed.MarshalTo(dAtA[i:]) + n12, err := m.Decompressed.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n10 + i += n12 } return i, nil } @@ -2232,11 +2340,11 @@ func (m *Series_Compressed) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x1a i++ i = encodeVarintQuery(dAtA, i, uint64(m.Compressed.Size())) - n11, err := m.Compressed.MarshalTo(dAtA[i:]) + n13, err := m.Compressed.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n11 + i += n13 } return i, nil } @@ -2460,11 +2568,11 @@ func (m *M3Segments) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintQuery(dAtA, i, uint64(m.Merged.Size())) - n12, err := m.Merged.MarshalTo(dAtA[i:]) + n14, err := m.Merged.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n12 + i += n14 } if len(m.Unmerged) > 0 { for _, msg := range m.Unmerged { @@ -2537,11 +2645,11 @@ func (m *SearchRequest) MarshalTo(dAtA []byte) (int, error) { var l int _ = l if m.Matchers != nil { - nn13, err := m.Matchers.MarshalTo(dAtA[i:]) + nn15, err := m.Matchers.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += nn13 + i += nn15 } if m.Start != 0 { dAtA[i] = 0x10 @@ -2557,11 +2665,11 @@ func (m *SearchRequest) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x22 i++ i = encodeVarintQuery(dAtA, i, uint64(m.Options.Size())) - n14, err := m.Options.MarshalTo(dAtA[i:]) + n16, err := m.Options.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n14 + i += n16 } return i, nil } @@ -2572,11 +2680,11 @@ func (m *SearchRequest_TagMatchers) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintQuery(dAtA, i, uint64(m.TagMatchers.Size())) - n15, err := m.TagMatchers.MarshalTo(dAtA[i:]) + n17, err := m.TagMatchers.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n15 + i += n17 } return i, nil } @@ -2716,21 +2824,21 @@ func (m *SearchResponse) MarshalTo(dAtA []byte) (int, error) { var l int _ = l if m.Value != nil { - nn16, err := m.Value.MarshalTo(dAtA[i:]) + nn18, err := m.Value.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += nn16 + i += nn18 } if m.Meta != nil { dAtA[i] = 0x1a i++ i = encodeVarintQuery(dAtA, i, uint64(m.Meta.Size())) - n17, err := m.Meta.MarshalTo(dAtA[i:]) + n19, err := m.Meta.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n17 + i += n19 } return i, nil } @@ -2741,11 +2849,11 @@ func (m *SearchResponse_Decompressed) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintQuery(dAtA, i, uint64(m.Decompressed.Size())) - n18, err := m.Decompressed.MarshalTo(dAtA[i:]) + n20, err := m.Decompressed.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n18 + i += n20 } return i, nil } @@ -2755,11 +2863,11 @@ func (m *SearchResponse_Compressed) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x12 i++ i = encodeVarintQuery(dAtA, i, uint64(m.Compressed.Size())) - n19, err := m.Compressed.MarshalTo(dAtA[i:]) + n21, err := m.Compressed.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n19 + i += n21 } return i, nil } @@ -2805,11 +2913,11 @@ func (m *CompleteTagsRequestOptions) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x2a i++ i = encodeVarintQuery(dAtA, i, uint64(m.Options.Size())) - n20, err := m.Options.MarshalTo(dAtA[i:]) + n22, err := m.Options.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n20 + i += n22 } return i, nil } @@ -2830,21 +2938,21 @@ func (m *CompleteTagsRequest) MarshalTo(dAtA []byte) (int, error) { var l int _ = l if m.Matchers != nil { - nn21, err := m.Matchers.MarshalTo(dAtA[i:]) + nn23, err := m.Matchers.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += nn21 + i += nn23 } if m.Options != nil { dAtA[i] = 0x12 i++ i = encodeVarintQuery(dAtA, i, uint64(m.Options.Size())) - n22, err := m.Options.MarshalTo(dAtA[i:]) + n24, err := m.Options.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n22 + i += n24 } return i, nil } @@ -2855,11 +2963,11 @@ func (m *CompleteTagsRequest_TagMatchers) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintQuery(dAtA, i, uint64(m.TagMatchers.Size())) - n23, err := m.TagMatchers.MarshalTo(dAtA[i:]) + n25, err := m.TagMatchers.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n23 + i += n25 } return i, nil } @@ -2967,21 +3075,21 @@ func (m *CompleteTagsResponse) MarshalTo(dAtA []byte) (int, error) { var l int _ = l if m.Value != nil { - nn24, err := m.Value.MarshalTo(dAtA[i:]) + nn26, err := m.Value.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += nn24 + i += nn26 } if m.Meta != nil { dAtA[i] = 0x1a i++ i = encodeVarintQuery(dAtA, i, uint64(m.Meta.Size())) - n25, err := m.Meta.MarshalTo(dAtA[i:]) + n27, err := m.Meta.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n25 + i += n27 } return i, nil } @@ -2992,11 +3100,11 @@ func (m *CompleteTagsResponse_Default) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0xa i++ i = encodeVarintQuery(dAtA, i, uint64(m.Default.Size())) - n26, err := m.Default.MarshalTo(dAtA[i:]) + n28, err := m.Default.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n26 + i += n28 } return i, nil } @@ -3006,11 +3114,11 @@ func (m *CompleteTagsResponse_NamesOnly) MarshalTo(dAtA []byte) (int, error) { dAtA[i] = 0x12 i++ i = encodeVarintQuery(dAtA, i, uint64(m.NamesOnly.Size())) - n27, err := m.NamesOnly.MarshalTo(dAtA[i:]) + n29, err := m.NamesOnly.MarshalTo(dAtA[i:]) if err != nil { return 0, err } - i += n27 + i += n29 } return i, nil } @@ -3052,22 +3160,22 @@ func (m *ResultMetadata) MarshalTo(dAtA []byte) (int, error) { } } if len(m.Resolutions) > 0 { - dAtA29 := make([]byte, len(m.Resolutions)*10) - var j28 int + dAtA31 := make([]byte, len(m.Resolutions)*10) + var j30 int for _, num1 := range m.Resolutions { num := uint64(num1) for num >= 1<<7 { - dAtA29[j28] = uint8(uint64(num)&0x7f | 0x80) + dAtA31[j30] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j28++ + j30++ } - dAtA29[j28] = uint8(num) - j28++ + dAtA31[j30] = uint8(num) + j30++ } dAtA[i] = 0x1a i++ - i = encodeVarintQuery(dAtA, i, uint64(j28)) - i += copy(dAtA[i:], dAtA29[:j28]) + i = encodeVarintQuery(dAtA, i, uint64(j30)) + i += copy(dAtA[i:], dAtA31[:j30]) } return i, nil } @@ -3216,6 +3324,20 @@ func (m *FetchOptions) Size() (n int) { } func (m *RestrictFetchOptions) Size() (n int) { + var l int + _ = l + if m.RestrictFetchType != nil { + l = m.RestrictFetchType.Size() + n += 1 + l + sovQuery(uint64(l)) + } + if m.RestrictFetchTags != nil { + l = m.RestrictFetchTags.Size() + n += 1 + l + sovQuery(uint64(l)) + } + return n +} + +func (m *RestrictFetchType) Size() (n int) { var l int _ = l if m.MetricsType != 0 { @@ -3225,10 +3347,22 @@ func (m *RestrictFetchOptions) Size() (n int) { l = m.MetricsStoragePolicy.Size() n += 1 + l + sovQuery(uint64(l)) } - if m.MustApplyMatchers != nil { - l = m.MustApplyMatchers.Size() + return n +} + +func (m *RestrictFetchTags) Size() (n int) { + var l int + _ = l + if m.Restrict != nil { + l = m.Restrict.Size() n += 1 + l + sovQuery(uint64(l)) } + if len(m.Strip) > 0 { + for _, b := range m.Strip { + l = len(b) + n += 1 + l + sovQuery(uint64(l)) + } + } return n } @@ -4421,6 +4555,122 @@ func (m *RestrictFetchOptions) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: RestrictFetchOptions: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RestrictFetchType", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.RestrictFetchType == nil { + m.RestrictFetchType = &RestrictFetchType{} + } + if err := m.RestrictFetchType.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RestrictFetchTags", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + msglen + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.RestrictFetchTags == nil { + m.RestrictFetchTags = &RestrictFetchTags{} + } + if err := m.RestrictFetchTags.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RestrictFetchType) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RestrictFetchType: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RestrictFetchType: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { case 1: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field MetricsType", wireType) @@ -4473,9 +4723,59 @@ func (m *RestrictFetchOptions) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 3: + default: + iNdEx = preIndex + skippy, err := skipQuery(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthQuery + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RestrictFetchTags) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RestrictFetchTags: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RestrictFetchTags: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field MustApplyMatchers", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Restrict", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -4499,13 +4799,42 @@ func (m *RestrictFetchOptions) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.MustApplyMatchers == nil { - m.MustApplyMatchers = &TagMatchers{} + if m.Restrict == nil { + m.Restrict = &TagMatchers{} } - if err := m.MustApplyMatchers.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.Restrict.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Strip", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowQuery + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthQuery + } + postIndex := iNdEx + byteLen + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Strip = append(m.Strip, make([]byte, postIndex-iNdEx)) + copy(m.Strip[len(m.Strip)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipQuery(dAtA[iNdEx:]) @@ -7440,105 +7769,108 @@ func init() { } var fileDescriptorQuery = []byte{ - // 1596 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x58, 0xdd, 0x72, 0x1b, 0xc5, - 0x12, 0xd6, 0x6a, 0xad, 0xbf, 0xd6, 0x8f, 0xe5, 0xb1, 0xcf, 0x89, 0xec, 0x93, 0xe3, 0xe3, 0xda, - 0x03, 0xc1, 0x38, 0xc1, 0x4a, 0xec, 0x84, 0x10, 0xaa, 0x08, 0xc8, 0xb6, 0x62, 0xbb, 0x62, 0x4b, - 0xce, 0x68, 0x4d, 0x02, 0x05, 0x65, 0x56, 0xab, 0x89, 0xbc, 0xe5, 0xfd, 0xcb, 0xee, 0x28, 0xc4, - 0x29, 0x1e, 0x82, 0xe2, 0x15, 0x28, 0x78, 0x82, 0x3c, 0x02, 0x17, 0x5c, 0x72, 0xc7, 0x2d, 0x15, - 0xb8, 0xe0, 0x31, 0xa8, 0x99, 0x9d, 0xfd, 0x93, 0xe4, 0x72, 0x2a, 0x77, 0x3b, 0xdd, 0x5f, 0x77, - 0x4f, 0xf7, 0xf4, 0x7c, 0x3d, 0x12, 0xdc, 0x1f, 0x1a, 0xf4, 0x74, 0xd4, 0x5f, 0xd7, 0x1d, 0xab, - 0x69, 0x6d, 0x0e, 0xfa, 0x4d, 0x6b, 0xb3, 0xe9, 0x7b, 0x7a, 0xf3, 0xd9, 0x88, 0x78,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0xe6, 0x68, 0x40, 0x30, - 0xf1, 0x1d, 0x73, 0xc4, 0x73, 0x2b, 0xac, 0x48, 0xab, 0x45, 0x3c, 0xa9, 0x50, 0x7e, 0x97, 0x60, - 0x61, 0x5a, 0xad, 0xd0, 0x06, 0x94, 0xc5, 0x8d, 0x63, 0x87, 0xc2, 0x8b, 0x1e, 0x1d, 0x56, 0x2c, - 0xc7, 0x49, 0x10, 0x7a, 0x08, 0x0b, 0x62, 0xd9, 0xa3, 0x8e, 0xa7, 0x0d, 0xc9, 0x11, 0xbf, 0x92, - 0xe2, 0x60, 0xae, 0xac, 0x87, 0x57, 0x75, 0x3d, 0xa5, 0xc6, 0x53, 0x8d, 0xd0, 0x7d, 0x98, 0xb3, - 0x46, 0x3e, 0x6d, 0xb9, 0xae, 0x79, 0x7e, 0xd9, 0xad, 0xc0, 0x93, 0x50, 0xe5, 0x6b, 0xa8, 0x8a, - 0x7b, 0x28, 0xee, 0xfb, 0xff, 0x21, 0xef, 0x13, 0xcf, 0x20, 0x61, 0x77, 0x97, 0xb9, 0x97, 0x1e, - 0x17, 0x61, 0xa1, 0x42, 0xef, 0xc1, 0x8c, 0x45, 0xa8, 0x26, 0xb6, 0x3c, 0x1f, 0xf6, 0xd2, 0xc8, - 0xa4, 0x87, 0x84, 0x6a, 0x03, 0x8d, 0x6a, 0x98, 0x03, 0x94, 0x57, 0x12, 0xe4, 0x7b, 0x69, 0x1b, - 0x29, 0x61, 0x13, 0xa8, 0xd2, 0x36, 0xe8, 0x13, 0xa8, 0x0c, 0x88, 0xee, 0x58, 0xae, 0x47, 0x7c, - 0x9f, 0x0c, 0xa2, 0xba, 0x30, 0x83, 0x9d, 0x84, 0x22, 0x30, 0xde, 0xcb, 0xe0, 0x14, 0x1c, 0xdd, - 0x03, 0x48, 0x18, 0xcb, 0x09, 0xe3, 0xc3, 0xcd, 0xed, 0x49, 0xe3, 0x04, 0x78, 0xab, 0x20, 0x6e, - 0xa2, 0xf2, 0x04, 0x6a, 0x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, 0x98, 0x48, 0x7e, 0x82, 0x09, 0x23, 0xb2, 0x96, 0x2f, 0x21, 0xf8, 0x98, 0x32, - 0x7f, 0x91, 0x60, 0x89, 0xdd, 0x43, 0x93, 0x50, 0xc2, 0x8e, 0x42, 0x74, 0x5c, 0x38, 0x28, 0xdf, - 0x17, 0xcf, 0x99, 0x60, 0x42, 0xfe, 0x8b, 0x3b, 0x4c, 0xc2, 0xe3, 0x37, 0x0d, 0x3b, 0xeb, 0xa7, - 0x86, 0x49, 0x89, 0xd7, 0xd1, 0x2c, 0xa2, 0x86, 0x34, 0x57, 0xc1, 0x63, 0xd2, 0xb8, 0x2b, 0xe5, - 0x29, 0x5d, 0x39, 0x33, 0xb5, 0x2b, 0x73, 0x97, 0x75, 0xa5, 0xf2, 0x83, 0x04, 0xf3, 0x53, 0xd2, - 0x78, 0xcb, 0x8b, 0x73, 0x2f, 0x0e, 0x1d, 0xd4, 0xfe, 0x7f, 0x13, 0x89, 0xa7, 0xeb, 0x34, 0xfd, - 0x7a, 0xac, 0x40, 0x51, 0xd5, 0x86, 0x2c, 0x71, 0x9e, 0x35, 0x23, 0xe2, 0xa0, 0x97, 0x2a, 0x38, - 0x58, 0x28, 0xb7, 0x39, 0x82, 0xb3, 0xdf, 0x25, 0xdd, 0x2a, 0x27, 0xba, 0x75, 0x03, 0x4a, 0xa1, - 0x95, 0x8f, 0xde, 0x8d, 0x40, 0x41, 0x97, 0x56, 0xc3, 0xe4, 0xb8, 0x3e, 0xb2, 0xf9, 0x51, 0x82, - 0x85, 0xf4, 0xfe, 0x45, 0x93, 0xae, 0x41, 0x61, 0x40, 0x9e, 0x6a, 0x23, 0x93, 0xa6, 0x28, 0x33, - 0x0a, 0xb0, 0x97, 0xc1, 0x21, 0x00, 0x7d, 0x00, 0x25, 0xbe, 0xef, 0xae, 0x6d, 0x86, 0xef, 0x9e, - 0x28, 0x1c, 0x4f, 0x73, 0x2f, 0x83, 0x63, 0xc4, 0x5b, 0x74, 0xe3, 0x77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x00, 0x00, + // 1636 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x58, 0xdb, 0x72, 0xdb, 0x4e, + 0x19, 0xb7, 0xac, 0xf8, 0xf4, 0xf9, 0x10, 0x67, 0x13, 0xfe, 0x75, 0x42, 0x09, 0x1e, 0x01, 0x7f, + 0x42, 0x5a, 0xe2, 0xd6, 0x69, 0x29, 0x65, 0x86, 0x83, 0x13, 0xbb, 0x49, 0xa6, 0x89, 0x9d, 0xae, + 0x15, 0x5a, 0x18, 0x98, 0xb0, 0x96, 0xb7, 0x8e, 0x26, 0xd6, 0xa1, 0x92, 0x5c, 0x9a, 0x0e, 0x0f, + 0xc1, 0x30, 0x3c, 0x01, 0x0c, 0x3c, 0x41, 0x1f, 0x81, 0x0b, 0x2e, 0x79, 0x04, 0xa6, 0x70, 0xc1, + 0x63, 0x30, 0xbb, 0x5a, 0x9d, 0x2c, 0x65, 0xda, 0xe9, 0x9d, 0xbf, 0xf3, 0x7e, 0xdf, 0xfe, 0xf6, + 0xb7, 0x2b, 0xc3, 0xcf, 0x66, 0xba, 0x77, 0xb5, 0x98, 0xec, 0x69, 0x96, 0xd1, 0x31, 0xf6, 0xa7, + 0x93, 0x8e, 0xb1, 0xdf, 0x71, 0x1d, 0xad, 0xf3, 0x66, 0x41, 0x9d, 0x9b, 0xce, 0x8c, 0x9a, 0xd4, + 0x21, 0x1e, 0x9d, 0x76, 0x6c, 0xc7, 0xf2, 0xac, 0x8e, 0x63, 0x6b, 0xf6, 0xc4, 0xb7, 0xed, 0x71, + 0x0d, 0x92, 0x1d, 0x5b, 0xdb, 0xea, 0xdf, 0x92, 0xc4, 0xa0, 0x9e, 0xa3, 0x6b, 0x6e, 0x2a, 0x8d, + 0x6d, 0xcd, 0x75, 0xed, 0xc6, 0x9e, 0x88, 0x1f, 0x7e, 0x2a, 0x65, 0x15, 0xea, 0xc7, 0x94, 0xcc, +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diff --git a/src/query/generated/proto/rpcpb/query.proto b/src/query/generated/proto/rpcpb/query.proto index 904c99e274..7fcd180e4d 100644 --- a/src/query/generated/proto/rpcpb/query.proto +++ b/src/query/generated/proto/rpcpb/query.proto @@ -65,9 +65,18 @@ message FetchOptions { } message RestrictFetchOptions { + RestrictFetchType RestrictFetchType = 1; + RestrictFetchTags RestrictFetchTags = 2; +} + +message RestrictFetchType { MetricsType metricsType = 1; policypb.StoragePolicy metricsStoragePolicy = 2; - TagMatchers mustApplyMatchers = 3; +} + +message RestrictFetchTags { + TagMatchers restrict = 1; + repeated bytes strip = 2; } enum MetricsType { diff --git a/src/query/storage/fanout/storage.go b/src/query/storage/fanout/storage.go index 23c2744d4d..4fd988e6ef 100644 --- a/src/query/storage/fanout/storage.go +++ b/src/query/storage/fanout/storage.go @@ -345,14 +345,14 @@ func applyOptions( return result } - matchers := opts.RestrictFetchOptions.MustApplyMatchers - if len(matchers) > 0 { + filter := opts.RestrictFetchOptions.GetRestrictByTag().GetFilterByNames() + if len(filter) > 0 { // Filter out unwanted tags inplace. filteredList := result.CompletedTags[:0] for _, s := range result.CompletedTags { skip := false - for _, filter := range matchers { - if bytes.Equal(s.Name, filter.Name) { + for _, name := range filter { + if bytes.Equal(s.Name, name) { skip = true break } diff --git a/src/query/storage/index.go b/src/query/storage/index.go index f07b558264..58a2790748 100644 --- a/src/query/storage/index.go +++ b/src/query/storage/index.go @@ -125,8 +125,8 @@ func FetchQueryToM3Query( fetchQuery *FetchQuery, options *FetchOptions, ) (index.Query, error) { - withOpts := fetchQuery.WithAppliedOptions(options) - matchers := withOpts.TagMatchers + fetchQuery = fetchQuery.WithAppliedOptions(options) + matchers := fetchQuery.TagMatchers // If no matchers provided, explicitly set this to an AllQuery. if len(matchers) == 0 { return index.Query{ diff --git a/src/query/storage/m3/cluster_resolver.go b/src/query/storage/m3/cluster_resolver.go index 7955cb08b5..b8ecf5cbf7 100644 --- a/src/query/storage/m3/cluster_resolver.go +++ b/src/query/storage/m3/cluster_resolver.go @@ -21,6 +21,7 @@ package m3 import ( + "errors" "fmt" "sort" "time" @@ -301,12 +302,22 @@ func aggregatedNamespaces( func resolveClusterNamespacesForQueryWithRestrictFetchOptions( now, start time.Time, clusters Clusters, - restrict *storage.RestrictFetchOptions, + fetchOptions *storage.RestrictFetchOptions, ) (queryFanoutType, ClusterNamespaces, error) { coversRangeFilter := newCoversRangeFilter(coversRangeFilterOptions{ now: now, queryStart: start, }) + + if fetchOptions == nil { + return 0, nil, errors.New("fetch options must not be nil") + } + + restrict := fetchOptions.RestrictByType + if restrict == nil { + return 0, nil, errors.New("fetch options type restriction must not be nil") + } + result := func( namespace ClusterNamespace, err error, @@ -314,10 +325,12 @@ func resolveClusterNamespacesForQueryWithRestrictFetchOptions( if err != nil { return 0, nil, err } + if coversRangeFilter(namespace) { return namespaceCoversAllQueryRange, ClusterNamespaces{namespace}, nil } + return namespaceCoversPartialQueryRange, ClusterNamespaces{namespace}, nil } @@ -335,6 +348,7 @@ func resolveClusterNamespacesForQueryWithRestrictFetchOptions( fmt.Errorf("could not find namespace for storage policy: %v", restrict.StoragePolicy.String())) } + return result(ns, nil) default: return result(nil, diff --git a/src/query/storage/m3/cluster_resolver_test.go b/src/query/storage/m3/cluster_resolver_test.go index b93b95facf..6bd19a861c 100644 --- a/src/query/storage/m3/cluster_resolver_test.go +++ b/src/query/storage/m3/cluster_resolver_test.go @@ -312,7 +312,9 @@ var testCases = []struct { name: "restrict to unaggregated", queryLength: time.Hour * 1000, restrict: &storage.RestrictFetchOptions{ - MetricsType: storage.UnaggregatedMetricsType, + RestrictByType: &storage.RestrictByType{ + MetricsType: storage.UnaggregatedMetricsType, + }, }, expectedType: namespaceCoversPartialQueryRange, expectedClusterNames: []string{"UNAGG"}, @@ -321,9 +323,11 @@ var testCases = []struct { name: "restrict to aggregate filtered", queryLength: time.Hour * 1000, restrict: &storage.RestrictFetchOptions{ - MetricsType: storage.AggregatedMetricsType, - StoragePolicy: policy.MustParseStoragePolicy( - genResolution.String() + ":" + genRetentionFiltered.String()), + RestrictByType: &storage.RestrictByType{ + MetricsType: storage.AggregatedMetricsType, + StoragePolicy: policy.MustParseStoragePolicy( + genResolution.String() + ":" + genRetentionFiltered.String()), + }, }, expectedType: namespaceCoversPartialQueryRange, expectedClusterNames: []string{"AGG_FILTERED"}, @@ -332,9 +336,11 @@ var testCases = []struct { name: "restrict to aggregate unfiltered", queryLength: time.Hour * 1000, restrict: &storage.RestrictFetchOptions{ - MetricsType: storage.AggregatedMetricsType, - StoragePolicy: policy.MustParseStoragePolicy( - genResolution.String() + ":" + genRetentionUnfiltered.String()), + RestrictByType: &storage.RestrictByType{ + MetricsType: storage.AggregatedMetricsType, + StoragePolicy: policy.MustParseStoragePolicy( + genResolution.String() + ":" + genRetentionUnfiltered.String()), + }, }, expectedType: namespaceCoversPartialQueryRange, expectedClusterNames: []string{"AGG_NO_FILTER"}, @@ -343,7 +349,9 @@ var testCases = []struct { name: "restrict with unknown metrics type", queryLength: time.Hour * 1000, restrict: &storage.RestrictFetchOptions{ - MetricsType: storage.UnknownMetricsType, + RestrictByType: &storage.RestrictByType{ + MetricsType: storage.UnknownMetricsType, + }, }, expectedErrContains: "unrecognized metrics type:", }, @@ -351,8 +359,10 @@ var testCases = []struct { name: "restrict with unknown storage policy", queryLength: time.Hour * 1000, restrict: &storage.RestrictFetchOptions{ - MetricsType: storage.AggregatedMetricsType, - StoragePolicy: policy.MustParseStoragePolicy("1s:100d"), + RestrictByType: &storage.RestrictByType{ + MetricsType: storage.AggregatedMetricsType, + StoragePolicy: policy.MustParseStoragePolicy("1s:100d"), + }, }, expectedErrContains: "could not find namespace for storage policy:", }, diff --git a/src/query/storage/restrict_fetch_options.go b/src/query/storage/restrict_fetch_options.go new file mode 100644 index 0000000000..17d1afab06 --- /dev/null +++ b/src/query/storage/restrict_fetch_options.go @@ -0,0 +1,163 @@ +// Copyright (c) 2019 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package storage + +import ( + "bytes" + "fmt" + + "github.com/m3db/m3/src/metrics/policy" + "github.com/m3db/m3/src/query/models" +) + +// Validate will validate the restrict fetch options. +func (o *RestrictFetchOptions) Validate() error { + if o.RestrictByType != nil { + return o.RestrictByType.Validate() + } + + return nil +} + +// GetRestrictByType provides the type restrictions if present; nil otherwise. +func (o *RestrictFetchOptions) GetRestrictByType() *RestrictByType { + if o == nil { + return nil + } + + return o.RestrictByType +} + +// GetRestrictByTag provides the tag restrictions if present; nil otherwise. +func (o *RestrictFetchOptions) GetRestrictByTag() *RestrictByTag { + if o == nil { + return nil + } + + return o.RestrictByTag +} + +// GetMatchers provides the tag matchers by which results are restricted if +// present; nil otherwise. +func (o *RestrictByTag) GetMatchers() models.Matchers { + if o == nil { + return nil + } + + return o.Restrict +} + +// Validate will validate the restrict type restrictions. +func (o *RestrictByType) Validate() error { + switch o.MetricsType { + case UnaggregatedMetricsType: + if o.StoragePolicy != policy.EmptyStoragePolicy { + return fmt.Errorf( + "expected no storage policy for unaggregated metrics type, "+ + "instead got: %v", o.StoragePolicy.String()) + } + case AggregatedMetricsType: + if v := o.StoragePolicy.Resolution().Window; v <= 0 { + return fmt.Errorf( + "expected positive resolution window, instead got: %v", v) + } + if v := o.StoragePolicy.Resolution().Precision; v <= 0 { + return fmt.Errorf( + "expected positive resolution precision, instead got: %v", v) + } + if v := o.StoragePolicy.Retention().Duration(); v <= 0 { + return fmt.Errorf( + "expected positive retention, instead got: %v", v) + } + default: + return fmt.Errorf( + "unknown metrics type: %v", o.MetricsType) + } + return nil +} + +// GetFilterByNames returns the tag names to filter out of the response. +func (o *RestrictByTag) GetFilterByNames() [][]byte { + if o == nil { + return nil + } + + if o.Strip != nil { + return o.Strip + } + + o.Strip = make([][]byte, 0, len(o.Restrict)) + for _, r := range o.Restrict { + o.Strip = append(o.Strip, r.Name) + } + + return o.Strip +} + +// WithAppliedOptions returns a copy of the fetch query applied options +// that restricts the fetch with respect to labels that must be applied. +func (q *FetchQuery) WithAppliedOptions( + opts *FetchOptions, +) *FetchQuery { + result := *q + if opts == nil { + return &result + } + + restrictOpts := opts.RestrictFetchOptions + if restrictOpts == nil { + return &result + } + + restrict := restrictOpts.GetRestrictByTag().GetMatchers() + if len(restrict) == 0 { + return &result + } + + // Since must apply matchers will always be small (usually 1) + // it's better to not allocate intermediate datastructure and just + // perform n^2 matching. + existing := result.TagMatchers + for _, existingMatcher := range result.TagMatchers { + willBeOverridden := false + for _, matcher := range restrict { + if bytes.Equal(existingMatcher.Name, matcher.Name) { + willBeOverridden = true + break + } + } + + if willBeOverridden { + // We'll override this when we append the restrict matchers. + continue + } + + existing = append(existing, existingMatcher) + } + + // Now append the must apply matchers. + result.TagMatchers = append(existing, restrict...) + return &result +} + +func (q *FetchQuery) String() string { + return q.Raw +} diff --git a/src/query/storage/restrict_fetch_options_test.go b/src/query/storage/restrict_fetch_options_test.go new file mode 100644 index 0000000000..9b59c2724b --- /dev/null +++ b/src/query/storage/restrict_fetch_options_test.go @@ -0,0 +1,53 @@ +// Copyright (c) 2019 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package storage + +import ( + "testing" + + "github.com/m3db/m3/src/query/models" + + "github.com/stretchr/testify/require" +) + +func TestGetRestrict(t *testing.T) { + var opts *RestrictFetchOptions + require.Nil(t, opts.GetRestrictByTag()) + require.Nil(t, opts.GetRestrictByType()) + + opts = &RestrictFetchOptions{} + require.Nil(t, opts.GetRestrictByTag()) + require.Nil(t, opts.GetRestrictByType()) + + opts.RestrictByTag = &RestrictByTag{} + require.NotNil(t, opts.GetRestrictByTag()) + + matcher, err := models.NewMatcher(models.MatchEqual, []byte("f"), []byte("b")) + require.NoError(t, err) + matchers := models.Matchers{matcher} + + opts.RestrictByTag.Restrict = matchers + require.Equal(t, matchers, opts.GetRestrictByTag().GetMatchers()) + + byType := &RestrictByType{} + opts.RestrictByType = byType + require.Equal(t, byType, opts.GetRestrictByType()) +} diff --git a/src/query/storage/types.go b/src/query/storage/types.go index 55215adfcb..de1a0e5b11 100644 --- a/src/query/storage/types.go +++ b/src/query/storage/types.go @@ -21,7 +21,6 @@ package storage import ( - "bytes" "context" "fmt" "time" @@ -102,53 +101,6 @@ type FetchQuery struct { Interval time.Duration `json:"interval"` } -// WithAppliedOptions returns a copy of the fetch query applied options -// that restricts the fetch with respect to labels that must be applied. -func (q *FetchQuery) WithAppliedOptions( - opts *FetchOptions, -) *FetchQuery { - result := *q - if opts == nil { - return &result - } - - if restrictOpts := opts.RestrictFetchOptions; restrictOpts != nil { - mustApplyMatchers := restrictOpts.MustApplyMatchers - if n := len(mustApplyMatchers); n > 0 { - existing := result.TagMatchers - result.TagMatchers = make(models.Matchers, 0, len(existing)+n) - // Since must apply matchers will always be small (usually 1) - // it's better to not allocate intermediate datastructure and just - // perform n^2 matching. - for _, existingMatcher := range existing { - willBeOverridden := false - for _, mustApplyMatcher := range mustApplyMatchers { - if bytes.Equal(existingMatcher.Name, mustApplyMatcher.Name) { - willBeOverridden = true - break - } - } - - if willBeOverridden { - // We'll override this when we append the must apply matchers. - continue - } - - result.TagMatchers = append(result.TagMatchers, existingMatcher) - } - - // Now append the must apply matchers. - result.TagMatchers = append(result.TagMatchers, mustApplyMatchers...) - } - } - - return &result -} - -func (q *FetchQuery) String() string { - return q.Raw -} - // FetchOptions represents the options for fetch query. type FetchOptions struct { // Remote is set when this fetch is originated by a remote grpc call. @@ -240,8 +192,10 @@ func (o *FetchOptions) QueryFetchOptions( if r.RestrictFetchOptions == nil && queryCtx.Options.RestrictFetchType != nil { v := queryCtx.Options.RestrictFetchType restrict := RestrictFetchOptions{ - MetricsType: MetricsType(v.MetricsType), - StoragePolicy: v.StoragePolicy, + RestrictByType: &RestrictByType{ + MetricsType: MetricsType(v.MetricsType), + StoragePolicy: v.StoragePolicy, + }, } if err := restrict.Validate(); err != nil { return nil, err @@ -258,46 +212,36 @@ func (o *FetchOptions) Clone() *FetchOptions { return &result } -// RestrictFetchOptions restricts the fetch to a specific set of conditions. -type RestrictFetchOptions struct { +// RestrictByType are specific restrictions to stick to a single data type. +type RestrictByType struct { // MetricsType restricts the type of metrics being returned. MetricsType MetricsType // StoragePolicy is required if metrics type is not unaggregated // to specify which storage policy metrics should be returned from. StoragePolicy policy.StoragePolicy - // MustApplyMatchers is a set of override matchers to apply to a fetch +} + +// RestrictByTag are specific restrictions to enforce behavior for given +// tags. +type RestrictByTag struct { + // Restrict is a set of override matchers to apply to a fetch // regardless of the existing fetch matchers, they should replace any // existing matchers part of a fetch if they collide. - MustApplyMatchers []models.Matcher + Restrict models.Matchers `json:"restrict"` + // Strip is a set of tag names to strip from the response. + // + // NB: If this is unset, but Restrict is set, all tag names appearing in any + // of the Restrict matchers are removed. + Strip [][]byte `json:"strip"` } -// Validate will validate the restrict fetch options. -func (o RestrictFetchOptions) Validate() error { - switch o.MetricsType { - case UnaggregatedMetricsType: - if o.StoragePolicy != policy.EmptyStoragePolicy { - return fmt.Errorf( - "expected no storage policy for unaggregated metrics type, "+ - "instead got: %v", o.StoragePolicy.String()) - } - case AggregatedMetricsType: - if v := o.StoragePolicy.Resolution().Window; v <= 0 { - return fmt.Errorf( - "expected positive resolution window, instead got: %v", v) - } - if v := o.StoragePolicy.Resolution().Precision; v <= 0 { - return fmt.Errorf( - "expected positive resolution precision, instead got: %v", v) - } - if v := o.StoragePolicy.Retention().Duration(); v <= 0 { - return fmt.Errorf( - "expected positive retention, instead got: %v", v) - } - default: - return fmt.Errorf( - "unknown metrics type: %v", o.MetricsType) - } - return nil +// RestrictFetchOptions restricts the fetch to a specific set of conditions. +type RestrictFetchOptions struct { + // RestrictByType are specific restrictions to stick to a single data type. + RestrictByType *RestrictByType + // RestrictByTag are specific restrictions to enforce behavior for given + // tags. + RestrictByTag *RestrictByTag `json:"tags"` } // Querier handles queries against a storage. diff --git a/src/query/tsdb/remote/codecs.go b/src/query/tsdb/remote/codecs.go index e9fb66d374..c11df3e6ff 100644 --- a/src/query/tsdb/remote/codecs.go +++ b/src/query/tsdb/remote/codecs.go @@ -122,9 +122,12 @@ func encodeFetchRequest( } func encodeTagMatchers(modelMatchers models.Matchers) (*rpc.TagMatchers, error) { + if modelMatchers == nil { + return nil, nil + } + matchers := make([]*rpc.TagMatcher, len(modelMatchers)) for i, matcher := range modelMatchers { - fmt.Println("matcher", matcher) t, err := encodeMatcherTypeToProto(matcher.Type) if err != nil { return nil, err @@ -200,15 +203,14 @@ func encodeFetchOptions(options *storage.FetchOptions) (*rpc.FetchOptions, error return result, nil } -func encodeRestrictFetchOptions( - o *storage.RestrictFetchOptions, -) (*rpcpb.RestrictFetchOptions, error) { +func encodeRestrictFetchOptionsByType( + o *storage.RestrictByType, +) (*rpcpb.RestrictFetchType, error) { if err := o.Validate(); err != nil { return nil, err } - result := &rpcpb.RestrictFetchOptions{} - + result := &rpcpb.RestrictFetchType{} switch o.MetricsType { case storage.UnaggregatedMetricsType: result.MetricsType = rpcpb.MetricsType_UNAGGREGATED_METRICS_TYPE @@ -223,18 +225,44 @@ func encodeRestrictFetchOptions( result.MetricsStoragePolicy = storagePolicyProto } - if len(o.MustApplyMatchers) > 0 { - fmt.Println("Applhying matchers", o.MustApplyMatchers) - matchers, err := encodeTagMatchers(o.MustApplyMatchers) - if err != nil { - return nil, err - } - fmt.Println(" matchers", matchers) + return result, nil +} - result.MustApplyMatchers = matchers +func encodeRestrictFetchOptionsByTag( + o *storage.RestrictByTag, +) (*rpcpb.RestrictFetchTags, error) { + if o == nil { + return nil, nil } - return result, nil + matchers, err := encodeTagMatchers(o.GetMatchers()) + if err != nil { + return nil, err + } + + return &rpcpb.RestrictFetchTags{ + Restrict: matchers, + Strip: o.Strip, + }, nil +} + +func encodeRestrictFetchOptions( + o *storage.RestrictFetchOptions, +) (*rpcpb.RestrictFetchOptions, error) { + byType, err := encodeRestrictFetchOptionsByType(o.GetRestrictByType()) + if err != nil { + return nil, err + } + + byTags, err := encodeRestrictFetchOptionsByTag(o.GetRestrictByTag()) + if err != nil { + return nil, err + } + + return &rpcpb.RestrictFetchOptions{ + RestrictFetchType: byType, + RestrictFetchTags: byTags, + }, nil } func encodeMatcherTypeToProto(t models.MatchType) (rpc.MatcherType, error) { @@ -346,13 +374,12 @@ func decodeFanoutOption(opt rpc.FanoutOption) (storage.FanoutOption, error) { return 0, fmt.Errorf("unknown fanout option for proto encoding: %v", opt) } -func decodeRestrictFetchOptions( - p *rpc.RestrictFetchOptions, -) (storage.RestrictFetchOptions, error) { - var result storage.RestrictFetchOptions - +func decodeRestrictFetchOptionsByType( + p *rpc.RestrictFetchType, +) (*storage.RestrictByType, error) { + result := &storage.RestrictByType{} if p == nil { - return result, errors.New("no restrict fetch options proto message") + return result, errors.New("no restrict fetch options by type") } switch p.GetMetricsType() { @@ -372,22 +399,44 @@ func decodeRestrictFetchOptions( result.StoragePolicy = storagePolicy } - matchers := p.GetMustApplyMatchers() - if len(matchers.GetTagMatchers()) > 0 { - decodedMatchers, err := decodeTagMatchers(matchers) - if err != nil { - return result, err - } + return result, nil +} + +func decodeRestrictFetchOptionsByTag( + p *rpc.RestrictFetchTags, +) (*storage.RestrictByTag, error) { + if p == nil { + return nil, nil + } - result.MustApplyMatchers = decodedMatchers + matchers, err := decodeTagMatchers(p.GetRestrict()) + if err != nil { + return nil, err } - // Validate the resulting options. - if err := result.Validate(); err != nil { - return result, err + return &storage.RestrictByTag{ + Restrict: matchers, + Strip: p.Strip, + }, nil +} + +func decodeRestrictFetchOptions( + p *rpc.RestrictFetchOptions, +) (*storage.RestrictFetchOptions, error) { + byType, err := decodeRestrictFetchOptionsByType(p.GetRestrictFetchType()) + if err != nil { + return nil, err } - return result, nil + byTag, err := decodeRestrictFetchOptionsByTag(p.GetRestrictFetchTags()) + if err != nil { + return nil, err + } + + return &storage.RestrictFetchOptions{ + RestrictByType: byType, + RestrictByTag: byTag, + }, nil } func decodeFetchOptions(rpcFetchOptions *rpc.FetchOptions) (*storage.FetchOptions, error) { @@ -426,7 +475,7 @@ func decodeFetchOptions(rpcFetchOptions *rpc.FetchOptions) (*storage.FetchOption return nil, err } - result.RestrictFetchOptions = &restrict + result.RestrictFetchOptions = restrict } if v := rpcFetchOptions.LookbackDuration; v > 0 { diff --git a/src/query/tsdb/remote/codecs_test.go b/src/query/tsdb/remote/codecs_test.go index 2d467ef0c0..71fd459de0 100644 --- a/src/query/tsdb/remote/codecs_test.go +++ b/src/query/tsdb/remote/codecs_test.go @@ -133,8 +133,10 @@ func TestEncodeFetchMessage(t *testing.T) { fetchOpts := storage.NewFetchOptions() fetchOpts.Limit = 42 fetchOpts.RestrictFetchOptions = &storage.RestrictFetchOptions{ - MetricsType: storage.AggregatedMetricsType, - StoragePolicy: policy.MustParseStoragePolicy("1m:14d"), + RestrictByType: &storage.RestrictByType{ + MetricsType: storage.AggregatedMetricsType, + StoragePolicy: policy.MustParseStoragePolicy("1m:14d"), + }, } lookback := time.Minute fetchOpts.LookbackDuration = &lookback @@ -155,11 +157,15 @@ func TestEncodeFetchMessage(t *testing.T) { require.NotNil(t, grpcQ.Options) assert.Equal(t, int64(42), grpcQ.Options.Limit) require.NotNil(t, grpcQ.Options.Restrict) - assert.Equal(t, rpc.MetricsType_AGGREGATED_METRICS_TYPE, grpcQ.Options.Restrict.MetricsType) - require.NotNil(t, grpcQ.Options.Restrict.MetricsStoragePolicy) - expectedStoragePolicyProto, err := fetchOpts.RestrictFetchOptions.StoragePolicy.Proto() + require.NotNil(t, grpcQ.Options.Restrict.RestrictFetchType) + assert.Equal(t, rpc.MetricsType_AGGREGATED_METRICS_TYPE, + grpcQ.Options.Restrict.RestrictFetchType.MetricsType) + require.NotNil(t, grpcQ.Options.Restrict.RestrictFetchType.MetricsStoragePolicy) + expectedStoragePolicyProto, err := fetchOpts.RestrictFetchOptions. + RestrictByType.StoragePolicy.Proto() require.NoError(t, err) - assert.Equal(t, expectedStoragePolicyProto, grpcQ.Options.Restrict.MetricsStoragePolicy) + assert.Equal(t, expectedStoragePolicyProto, grpcQ.Options.Restrict. + RestrictFetchType.MetricsStoragePolicy) assert.Equal(t, lookback, time.Duration(grpcQ.Options.LookbackDuration)) } @@ -168,8 +174,10 @@ func TestEncodeDecodeFetchQuery(t *testing.T) { fetchOpts := storage.NewFetchOptions() fetchOpts.Limit = 42 fetchOpts.RestrictFetchOptions = &storage.RestrictFetchOptions{ - MetricsType: storage.AggregatedMetricsType, - StoragePolicy: policy.MustParseStoragePolicy("1m:14d"), + RestrictByType: &storage.RestrictByType{ + MetricsType: storage.AggregatedMetricsType, + StoragePolicy: policy.MustParseStoragePolicy("1m:14d"), + }, } lookback := time.Minute fetchOpts.LookbackDuration = &lookback @@ -183,10 +191,12 @@ func TestEncodeDecodeFetchQuery(t *testing.T) { require.NoError(t, err) require.NotNil(t, revertedOpts) require.Equal(t, fetchOpts.Limit, revertedOpts.Limit) - require.Equal(t, fetchOpts.RestrictFetchOptions.MetricsType, - revertedOpts.RestrictFetchOptions.MetricsType) - require.Equal(t, fetchOpts.RestrictFetchOptions.StoragePolicy.String(), - revertedOpts.RestrictFetchOptions.StoragePolicy.String()) + require.Equal(t, fetchOpts.RestrictFetchOptions. + RestrictByType.MetricsType, + revertedOpts.RestrictFetchOptions.RestrictByType.MetricsType) + require.Equal(t, fetchOpts.RestrictFetchOptions. + RestrictByType.StoragePolicy.String(), + revertedOpts.RestrictFetchOptions.RestrictByType.StoragePolicy.String()) require.NotNil(t, revertedOpts.LookbackDuration) require.Equal(t, lookback, *revertedOpts.LookbackDuration) @@ -230,43 +240,61 @@ func TestRetrieveMetadata(t *testing.T) { func TestNewRestrictFetchOptionsFromProto(t *testing.T) { tests := []struct { value *rpcpb.RestrictFetchOptions - expected storage.RestrictFetchOptions + expected *storage.RestrictFetchOptions errContains string }{ { value: &rpcpb.RestrictFetchOptions{ - MetricsType: rpcpb.MetricsType_UNAGGREGATED_METRICS_TYPE, + RestrictFetchType: &rpcpb.RestrictFetchType{ + MetricsType: rpcpb.MetricsType_UNAGGREGATED_METRICS_TYPE, + }, }, - expected: storage.RestrictFetchOptions{ - MetricsType: storage.UnaggregatedMetricsType, + expected: &storage.RestrictFetchOptions{ + RestrictByType: &storage.RestrictByType{ + MetricsType: storage.UnaggregatedMetricsType, + }, }, }, { value: &rpcpb.RestrictFetchOptions{ - MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, - MetricsStoragePolicy: &policypb.StoragePolicy{ - Resolution: &policypb.Resolution{ - WindowSize: int64(time.Minute), - Precision: int64(time.Second), - }, - Retention: &policypb.Retention{ - Period: int64(24 * time.Hour), + RestrictFetchType: &rpcpb.RestrictFetchType{ + MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, + MetricsStoragePolicy: &policypb.StoragePolicy{ + Resolution: &policypb.Resolution{ + WindowSize: int64(time.Minute), + Precision: int64(time.Second), + }, + Retention: &policypb.Retention{ + Period: int64(24 * time.Hour), + }, }, }, - MustApplyMatchers: &rpc.TagMatchers{ - TagMatchers: []*rpc.TagMatcher{ - newRPCMatcher(rpc.MatcherType_NOTREGEXP, "foo", "bar"), - newRPCMatcher(rpc.MatcherType_EQUAL, "baz", "qux"), + RestrictFetchTags: &rpc.RestrictFetchTags{ + Restrict: &rpc.TagMatchers{ + TagMatchers: []*rpc.TagMatcher{ + newRPCMatcher(rpc.MatcherType_NOTREGEXP, "foo", "bar"), + newRPCMatcher(rpc.MatcherType_EQUAL, "baz", "qux"), + }, + }, + Strip: [][]byte{ + []byte("foobar"), }, }, }, - expected: storage.RestrictFetchOptions{ - MetricsType: storage.AggregatedMetricsType, - StoragePolicy: policy.NewStoragePolicy(time.Minute, - xtime.Second, 24*time.Hour), - MustApplyMatchers: []models.Matcher{ - mustNewMatcher(models.MatchNotRegexp, "foo", "bar"), - mustNewMatcher(models.MatchEqual, "baz", "qux"), + expected: &storage.RestrictFetchOptions{ + RestrictByType: &storage.RestrictByType{ + MetricsType: storage.AggregatedMetricsType, + StoragePolicy: policy.NewStoragePolicy(time.Minute, + xtime.Second, 24*time.Hour), + }, + RestrictByTag: &storage.RestrictByTag{ + Restrict: []models.Matcher{ + mustNewMatcher(models.MatchNotRegexp, "foo", "bar"), + mustNewMatcher(models.MatchEqual, "baz", "qux"), + }, + Strip: [][]byte{ + []byte("foobar"), + }, }, }, }, @@ -276,20 +304,24 @@ func TestNewRestrictFetchOptionsFromProto(t *testing.T) { }, { value: &rpcpb.RestrictFetchOptions{ - MetricsType: rpcpb.MetricsType_UNKNOWN_METRICS_TYPE, + RestrictFetchType: &rpcpb.RestrictFetchType{ + MetricsType: rpcpb.MetricsType_UNKNOWN_METRICS_TYPE, + }, }, errContains: "unknown metrics type:", }, { value: &rpcpb.RestrictFetchOptions{ - MetricsType: rpcpb.MetricsType_UNAGGREGATED_METRICS_TYPE, - MetricsStoragePolicy: &policypb.StoragePolicy{ - Resolution: &policypb.Resolution{ - WindowSize: int64(time.Minute), - Precision: int64(time.Second), - }, - Retention: &policypb.Retention{ - Period: int64(24 * time.Hour), + RestrictFetchType: &rpcpb.RestrictFetchType{ + MetricsType: rpcpb.MetricsType_UNAGGREGATED_METRICS_TYPE, + MetricsStoragePolicy: &policypb.StoragePolicy{ + Resolution: &policypb.Resolution{ + WindowSize: int64(time.Minute), + Precision: int64(time.Second), + }, + Retention: &policypb.Retention{ + Period: int64(24 * time.Hour), + }, }, }, }, @@ -297,10 +329,12 @@ func TestNewRestrictFetchOptionsFromProto(t *testing.T) { }, { value: &rpcpb.RestrictFetchOptions{ - MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, - MetricsStoragePolicy: &policypb.StoragePolicy{ - Resolution: &policypb.Resolution{ - WindowSize: -1, + RestrictFetchType: &rpcpb.RestrictFetchType{ + MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, + MetricsStoragePolicy: &policypb.StoragePolicy{ + Resolution: &policypb.Resolution{ + WindowSize: -1, + }, }, }, }, @@ -308,11 +342,13 @@ func TestNewRestrictFetchOptionsFromProto(t *testing.T) { }, { value: &rpcpb.RestrictFetchOptions{ - MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, - MetricsStoragePolicy: &policypb.StoragePolicy{ - Resolution: &policypb.Resolution{ - WindowSize: int64(time.Minute), - Precision: int64(-1), + RestrictFetchType: &rpcpb.RestrictFetchType{ + MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, + MetricsStoragePolicy: &policypb.StoragePolicy{ + Resolution: &policypb.Resolution{ + WindowSize: int64(time.Minute), + Precision: int64(-1), + }, }, }, }, @@ -320,14 +356,16 @@ func TestNewRestrictFetchOptionsFromProto(t *testing.T) { }, { value: &rpcpb.RestrictFetchOptions{ - MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, - MetricsStoragePolicy: &policypb.StoragePolicy{ - Resolution: &policypb.Resolution{ - WindowSize: int64(time.Minute), - Precision: int64(time.Second), - }, - Retention: &policypb.Retention{ - Period: int64(-1), + RestrictFetchType: &rpcpb.RestrictFetchType{ + MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, + MetricsStoragePolicy: &policypb.StoragePolicy{ + Resolution: &policypb.Resolution{ + WindowSize: int64(time.Minute), + Precision: int64(time.Second), + }, + Retention: &policypb.Retention{ + Period: int64(-1), + }, }, }, }, @@ -335,19 +373,19 @@ func TestNewRestrictFetchOptionsFromProto(t *testing.T) { }, } for _, test := range tests { - t.Run(fmt.Sprintf("%s", test.value), func(t *testing.T) { - result, err := decodeRestrictFetchOptions(test.value) - if test.errContains == "" { - require.NoError(t, err) - assert.Equal(t, test.expected, result) - return - } + // t.Run(fmt.Sprintf("%s", test.value), func(t *testing.T) { + result, err := decodeRestrictFetchOptions(test.value) + if test.errContains == "" { + require.NoError(t, err) + assert.Equal(t, test.expected, result) + return + } - require.Error(t, err) - assert.True(t, - strings.Contains(err.Error(), test.errContains), - fmt.Sprintf("err=%v, want_contains=%v", err.Error(), test.errContains)) - }) + require.Error(t, err) + assert.True(t, + strings.Contains(err.Error(), test.errContains), + fmt.Sprintf("err=%v, want_contains=%v", err.Error(), test.errContains)) + // }) } } @@ -372,66 +410,90 @@ func TestRestrictFetchOptionsProto(t *testing.T) { }{ { value: storage.RestrictFetchOptions{ - MetricsType: storage.UnaggregatedMetricsType, - MustApplyMatchers: []models.Matcher{ - mustNewMatcher(models.MatchNotRegexp, "foo", "bar"), + RestrictByType: &storage.RestrictByType{ + MetricsType: storage.UnaggregatedMetricsType, + }, + RestrictByTag: &storage.RestrictByTag{ + Restrict: []models.Matcher{ + mustNewMatcher(models.MatchNotRegexp, "foo", "bar"), + }, + Strip: [][]byte{[]byte("foobar")}, }, }, expected: &rpcpb.RestrictFetchOptions{ - MetricsType: rpcpb.MetricsType_UNAGGREGATED_METRICS_TYPE, - MustApplyMatchers: &rpc.TagMatchers{ - TagMatchers: []*rpc.TagMatcher{ - newRPCMatcher(rpc.MatcherType_NOTREGEXP, "foo", "bar"), + RestrictFetchType: &rpcpb.RestrictFetchType{ + MetricsType: rpcpb.MetricsType_UNAGGREGATED_METRICS_TYPE, + }, + RestrictFetchTags: &rpcpb.RestrictFetchTags{ + Restrict: &rpc.TagMatchers{ + TagMatchers: []*rpc.TagMatcher{ + newRPCMatcher(rpc.MatcherType_NOTREGEXP, "foo", "bar"), + }, }, + Strip: [][]byte{[]byte("foobar")}, }, }, }, { value: storage.RestrictFetchOptions{ - MetricsType: storage.AggregatedMetricsType, - StoragePolicy: policy.NewStoragePolicy(time.Minute, - xtime.Second, 24*time.Hour), - MustApplyMatchers: []models.Matcher{ - mustNewMatcher(models.MatchNotRegexp, "foo", "bar"), - mustNewMatcher(models.MatchEqual, "baz", "qux"), + RestrictByType: &storage.RestrictByType{ + MetricsType: storage.AggregatedMetricsType, + StoragePolicy: policy.NewStoragePolicy(time.Minute, + xtime.Second, 24*time.Hour), + }, + RestrictByTag: &storage.RestrictByTag{ + Restrict: models.Matchers{ + mustNewMatcher(models.MatchNotRegexp, "foo", "bar"), + mustNewMatcher(models.MatchEqual, "baz", "qux"), + }, + Strip: [][]byte{[]byte("foobar")}, }, }, expected: &rpcpb.RestrictFetchOptions{ - MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, - MetricsStoragePolicy: &policypb.StoragePolicy{ - Resolution: &policypb.Resolution{ - WindowSize: int64(time.Minute), - Precision: int64(time.Second), - }, - Retention: &policypb.Retention{ - Period: int64(24 * time.Hour), + RestrictFetchType: &rpcpb.RestrictFetchType{ + MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, + MetricsStoragePolicy: &policypb.StoragePolicy{ + Resolution: &policypb.Resolution{ + WindowSize: int64(time.Minute), + Precision: int64(time.Second), + }, + Retention: &policypb.Retention{ + Period: int64(24 * time.Hour), + }, }, }, - MustApplyMatchers: &rpc.TagMatchers{ - TagMatchers: []*rpc.TagMatcher{ - newRPCMatcher(rpc.MatcherType_NOTREGEXP, "foo", "bar"), - newRPCMatcher(rpc.MatcherType_EQUAL, "baz", "qux"), + RestrictFetchTags: &rpcpb.RestrictFetchTags{ + Restrict: &rpc.TagMatchers{ + TagMatchers: []*rpc.TagMatcher{ + newRPCMatcher(rpc.MatcherType_NOTREGEXP, "foo", "bar"), + newRPCMatcher(rpc.MatcherType_EQUAL, "baz", "qux"), + }, }, + Strip: [][]byte{[]byte("foobar")}, }, }, }, { value: storage.RestrictFetchOptions{ - MetricsType: storage.MetricsType(uint(math.MaxUint16)), + RestrictByType: &storage.RestrictByType{ + MetricsType: storage.MetricsType(uint(math.MaxUint16)), + }, }, errContains: "unknown metrics type:", }, { value: storage.RestrictFetchOptions{ - MetricsType: storage.UnaggregatedMetricsType, - StoragePolicy: policy.NewStoragePolicy(time.Minute, - xtime.Second, 24*time.Hour), + RestrictByType: &storage.RestrictByType{ + MetricsType: storage.UnaggregatedMetricsType, + StoragePolicy: policy.NewStoragePolicy(time.Minute, + xtime.Second, 24*time.Hour), + }, }, errContains: "expected no storage policy for unaggregated metrics", }, } for _, test := range tests { - t.Run(fmt.Sprintf("%s", test.value), func(t *testing.T) { + t.Run(fmt.Sprintf("%+v", test.value), func(t *testing.T) { result, err := encodeRestrictFetchOptions(&test.value) if test.errContains == "" { require.NoError(t, err) From fd66d0a515624e89e520accbf5b7b21cbb9351ee Mon Sep 17 00:00:00 2001 From: Artem Date: Mon, 2 Dec 2019 08:41:05 -0500 Subject: [PATCH 4/7] Rename --- src/query/api/v1/handler/fetch_options.go | 38 ++++----- .../api/v1/handler/fetch_options_test.go | 12 +-- src/query/api/v1/handler/headers.go | 7 +- src/query/api/v1/handler/prometheus/common.go | 2 +- .../api/v1/handler/prometheus/native/read.go | 2 +- .../prometheus/native/read_instantaneous.go | 2 +- src/query/functions/fetch_test.go | 2 +- src/query/generated/proto/rpcpb/query.pb.go | 36 ++++---- src/query/generated/proto/rpcpb/query.proto | 8 +- src/query/storage/fanout/storage.go | 4 +- src/query/storage/m3/cluster_resolver.go | 10 +-- src/query/storage/m3/cluster_resolver_test.go | 12 +-- src/query/storage/m3/storage.go | 2 +- src/query/storage/restrict_fetch_options.go | 8 +- .../storage/restrict_fetch_options_test.go | 4 +- src/query/storage/types.go | 29 ++++--- src/query/tsdb/remote/codecs.go | 49 ++++++----- src/query/tsdb/remote/codecs_test.go | 84 +++++++++---------- 18 files changed, 162 insertions(+), 149 deletions(-) diff --git a/src/query/api/v1/handler/fetch_options.go b/src/query/api/v1/handler/fetch_options.go index ce7bddaef1..9e87e3a7cd 100644 --- a/src/query/api/v1/handler/fetch_options.go +++ b/src/query/api/v1/handler/fetch_options.go @@ -114,10 +114,10 @@ func (b fetchOptionsBuilder) NewFetchOptions( return nil, xhttp.NewParseError(err, http.StatusBadRequest) } - fetchOpts.RestrictFetchOptions = newOrExistingRestrictFetchOptions(fetchOpts) - fetchOpts.RestrictFetchOptions.RestrictByType = - newOrExistingRestrictFetchOptionsRestrictByType(fetchOpts) - fetchOpts.RestrictFetchOptions.RestrictByType.MetricsType = mt + fetchOpts.RestrictQueryOptions = newOrExistingRestrictQueryOptions(fetchOpts) + fetchOpts.RestrictQueryOptions.RestrictByType = + newOrExistingRestrictQueryOptionsRestrictByType(fetchOpts) + fetchOpts.RestrictQueryOptions.RestrictByType.MetricsType = mt } if str := req.Header.Get(MetricsStoragePolicyHeader); str != "" { @@ -128,23 +128,23 @@ func (b fetchOptionsBuilder) NewFetchOptions( return nil, xhttp.NewParseError(err, http.StatusBadRequest) } - fetchOpts.RestrictFetchOptions = newOrExistingRestrictFetchOptions(fetchOpts) - fetchOpts.RestrictFetchOptions.RestrictByType = - newOrExistingRestrictFetchOptionsRestrictByType(fetchOpts) - fetchOpts.RestrictFetchOptions.RestrictByType.StoragePolicy = sp + fetchOpts.RestrictQueryOptions = newOrExistingRestrictQueryOptions(fetchOpts) + fetchOpts.RestrictQueryOptions.RestrictByType = + newOrExistingRestrictQueryOptionsRestrictByType(fetchOpts) + fetchOpts.RestrictQueryOptions.RestrictByType.StoragePolicy = sp } - if str := req.Header.Get(FetchRestrictLabels); str != "" { - var opts *storage.RestrictFetchOptions + if str := req.Header.Get(QueryOptionsJSONHeader); str != "" { + var opts *storage.RestrictQueryOptions if err := json.Unmarshal([]byte(str), opts); err != nil { return nil, xhttp.NewParseError(err, http.StatusBadRequest) } - fetchOpts.RestrictFetchOptions = newOrExistingRestrictFetchOptions(fetchOpts) - fetchOpts.RestrictFetchOptions.RestrictByTag = opts.RestrictByTag + fetchOpts.RestrictQueryOptions = newOrExistingRestrictQueryOptions(fetchOpts) + fetchOpts.RestrictQueryOptions.RestrictByTag = opts.RestrictByTag } - if restrict := fetchOpts.RestrictFetchOptions; restrict != nil { + if restrict := fetchOpts.RestrictQueryOptions; restrict != nil { if err := restrict.Validate(); err != nil { err = fmt.Errorf( "could not validate restrict options: err=%v", err) @@ -172,19 +172,19 @@ func (b fetchOptionsBuilder) NewFetchOptions( return fetchOpts, nil } -func newOrExistingRestrictFetchOptions( +func newOrExistingRestrictQueryOptions( fetchOpts *storage.FetchOptions, -) *storage.RestrictFetchOptions { - if v := fetchOpts.RestrictFetchOptions; v != nil { +) *storage.RestrictQueryOptions { + if v := fetchOpts.RestrictQueryOptions; v != nil { return v } - return &storage.RestrictFetchOptions{} + return &storage.RestrictQueryOptions{} } -func newOrExistingRestrictFetchOptionsRestrictByType( +func newOrExistingRestrictQueryOptionsRestrictByType( fetchOpts *storage.FetchOptions, ) *storage.RestrictByType { - if v := fetchOpts.RestrictFetchOptions.RestrictByType; v != nil { + if v := fetchOpts.RestrictQueryOptions.RestrictByType; v != nil { return v } return &storage.RestrictByType{} diff --git a/src/query/api/v1/handler/fetch_options_test.go b/src/query/api/v1/handler/fetch_options_test.go index 13b3e87a02..7875cf5986 100644 --- a/src/query/api/v1/handler/fetch_options_test.go +++ b/src/query/api/v1/handler/fetch_options_test.go @@ -47,7 +47,7 @@ func TestFetchOptionsBuilder(t *testing.T) { headers map[string]string query string expectedLimit int - expectedRestrict *storage.RestrictFetchOptions + expectedRestrict *storage.RestrictQueryOptions expectedLookback *expectedLookback expectedErr bool }{ @@ -78,7 +78,7 @@ func TestFetchOptionsBuilder(t *testing.T) { headers: map[string]string{ MetricsTypeHeader: storage.UnaggregatedMetricsType.String(), }, - expectedRestrict: &storage.RestrictFetchOptions{ + expectedRestrict: &storage.RestrictQueryOptions{ RestrictByType: &storage.RestrictByType{ MetricsType: storage.UnaggregatedMetricsType, }, @@ -90,7 +90,7 @@ func TestFetchOptionsBuilder(t *testing.T) { MetricsTypeHeader: storage.AggregatedMetricsType.String(), MetricsStoragePolicyHeader: "1m:14d", }, - expectedRestrict: &storage.RestrictFetchOptions{ + expectedRestrict: &storage.RestrictQueryOptions{ RestrictByType: &storage.RestrictByType{ MetricsType: storage.AggregatedMetricsType, StoragePolicy: policy.MustParseStoragePolicy("1m:14d"), @@ -171,10 +171,10 @@ func TestFetchOptionsBuilder(t *testing.T) { require.NoError(t, err) require.Equal(t, test.expectedLimit, opts.Limit) if test.expectedRestrict == nil { - require.Nil(t, opts.RestrictFetchOptions) + require.Nil(t, opts.RestrictQueryOptions) } else { - require.NotNil(t, opts.RestrictFetchOptions) - require.Equal(t, *test.expectedRestrict, *opts.RestrictFetchOptions) + require.NotNil(t, opts.RestrictQueryOptions) + require.Equal(t, *test.expectedRestrict, *opts.RestrictQueryOptions) } if test.expectedLookback == nil { require.Nil(t, opts.LookbackDuration) diff --git a/src/query/api/v1/handler/headers.go b/src/query/api/v1/handler/headers.go index f6d27e49f7..eff037e6e0 100644 --- a/src/query/api/v1/handler/headers.go +++ b/src/query/api/v1/handler/headers.go @@ -56,11 +56,8 @@ const ( // metrics type. MetricsStoragePolicyHeader = "M3-Storage-Policy" - // FetchRestrictLabels restricts all fetches to match certain labels. - FetchRestrictLabels = "M3-Fetch-Restrict-Labels" - - // FetchStripLabels strips certain labels from the result. - FetchStripLabels = "M3-Fetch-Strip-Labels" + // QueryOptionsJSONHeader provides tag options to enforces on queries. + QueryOptionsJSONHeader = "M3-Restrict-By-Tags-JSON" // UnaggregatedStoragePolicy specifies the unaggregated storage policy. UnaggregatedStoragePolicy = "unaggregated" diff --git a/src/query/api/v1/handler/prometheus/common.go b/src/query/api/v1/handler/prometheus/common.go index a2d39fe2ba..b1828d7acb 100644 --- a/src/query/api/v1/handler/prometheus/common.go +++ b/src/query/api/v1/handler/prometheus/common.go @@ -643,7 +643,7 @@ func FilterSeriesByOptions( return series } - keys := opts.RestrictFetchOptions.GetRestrictByTag().GetFilterByNames() + keys := opts.RestrictQueryOptions.GetRestrictByTag().GetFilterByNames() if len(keys) > 0 { for i, s := range series { series[i].Tags = s.Tags.TagsWithoutKeys(keys) diff --git a/src/query/api/v1/handler/prometheus/native/read.go b/src/query/api/v1/handler/prometheus/native/read.go index 627dce52b0..29ab140373 100644 --- a/src/query/api/v1/handler/prometheus/native/read.go +++ b/src/query/api/v1/handler/prometheus/native/read.go @@ -147,7 +147,7 @@ func (h *PromReadHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { LimitMaxTimeseries: fetchOpts.Limit, }} - restrictOpts := fetchOpts.RestrictFetchOptions.GetRestrictByType() + restrictOpts := fetchOpts.RestrictQueryOptions.GetRestrictByType() if restrictOpts != nil { restrict := &models.RestrictFetchTypeQueryContextOptions{ MetricsType: uint(restrictOpts.MetricsType), diff --git a/src/query/api/v1/handler/prometheus/native/read_instantaneous.go b/src/query/api/v1/handler/prometheus/native/read_instantaneous.go index 574223ec4a..154b249256 100644 --- a/src/query/api/v1/handler/prometheus/native/read_instantaneous.go +++ b/src/query/api/v1/handler/prometheus/native/read_instantaneous.go @@ -97,7 +97,7 @@ func (h *PromReadInstantHandler) ServeHTTP(w http.ResponseWriter, r *http.Reques LimitMaxTimeseries: fetchOpts.Limit, }} - restrictOpts := fetchOpts.RestrictFetchOptions.GetRestrictByType() + restrictOpts := fetchOpts.RestrictQueryOptions.GetRestrictByType() if restrictOpts != nil { restrict := &models.RestrictFetchTypeQueryContextOptions{ MetricsType: uint(restrictOpts.MetricsType), diff --git a/src/query/functions/fetch_test.go b/src/query/functions/fetch_test.go index 09230a17da..e7783aa74d 100644 --- a/src/query/functions/fetch_test.go +++ b/src/query/functions/fetch_test.go @@ -146,7 +146,7 @@ func TestFetchWithRestrictFetch(t *testing.T) { assert.Equal(t, expected, sink.Values) fetchOpts := mockStorage.LastFetchOptions() - restrictByType := fetchOpts.RestrictFetchOptions.GetRestrictByType() + restrictByType := fetchOpts.RestrictQueryOptions.GetRestrictByType() require.NotNil(t, restrictByType) assert.Equal(t, storage.AggregatedMetricsType, storage.MetricsType(restrictByType.MetricsType)) assert.Equal(t, "10s:42d", restrictByType.StoragePolicy.String()) diff --git a/src/query/generated/proto/rpcpb/query.pb.go b/src/query/generated/proto/rpcpb/query.pb.go index 10924c7842..89f2e498aa 100644 --- a/src/query/generated/proto/rpcpb/query.pb.go +++ b/src/query/generated/proto/rpcpb/query.pb.go @@ -34,7 +34,7 @@ TagMatchers TagMatcher FetchOptions - RestrictFetchOptions + RestrictQueryOptions RestrictFetchType RestrictFetchTags FetchResponse @@ -396,7 +396,7 @@ func (m *TagMatcher) GetType() MatcherType { type FetchOptions struct { Limit int64 `protobuf:"varint,1,opt,name=limit,proto3" json:"limit,omitempty"` - Restrict *RestrictFetchOptions `protobuf:"bytes,2,opt,name=restrict" json:"restrict,omitempty"` + Restrict *RestrictQueryOptions `protobuf:"bytes,2,opt,name=restrict" json:"restrict,omitempty"` LookbackDuration int64 `protobuf:"varint,3,opt,name=lookbackDuration,proto3" json:"lookbackDuration,omitempty"` Unaggregated FanoutOption `protobuf:"varint,4,opt,name=unaggregated,proto3,enum=rpc.FanoutOption" json:"unaggregated,omitempty"` Aggregated FanoutOption `protobuf:"varint,5,opt,name=aggregated,proto3,enum=rpc.FanoutOption" json:"aggregated,omitempty"` @@ -416,7 +416,7 @@ func (m *FetchOptions) GetLimit() int64 { return 0 } -func (m *FetchOptions) GetRestrict() *RestrictFetchOptions { +func (m *FetchOptions) GetRestrict() *RestrictQueryOptions { if m != nil { return m.Restrict } @@ -458,24 +458,24 @@ func (m *FetchOptions) GetIncludeResolution() bool { return false } -type RestrictFetchOptions struct { +type RestrictQueryOptions struct { RestrictFetchType *RestrictFetchType `protobuf:"bytes,1,opt,name=RestrictFetchType" json:"RestrictFetchType,omitempty"` RestrictFetchTags *RestrictFetchTags `protobuf:"bytes,2,opt,name=RestrictFetchTags" json:"RestrictFetchTags,omitempty"` } -func (m *RestrictFetchOptions) Reset() { *m = RestrictFetchOptions{} } -func (m *RestrictFetchOptions) String() string { return proto.CompactTextString(m) } -func (*RestrictFetchOptions) ProtoMessage() {} -func (*RestrictFetchOptions) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{6} } +func (m *RestrictQueryOptions) Reset() { *m = RestrictQueryOptions{} } +func (m *RestrictQueryOptions) String() string { return proto.CompactTextString(m) } +func (*RestrictQueryOptions) ProtoMessage() {} +func (*RestrictQueryOptions) Descriptor() ([]byte, []int) { return fileDescriptorQuery, []int{6} } -func (m *RestrictFetchOptions) GetRestrictFetchType() *RestrictFetchType { +func (m *RestrictQueryOptions) GetRestrictFetchType() *RestrictFetchType { if m != nil { return m.RestrictFetchType } return nil } -func (m *RestrictFetchOptions) GetRestrictFetchTags() *RestrictFetchTags { +func (m *RestrictQueryOptions) GetRestrictFetchTags() *RestrictFetchTags { if m != nil { return m.RestrictFetchTags } @@ -1618,7 +1618,7 @@ func init() { proto.RegisterType((*TagMatchers)(nil), "rpc.TagMatchers") proto.RegisterType((*TagMatcher)(nil), "rpc.TagMatcher") proto.RegisterType((*FetchOptions)(nil), "rpc.FetchOptions") - proto.RegisterType((*RestrictFetchOptions)(nil), "rpc.RestrictFetchOptions") + proto.RegisterType((*RestrictQueryOptions)(nil), "rpc.RestrictQueryOptions") proto.RegisterType((*RestrictFetchType)(nil), "rpc.RestrictFetchType") proto.RegisterType((*RestrictFetchTags)(nil), "rpc.RestrictFetchTags") proto.RegisterType((*FetchResponse)(nil), "rpc.FetchResponse") @@ -2138,7 +2138,7 @@ func (m *FetchOptions) MarshalTo(dAtA []byte) (int, error) { return i, nil } -func (m *RestrictFetchOptions) Marshal() (dAtA []byte, err error) { +func (m *RestrictQueryOptions) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalTo(dAtA) @@ -2148,7 +2148,7 @@ func (m *RestrictFetchOptions) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *RestrictFetchOptions) MarshalTo(dAtA []byte) (int, error) { +func (m *RestrictQueryOptions) MarshalTo(dAtA []byte) (int, error) { var i int _ = i var l int @@ -3323,7 +3323,7 @@ func (m *FetchOptions) Size() (n int) { return n } -func (m *RestrictFetchOptions) Size() (n int) { +func (m *RestrictQueryOptions) Size() (n int) { var l int _ = l if m.RestrictFetchType != nil { @@ -4403,7 +4403,7 @@ func (m *FetchOptions) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Restrict == nil { - m.Restrict = &RestrictFetchOptions{} + m.Restrict = &RestrictQueryOptions{} } if err := m.Restrict.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -4526,7 +4526,7 @@ func (m *FetchOptions) Unmarshal(dAtA []byte) error { } return nil } -func (m *RestrictFetchOptions) Unmarshal(dAtA []byte) error { +func (m *RestrictQueryOptions) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4549,10 +4549,10 @@ func (m *RestrictFetchOptions) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: RestrictFetchOptions: wiretype end group for non-group") + return fmt.Errorf("proto: RestrictQueryOptions: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: RestrictFetchOptions: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: RestrictQueryOptions: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: diff --git a/src/query/generated/proto/rpcpb/query.proto b/src/query/generated/proto/rpcpb/query.proto index 7fcd180e4d..a50a243762 100644 --- a/src/query/generated/proto/rpcpb/query.proto +++ b/src/query/generated/proto/rpcpb/query.proto @@ -56,7 +56,7 @@ enum MatcherType { message FetchOptions { int64 limit = 1; - RestrictFetchOptions restrict = 2; + RestrictQueryOptions restrict = 2; int64 lookbackDuration = 3; FanoutOption unaggregated = 4; FanoutOption aggregated = 5; @@ -64,9 +64,9 @@ message FetchOptions { bool includeResolution = 7; } -message RestrictFetchOptions { - RestrictFetchType RestrictFetchType = 1; - RestrictFetchTags RestrictFetchTags = 2; +message RestrictQueryOptions { + RestrictFetchType RestrictFetchType = 3; + RestrictFetchTags RestrictFetchTags = 4; } message RestrictFetchType { diff --git a/src/query/storage/fanout/storage.go b/src/query/storage/fanout/storage.go index 4fd988e6ef..b603b0b38c 100644 --- a/src/query/storage/fanout/storage.go +++ b/src/query/storage/fanout/storage.go @@ -341,11 +341,11 @@ func applyOptions( result storage.CompleteTagsResult, opts *storage.FetchOptions, ) storage.CompleteTagsResult { - if opts.RestrictFetchOptions == nil { + if opts.RestrictQueryOptions == nil { return result } - filter := opts.RestrictFetchOptions.GetRestrictByTag().GetFilterByNames() + filter := opts.RestrictQueryOptions.GetRestrictByTag().GetFilterByNames() if len(filter) > 0 { // Filter out unwanted tags inplace. filteredList := result.CompletedTags[:0] diff --git a/src/query/storage/m3/cluster_resolver.go b/src/query/storage/m3/cluster_resolver.go index b8ecf5cbf7..a38d1f66f3 100644 --- a/src/query/storage/m3/cluster_resolver.go +++ b/src/query/storage/m3/cluster_resolver.go @@ -77,11 +77,11 @@ func resolveClusterNamespacesForQuery( now, start, end time.Time, clusters Clusters, opts *storage.FanoutOptions, - restrict *storage.RestrictFetchOptions, + restrict *storage.RestrictQueryOptions, ) (queryFanoutType, ClusterNamespaces, error) { if restrict != nil { // If a specific restriction is set, then attempt to satisfy. - return resolveClusterNamespacesForQueryWithRestrictFetchOptions(now, + return resolveClusterNamespacesForQueryWithRestrictQueryOptions(now, start, clusters, restrict) } @@ -296,13 +296,13 @@ func aggregatedNamespaces( return slices } -// resolveClusterNamespacesForQueryWithRestrictFetchOptions returns the cluster +// resolveClusterNamespacesForQueryWithRestrictQueryOptions returns the cluster // namespace referred to by the restrict fetch options or an error if it // cannot be found. -func resolveClusterNamespacesForQueryWithRestrictFetchOptions( +func resolveClusterNamespacesForQueryWithRestrictQueryOptions( now, start time.Time, clusters Clusters, - fetchOptions *storage.RestrictFetchOptions, + fetchOptions *storage.RestrictQueryOptions, ) (queryFanoutType, ClusterNamespaces, error) { coversRangeFilter := newCoversRangeFilter(coversRangeFilterOptions{ now: now, diff --git a/src/query/storage/m3/cluster_resolver_test.go b/src/query/storage/m3/cluster_resolver_test.go index 6bd19a861c..c0fa180971 100644 --- a/src/query/storage/m3/cluster_resolver_test.go +++ b/src/query/storage/m3/cluster_resolver_test.go @@ -163,7 +163,7 @@ var testCases = []struct { name string queryLength time.Duration opts *storage.FanoutOptions - restrict *storage.RestrictFetchOptions + restrict *storage.RestrictQueryOptions expectedType queryFanoutType expectedClusterNames []string expectedErr error @@ -311,7 +311,7 @@ var testCases = []struct { { name: "restrict to unaggregated", queryLength: time.Hour * 1000, - restrict: &storage.RestrictFetchOptions{ + restrict: &storage.RestrictQueryOptions{ RestrictByType: &storage.RestrictByType{ MetricsType: storage.UnaggregatedMetricsType, }, @@ -322,7 +322,7 @@ var testCases = []struct { { name: "restrict to aggregate filtered", queryLength: time.Hour * 1000, - restrict: &storage.RestrictFetchOptions{ + restrict: &storage.RestrictQueryOptions{ RestrictByType: &storage.RestrictByType{ MetricsType: storage.AggregatedMetricsType, StoragePolicy: policy.MustParseStoragePolicy( @@ -335,7 +335,7 @@ var testCases = []struct { { name: "restrict to aggregate unfiltered", queryLength: time.Hour * 1000, - restrict: &storage.RestrictFetchOptions{ + restrict: &storage.RestrictQueryOptions{ RestrictByType: &storage.RestrictByType{ MetricsType: storage.AggregatedMetricsType, StoragePolicy: policy.MustParseStoragePolicy( @@ -348,7 +348,7 @@ var testCases = []struct { { name: "restrict with unknown metrics type", queryLength: time.Hour * 1000, - restrict: &storage.RestrictFetchOptions{ + restrict: &storage.RestrictQueryOptions{ RestrictByType: &storage.RestrictByType{ MetricsType: storage.UnknownMetricsType, }, @@ -358,7 +358,7 @@ var testCases = []struct { { name: "restrict with unknown storage policy", queryLength: time.Hour * 1000, - restrict: &storage.RestrictFetchOptions{ + restrict: &storage.RestrictQueryOptions{ RestrictByType: &storage.RestrictByType{ MetricsType: storage.AggregatedMetricsType, StoragePolicy: policy.MustParseStoragePolicy("1s:100d"), diff --git a/src/query/storage/m3/storage.go b/src/query/storage/m3/storage.go index 999ad4992e..165c126cb3 100644 --- a/src/query/storage/m3/storage.go +++ b/src/query/storage/m3/storage.go @@ -301,7 +301,7 @@ func (s *m3storage) fetchCompressed( query.End, s.clusters, options.FanoutOptions, - options.RestrictFetchOptions, + options.RestrictQueryOptions, ) if err != nil { return nil, err diff --git a/src/query/storage/restrict_fetch_options.go b/src/query/storage/restrict_fetch_options.go index 17d1afab06..19aa847fa7 100644 --- a/src/query/storage/restrict_fetch_options.go +++ b/src/query/storage/restrict_fetch_options.go @@ -29,7 +29,7 @@ import ( ) // Validate will validate the restrict fetch options. -func (o *RestrictFetchOptions) Validate() error { +func (o *RestrictQueryOptions) Validate() error { if o.RestrictByType != nil { return o.RestrictByType.Validate() } @@ -38,7 +38,7 @@ func (o *RestrictFetchOptions) Validate() error { } // GetRestrictByType provides the type restrictions if present; nil otherwise. -func (o *RestrictFetchOptions) GetRestrictByType() *RestrictByType { +func (o *RestrictQueryOptions) GetRestrictByType() *RestrictByType { if o == nil { return nil } @@ -47,7 +47,7 @@ func (o *RestrictFetchOptions) GetRestrictByType() *RestrictByType { } // GetRestrictByTag provides the tag restrictions if present; nil otherwise. -func (o *RestrictFetchOptions) GetRestrictByTag() *RestrictByTag { +func (o *RestrictQueryOptions) GetRestrictByTag() *RestrictByTag { if o == nil { return nil } @@ -122,7 +122,7 @@ func (q *FetchQuery) WithAppliedOptions( return &result } - restrictOpts := opts.RestrictFetchOptions + restrictOpts := opts.RestrictQueryOptions if restrictOpts == nil { return &result } diff --git a/src/query/storage/restrict_fetch_options_test.go b/src/query/storage/restrict_fetch_options_test.go index 9b59c2724b..f0825001a5 100644 --- a/src/query/storage/restrict_fetch_options_test.go +++ b/src/query/storage/restrict_fetch_options_test.go @@ -29,11 +29,11 @@ import ( ) func TestGetRestrict(t *testing.T) { - var opts *RestrictFetchOptions + var opts *RestrictQueryOptions require.Nil(t, opts.GetRestrictByTag()) require.Nil(t, opts.GetRestrictByType()) - opts = &RestrictFetchOptions{} + opts = &RestrictQueryOptions{} require.Nil(t, opts.GetRestrictByTag()) require.Nil(t, opts.GetRestrictByType()) diff --git a/src/query/storage/types.go b/src/query/storage/types.go index de1a0e5b11..d6bfc8fa31 100644 --- a/src/query/storage/types.go +++ b/src/query/storage/types.go @@ -111,9 +111,9 @@ type FetchOptions struct { BlockType models.FetchedBlockType // FanoutOptions are the options for the fetch namespace fanout. FanoutOptions *FanoutOptions - // RestrictFetchOptions restricts the fetch to a specific set of + // RestrictQueryOptions restricts the fetch to a specific set of // conditions. - RestrictFetchOptions *RestrictFetchOptions + RestrictQueryOptions *RestrictQueryOptions // Step is the configured step size. Step time.Duration // LookbackDuration if set overrides the default lookback duration. @@ -189,20 +189,27 @@ func (o *FetchOptions) QueryFetchOptions( if r.Limit <= 0 { r.Limit = queryCtx.Options.LimitMaxTimeseries } - if r.RestrictFetchOptions == nil && queryCtx.Options.RestrictFetchType != nil { + + // Use inbuilt options for type restriction if none found. + if r.RestrictQueryOptions.GetRestrictByType() == nil && + queryCtx.Options.RestrictFetchType != nil { v := queryCtx.Options.RestrictFetchType - restrict := RestrictFetchOptions{ - RestrictByType: &RestrictByType{ - MetricsType: MetricsType(v.MetricsType), - StoragePolicy: v.StoragePolicy, - }, + restrict := &RestrictByType{ + MetricsType: MetricsType(v.MetricsType), + StoragePolicy: v.StoragePolicy, } + if err := restrict.Validate(); err != nil { return nil, err } - r.RestrictFetchOptions = &restrict + if r.RestrictQueryOptions == nil { + r.RestrictQueryOptions = &RestrictQueryOptions{} + } + + r.RestrictQueryOptions.RestrictByType = restrict } + return r, nil } @@ -235,8 +242,8 @@ type RestrictByTag struct { Strip [][]byte `json:"strip"` } -// RestrictFetchOptions restricts the fetch to a specific set of conditions. -type RestrictFetchOptions struct { +// RestrictQueryOptions restricts the query to a specific set of conditions. +type RestrictQueryOptions struct { // RestrictByType are specific restrictions to stick to a single data type. RestrictByType *RestrictByType // RestrictByTag are specific restrictions to enforce behavior for given diff --git a/src/query/tsdb/remote/codecs.go b/src/query/tsdb/remote/codecs.go index c11df3e6ff..0e65dc8f5b 100644 --- a/src/query/tsdb/remote/codecs.go +++ b/src/query/tsdb/remote/codecs.go @@ -187,8 +187,8 @@ func encodeFetchOptions(options *storage.FetchOptions) (*rpc.FetchOptions, error } result.AggregatedOptimized = aggOpt - if v := options.RestrictFetchOptions; v != nil { - restrict, err := encodeRestrictFetchOptions(v) + if v := options.RestrictQueryOptions; v != nil { + restrict, err := encodeRestrictQueryOptions(v) if err != nil { return nil, err } @@ -203,9 +203,13 @@ func encodeFetchOptions(options *storage.FetchOptions) (*rpc.FetchOptions, error return result, nil } -func encodeRestrictFetchOptionsByType( +func encodeRestrictQueryOptionsByType( o *storage.RestrictByType, ) (*rpcpb.RestrictFetchType, error) { + if o == nil { + return nil, nil + } + if err := o.Validate(); err != nil { return nil, err } @@ -228,7 +232,7 @@ func encodeRestrictFetchOptionsByType( return result, nil } -func encodeRestrictFetchOptionsByTag( +func encodeRestrictQueryOptionsByTag( o *storage.RestrictByTag, ) (*rpcpb.RestrictFetchTags, error) { if o == nil { @@ -246,20 +250,20 @@ func encodeRestrictFetchOptionsByTag( }, nil } -func encodeRestrictFetchOptions( - o *storage.RestrictFetchOptions, -) (*rpcpb.RestrictFetchOptions, error) { - byType, err := encodeRestrictFetchOptionsByType(o.GetRestrictByType()) +func encodeRestrictQueryOptions( + o *storage.RestrictQueryOptions, +) (*rpcpb.RestrictQueryOptions, error) { + byType, err := encodeRestrictQueryOptionsByType(o.GetRestrictByType()) if err != nil { return nil, err } - byTags, err := encodeRestrictFetchOptionsByTag(o.GetRestrictByTag()) + byTags, err := encodeRestrictQueryOptionsByTag(o.GetRestrictByTag()) if err != nil { return nil, err } - return &rpcpb.RestrictFetchOptions{ + return &rpcpb.RestrictQueryOptions{ RestrictFetchType: byType, RestrictFetchTags: byTags, }, nil @@ -374,7 +378,7 @@ func decodeFanoutOption(opt rpc.FanoutOption) (storage.FanoutOption, error) { return 0, fmt.Errorf("unknown fanout option for proto encoding: %v", opt) } -func decodeRestrictFetchOptionsByType( +func decodeRestrictQueryOptionsByType( p *rpc.RestrictFetchType, ) (*storage.RestrictByType, error) { result := &storage.RestrictByType{} @@ -399,10 +403,15 @@ func decodeRestrictFetchOptionsByType( result.StoragePolicy = storagePolicy } + if err := result.Validate(); err != nil { + return nil, err + + } + return result, nil } -func decodeRestrictFetchOptionsByTag( +func decodeRestrictQueryOptionsByTag( p *rpc.RestrictFetchTags, ) (*storage.RestrictByTag, error) { if p == nil { @@ -420,20 +429,20 @@ func decodeRestrictFetchOptionsByTag( }, nil } -func decodeRestrictFetchOptions( - p *rpc.RestrictFetchOptions, -) (*storage.RestrictFetchOptions, error) { - byType, err := decodeRestrictFetchOptionsByType(p.GetRestrictFetchType()) +func decodeRestrictQueryOptions( + p *rpc.RestrictQueryOptions, +) (*storage.RestrictQueryOptions, error) { + byType, err := decodeRestrictQueryOptionsByType(p.GetRestrictFetchType()) if err != nil { return nil, err } - byTag, err := decodeRestrictFetchOptionsByTag(p.GetRestrictFetchTags()) + byTag, err := decodeRestrictQueryOptionsByTag(p.GetRestrictFetchTags()) if err != nil { return nil, err } - return &storage.RestrictFetchOptions{ + return &storage.RestrictQueryOptions{ RestrictByType: byType, RestrictByTag: byTag, }, nil @@ -470,12 +479,12 @@ func decodeFetchOptions(rpcFetchOptions *rpc.FetchOptions) (*storage.FetchOption } if v := rpcFetchOptions.Restrict; v != nil { - restrict, err := decodeRestrictFetchOptions(v) + restrict, err := decodeRestrictQueryOptions(v) if err != nil { return nil, err } - result.RestrictFetchOptions = restrict + result.RestrictQueryOptions = restrict } if v := rpcFetchOptions.LookbackDuration; v > 0 { diff --git a/src/query/tsdb/remote/codecs_test.go b/src/query/tsdb/remote/codecs_test.go index 71fd459de0..ba94607ccf 100644 --- a/src/query/tsdb/remote/codecs_test.go +++ b/src/query/tsdb/remote/codecs_test.go @@ -132,7 +132,7 @@ func TestEncodeFetchMessage(t *testing.T) { rQ, start, end := createStorageFetchQuery(t) fetchOpts := storage.NewFetchOptions() fetchOpts.Limit = 42 - fetchOpts.RestrictFetchOptions = &storage.RestrictFetchOptions{ + fetchOpts.RestrictQueryOptions = &storage.RestrictQueryOptions{ RestrictByType: &storage.RestrictByType{ MetricsType: storage.AggregatedMetricsType, StoragePolicy: policy.MustParseStoragePolicy("1m:14d"), @@ -161,7 +161,7 @@ func TestEncodeFetchMessage(t *testing.T) { assert.Equal(t, rpc.MetricsType_AGGREGATED_METRICS_TYPE, grpcQ.Options.Restrict.RestrictFetchType.MetricsType) require.NotNil(t, grpcQ.Options.Restrict.RestrictFetchType.MetricsStoragePolicy) - expectedStoragePolicyProto, err := fetchOpts.RestrictFetchOptions. + expectedStoragePolicyProto, err := fetchOpts.RestrictQueryOptions. RestrictByType.StoragePolicy.Proto() require.NoError(t, err) assert.Equal(t, expectedStoragePolicyProto, grpcQ.Options.Restrict. @@ -173,7 +173,7 @@ func TestEncodeDecodeFetchQuery(t *testing.T) { rQ, _, _ := createStorageFetchQuery(t) fetchOpts := storage.NewFetchOptions() fetchOpts.Limit = 42 - fetchOpts.RestrictFetchOptions = &storage.RestrictFetchOptions{ + fetchOpts.RestrictQueryOptions = &storage.RestrictQueryOptions{ RestrictByType: &storage.RestrictByType{ MetricsType: storage.AggregatedMetricsType, StoragePolicy: policy.MustParseStoragePolicy("1m:14d"), @@ -191,12 +191,12 @@ func TestEncodeDecodeFetchQuery(t *testing.T) { require.NoError(t, err) require.NotNil(t, revertedOpts) require.Equal(t, fetchOpts.Limit, revertedOpts.Limit) - require.Equal(t, fetchOpts.RestrictFetchOptions. + require.Equal(t, fetchOpts.RestrictQueryOptions. RestrictByType.MetricsType, - revertedOpts.RestrictFetchOptions.RestrictByType.MetricsType) - require.Equal(t, fetchOpts.RestrictFetchOptions. + revertedOpts.RestrictQueryOptions.RestrictByType.MetricsType) + require.Equal(t, fetchOpts.RestrictQueryOptions. RestrictByType.StoragePolicy.String(), - revertedOpts.RestrictFetchOptions.RestrictByType.StoragePolicy.String()) + revertedOpts.RestrictQueryOptions.RestrictByType.StoragePolicy.String()) require.NotNil(t, revertedOpts.LookbackDuration) require.Equal(t, lookback, *revertedOpts.LookbackDuration) @@ -237,26 +237,26 @@ func TestRetrieveMetadata(t *testing.T) { require.Equal(t, requestID, logging.ReadContextID(encodedCtx)) } -func TestNewRestrictFetchOptionsFromProto(t *testing.T) { +func TestNewRestrictQueryOptionsFromProto(t *testing.T) { tests := []struct { - value *rpcpb.RestrictFetchOptions - expected *storage.RestrictFetchOptions + value *rpcpb.RestrictQueryOptions + expected *storage.RestrictQueryOptions errContains string }{ { - value: &rpcpb.RestrictFetchOptions{ + value: &rpcpb.RestrictQueryOptions{ RestrictFetchType: &rpcpb.RestrictFetchType{ MetricsType: rpcpb.MetricsType_UNAGGREGATED_METRICS_TYPE, }, }, - expected: &storage.RestrictFetchOptions{ + expected: &storage.RestrictQueryOptions{ RestrictByType: &storage.RestrictByType{ MetricsType: storage.UnaggregatedMetricsType, }, }, }, { - value: &rpcpb.RestrictFetchOptions{ + value: &rpcpb.RestrictQueryOptions{ RestrictFetchType: &rpcpb.RestrictFetchType{ MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, MetricsStoragePolicy: &policypb.StoragePolicy{ @@ -281,7 +281,7 @@ func TestNewRestrictFetchOptionsFromProto(t *testing.T) { }, }, }, - expected: &storage.RestrictFetchOptions{ + expected: &storage.RestrictQueryOptions{ RestrictByType: &storage.RestrictByType{ MetricsType: storage.AggregatedMetricsType, StoragePolicy: policy.NewStoragePolicy(time.Minute, @@ -300,10 +300,10 @@ func TestNewRestrictFetchOptionsFromProto(t *testing.T) { }, { value: nil, - errContains: "no restrict fetch options proto message", + errContains: "no restrict fetch options", }, { - value: &rpcpb.RestrictFetchOptions{ + value: &rpcpb.RestrictQueryOptions{ RestrictFetchType: &rpcpb.RestrictFetchType{ MetricsType: rpcpb.MetricsType_UNKNOWN_METRICS_TYPE, }, @@ -311,7 +311,7 @@ func TestNewRestrictFetchOptionsFromProto(t *testing.T) { errContains: "unknown metrics type:", }, { - value: &rpcpb.RestrictFetchOptions{ + value: &rpcpb.RestrictQueryOptions{ RestrictFetchType: &rpcpb.RestrictFetchType{ MetricsType: rpcpb.MetricsType_UNAGGREGATED_METRICS_TYPE, MetricsStoragePolicy: &policypb.StoragePolicy{ @@ -328,7 +328,7 @@ func TestNewRestrictFetchOptionsFromProto(t *testing.T) { errContains: "expected no storage policy for unaggregated metrics", }, { - value: &rpcpb.RestrictFetchOptions{ + value: &rpcpb.RestrictQueryOptions{ RestrictFetchType: &rpcpb.RestrictFetchType{ MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, MetricsStoragePolicy: &policypb.StoragePolicy{ @@ -341,7 +341,7 @@ func TestNewRestrictFetchOptionsFromProto(t *testing.T) { errContains: "unable to convert from duration to time unit", }, { - value: &rpcpb.RestrictFetchOptions{ + value: &rpcpb.RestrictQueryOptions{ RestrictFetchType: &rpcpb.RestrictFetchType{ MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, MetricsStoragePolicy: &policypb.StoragePolicy{ @@ -355,7 +355,7 @@ func TestNewRestrictFetchOptionsFromProto(t *testing.T) { errContains: "unable to convert from duration to time unit", }, { - value: &rpcpb.RestrictFetchOptions{ + value: &rpcpb.RestrictQueryOptions{ RestrictFetchType: &rpcpb.RestrictFetchType{ MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, MetricsStoragePolicy: &policypb.StoragePolicy{ @@ -373,19 +373,19 @@ func TestNewRestrictFetchOptionsFromProto(t *testing.T) { }, } for _, test := range tests { - // t.Run(fmt.Sprintf("%s", test.value), func(t *testing.T) { - result, err := decodeRestrictFetchOptions(test.value) - if test.errContains == "" { - require.NoError(t, err) - assert.Equal(t, test.expected, result) - return - } + t.Run(fmt.Sprintf("%+v", test), func(t *testing.T) { + result, err := decodeRestrictQueryOptions(test.value) + if test.errContains == "" { + require.NoError(t, err) + assert.Equal(t, test.expected, result) + return + } - require.Error(t, err) - assert.True(t, - strings.Contains(err.Error(), test.errContains), - fmt.Sprintf("err=%v, want_contains=%v", err.Error(), test.errContains)) - // }) + require.Error(t, err) + assert.True(t, + strings.Contains(err.Error(), test.errContains), + fmt.Sprintf("err=%v, want_contains=%v", err.Error(), test.errContains)) + }) } } @@ -402,14 +402,14 @@ func newRPCMatcher(t rpc.MatcherType, n, v string) *rpc.TagMatcher { return &rpc.TagMatcher{Name: []byte(n), Value: []byte(v), Type: t} } -func TestRestrictFetchOptionsProto(t *testing.T) { +func TestRestrictQueryOptionsProto(t *testing.T) { tests := []struct { - value storage.RestrictFetchOptions - expected *rpcpb.RestrictFetchOptions + value storage.RestrictQueryOptions + expected *rpcpb.RestrictQueryOptions errContains string }{ { - value: storage.RestrictFetchOptions{ + value: storage.RestrictQueryOptions{ RestrictByType: &storage.RestrictByType{ MetricsType: storage.UnaggregatedMetricsType, }, @@ -420,7 +420,7 @@ func TestRestrictFetchOptionsProto(t *testing.T) { Strip: [][]byte{[]byte("foobar")}, }, }, - expected: &rpcpb.RestrictFetchOptions{ + expected: &rpcpb.RestrictQueryOptions{ RestrictFetchType: &rpcpb.RestrictFetchType{ MetricsType: rpcpb.MetricsType_UNAGGREGATED_METRICS_TYPE, }, @@ -435,7 +435,7 @@ func TestRestrictFetchOptionsProto(t *testing.T) { }, }, { - value: storage.RestrictFetchOptions{ + value: storage.RestrictQueryOptions{ RestrictByType: &storage.RestrictByType{ MetricsType: storage.AggregatedMetricsType, StoragePolicy: policy.NewStoragePolicy(time.Minute, @@ -449,7 +449,7 @@ func TestRestrictFetchOptionsProto(t *testing.T) { Strip: [][]byte{[]byte("foobar")}, }, }, - expected: &rpcpb.RestrictFetchOptions{ + expected: &rpcpb.RestrictQueryOptions{ RestrictFetchType: &rpcpb.RestrictFetchType{ MetricsType: rpcpb.MetricsType_AGGREGATED_METRICS_TYPE, MetricsStoragePolicy: &policypb.StoragePolicy{ @@ -474,7 +474,7 @@ func TestRestrictFetchOptionsProto(t *testing.T) { }, }, { - value: storage.RestrictFetchOptions{ + value: storage.RestrictQueryOptions{ RestrictByType: &storage.RestrictByType{ MetricsType: storage.MetricsType(uint(math.MaxUint16)), }, @@ -482,7 +482,7 @@ func TestRestrictFetchOptionsProto(t *testing.T) { errContains: "unknown metrics type:", }, { - value: storage.RestrictFetchOptions{ + value: storage.RestrictQueryOptions{ RestrictByType: &storage.RestrictByType{ MetricsType: storage.UnaggregatedMetricsType, StoragePolicy: policy.NewStoragePolicy(time.Minute, @@ -494,7 +494,7 @@ func TestRestrictFetchOptionsProto(t *testing.T) { } for _, test := range tests { t.Run(fmt.Sprintf("%+v", test.value), func(t *testing.T) { - result, err := encodeRestrictFetchOptions(&test.value) + result, err := encodeRestrictQueryOptions(&test.value) if test.errContains == "" { require.NoError(t, err) require.Equal(t, test.expected, result) From 991a83896c5e9d0b0a6ef43d11e9f5c7b8302011 Mon Sep 17 00:00:00 2001 From: Artem Date: Mon, 2 Dec 2019 10:35:08 -0500 Subject: [PATCH 5/7] Change a few structures --- src/query/api/v1/handler/fetch_options.go | 11 +- .../api/v1/handler/fetch_options_test.go | 52 +++++++++ .../api/v1/handler/prometheus/native/read.go | 3 +- .../handler/prometheus/native/read_common.go | 2 + src/query/api/v1/handler/tag_options.go | 110 ++++++++++++++++++ src/query/models/matcher.go | 9 ++ src/query/models/matcher_test.go | 16 +-- ...h_options.go => restrict_query_options.go} | 0 ...test.go => restrict_query_options_test.go} | 0 src/query/storage/types.go | 6 +- 10 files changed, 189 insertions(+), 20 deletions(-) create mode 100644 src/query/api/v1/handler/tag_options.go rename src/query/storage/{restrict_fetch_options.go => restrict_query_options.go} (100%) rename src/query/storage/{restrict_fetch_options_test.go => restrict_query_options_test.go} (100%) diff --git a/src/query/api/v1/handler/fetch_options.go b/src/query/api/v1/handler/fetch_options.go index 9e87e3a7cd..1e1e969564 100644 --- a/src/query/api/v1/handler/fetch_options.go +++ b/src/query/api/v1/handler/fetch_options.go @@ -135,13 +135,18 @@ func (b fetchOptionsBuilder) NewFetchOptions( } if str := req.Header.Get(QueryOptionsJSONHeader); str != "" { - var opts *storage.RestrictQueryOptions - if err := json.Unmarshal([]byte(str), opts); err != nil { + var opts stringTagOptions + if err := json.Unmarshal([]byte(str), &opts); err != nil { + return nil, xhttp.NewParseError(err, http.StatusBadRequest) + } + + tagOpts, err := opts.toOptions() + if err != nil { return nil, xhttp.NewParseError(err, http.StatusBadRequest) } fetchOpts.RestrictQueryOptions = newOrExistingRestrictQueryOptions(fetchOpts) - fetchOpts.RestrictQueryOptions.RestrictByTag = opts.RestrictByTag + fetchOpts.RestrictQueryOptions.RestrictByTag = tagOpts } if restrict := fetchOpts.RestrictQueryOptions; restrict != nil { diff --git a/src/query/api/v1/handler/fetch_options_test.go b/src/query/api/v1/handler/fetch_options_test.go index 7875cf5986..1178ac4cc0 100644 --- a/src/query/api/v1/handler/fetch_options_test.go +++ b/src/query/api/v1/handler/fetch_options_test.go @@ -30,6 +30,7 @@ import ( "time" "github.com/m3db/m3/src/metrics/policy" + "github.com/m3db/m3/src/query/models" "github.com/m3db/m3/src/query/storage" "github.com/stretchr/testify/assert" @@ -273,3 +274,54 @@ func TestParseDurationOverflowError(t *testing.T) { _, err = ParseDuration(r, StepParam) assert.Error(t, err) } + +func TestFetchOptionsWithHeader(t *testing.T) { + type expectedLookback struct { + value time.Duration + } + + headers := map[string]string{ + MetricsTypeHeader: storage.AggregatedMetricsType.String(), + MetricsStoragePolicyHeader: "1m:14d", + QueryOptionsJSONHeader: `{ + "match":[ + {"name":"a", "value":"b", "type":"EQUAL"}, + {"name":"c", "value":"d", "type":"NOTEQUAL"}, + {"name":"e", "value":"f", "type":"REGEXP"}, + {"name":"g", "value":"h", "type":"NOTREGEXP"}, + {"name":"i", "value":"j", "type":"EXISTS"}, + {"name":"k", "value":"l", "type":"NOTEXISTS"} + ], + "strip":["foo"] + }`, + } + + builder := NewFetchOptionsBuilder(FetchOptionsBuilderOptions{Limit: 5}) + req := httptest.NewRequest("GET", "/", nil) + for k, v := range headers { + req.Header.Add(k, v) + } + + opts, err := builder.NewFetchOptions(req) + require.NoError(t, err) + require.NotNil(t, opts.RestrictQueryOptions) + ex := &storage.RestrictQueryOptions{ + RestrictByType: &storage.RestrictByType{ + MetricsType: storage.AggregatedMetricsType, + StoragePolicy: policy.MustParseStoragePolicy("1m:14d"), + }, + RestrictByTag: &storage.RestrictByTag{ + Restrict: models.Matchers{ + mustMatcher("a", "b", models.MatchEqual), + mustMatcher("c", "d", models.MatchNotEqual), + mustMatcher("e", "f", models.MatchRegexp), + mustMatcher("g", "h", models.MatchNotRegexp), + mustMatcher("i", "j", models.MatchField), + mustMatcher("k", "l", models.MatchNotField), + }, + Strip: toStrip("foo"), + }, + } + + require.Equal(t, ex, opts.RestrictQueryOptions) +} diff --git a/src/query/api/v1/handler/prometheus/native/read.go b/src/query/api/v1/handler/prometheus/native/read.go index 29ab140373..aabd3b78d8 100644 --- a/src/query/api/v1/handler/prometheus/native/read.go +++ b/src/query/api/v1/handler/prometheus/native/read.go @@ -220,8 +220,7 @@ func (h *PromReadHandler) ServeHTTPWithEngine( // TODO: Support multiple result types w.Header().Set("Content-Type", "application/json") handler.AddWarningHeaders(w, result.meta) - series := prometheus.FilterSeriesByOptions(result.series, fetchOpts) - return series, params, nil + return result.series, params, nil } func (h *PromReadHandler) validateRequest(params *models.RequestParams) error { diff --git a/src/query/api/v1/handler/prometheus/native/read_common.go b/src/query/api/v1/handler/prometheus/native/read_common.go index b58ab51861..3638f658f8 100644 --- a/src/query/api/v1/handler/prometheus/native/read_common.go +++ b/src/query/api/v1/handler/prometheus/native/read_common.go @@ -28,6 +28,7 @@ import ( "sort" "github.com/m3db/m3/src/query/api/v1/handler" + "github.com/m3db/m3/src/query/api/v1/handler/prometheus" "github.com/m3db/m3/src/query/block" "github.com/m3db/m3/src/query/executor" "github.com/m3db/m3/src/query/models" @@ -150,6 +151,7 @@ func read( return emptyResult, err } + series = prometheus.FilterSeriesByOptions(series, fetchOpts) return readResult{ series: series, meta: meta, diff --git a/src/query/api/v1/handler/tag_options.go b/src/query/api/v1/handler/tag_options.go new file mode 100644 index 0000000000..affd918fbe --- /dev/null +++ b/src/query/api/v1/handler/tag_options.go @@ -0,0 +1,110 @@ +// Copyright (c) 2019 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package handler + +import ( + "errors" + "fmt" + + "github.com/m3db/m3/src/query/models" + "github.com/m3db/m3/src/query/storage" +) + +func matchByName(name string) (models.MatchType, error) { + t := models.MatchEqual + switch name { + case "EQUAL": + // noop + case "NOTEQUAL": + t = models.MatchNotEqual + case "REGEXP": + t = models.MatchRegexp + case "NOTREGEXP": + t = models.MatchNotRegexp + case "EXISTS": + t = models.MatchField + case "NOTEXISTS": + t = models.MatchNotField + case "ALL": + return t, errors.New("ALL type not supported as a tag matcher restriction") + default: + return t, fmt.Errorf("matcher type %s not recognized", name) + } + + return t, nil +} + +func (m stringMatch) toMatcher() (models.Matcher, error) { + t, err := matchByName(m.Type) + if err != nil { + return models.Matcher{}, err + } + + return models.NewMatcher(t, []byte(m.Name), []byte(m.Value)) +} + +func (o *stringTagOptions) toOptions() (*storage.RestrictByTag, error) { + if len(o.Restrict) == 0 && len(o.Strip) == 0 { + return nil, nil + } + + opts := &storage.RestrictByTag{} + if len(o.Restrict) > 0 { + opts.Restrict = make(models.Matchers, 0, len(o.Restrict)) + for _, m := range o.Restrict { + r, err := m.toMatcher() + if err != nil { + return nil, err + } + + opts.Restrict = append(opts.Restrict, r) + } + } + + if o.Strip != nil { + opts.Strip = make([][]byte, 0, len(o.Strip)) + for _, s := range o.Strip { + opts.Strip = append(opts.Strip, []byte(s)) + } + } else { + // If strip not explicitly set, strip tag names from + // the restricted matchers. + opts.Strip = make([][]byte, 0, len(opts.Restrict)) + for _, s := range opts.Restrict { + opts.Strip = append(opts.Strip, s.Name) + } + } + + return opts, nil +} + +type stringMatch struct { + Name string `json:"name"` + Type string `json:"type"` + Value string `json:"value"` +} + +// This is an easy to use JSON representation of storage.RestrictByTag that +// allows plaintext string fields rather than forcing base64 encoded values. +type stringTagOptions struct { + Restrict []stringMatch `json:"match"` + Strip []string `json:"strip"` +} diff --git a/src/query/models/matcher.go b/src/query/models/matcher.go index 0991ff8b1a..0a10edfb8a 100644 --- a/src/query/models/matcher.go +++ b/src/query/models/matcher.go @@ -57,6 +57,15 @@ func NewMatcher(t MatchType, n, v []byte) (Matcher, error) { Value: v, } + if len(n) == 0 && t != MatchAll { + return Matcher{}, errors.New("name must be set unless using MatchAll") + } + + if len(v) == 0 && !(t == MatchAll || t == MatchField || t == MatchNotField) { + return Matcher{}, errors.New("field must be set unless using one " + + "of MatchField, MatchNotField, or MatchAll") + } + if t == MatchRegexp || t == MatchNotRegexp { re, err := regexp.Compile("^(?:" + string(v) + ")$") if err != nil { diff --git a/src/query/models/matcher_test.go b/src/query/models/matcher_test.go index af60022e57..7bb1de73e5 100644 --- a/src/query/models/matcher_test.go +++ b/src/query/models/matcher_test.go @@ -27,20 +27,12 @@ import ( "github.com/stretchr/testify/require" ) -func newMatcher(t *testing.T, mType MatchType, value string) Matcher { - m, err := NewMatcher(mType, []byte{}, []byte(value)) +func TestMatcherString(t *testing.T) { + m, err := NewMatcher(MatchEqual, []byte("foo"), []byte("bar")) require.NoError(t, err) require.NotNil(t, m) - - return m -} - -func TestMatcher_String(t *testing.T) { - m := newMatcher(t, MatchEqual, "foo") - m.Name = []byte(`key`) - - assert.Equal(t, `key="foo"`, m.String()) - assert.Equal(t, `key="foo"`, (&m).String()) + assert.Equal(t, `foo="bar"`, m.String()) + assert.Equal(t, `foo="bar"`, (&m).String()) } func TestMatchType(t *testing.T) { diff --git a/src/query/storage/restrict_fetch_options.go b/src/query/storage/restrict_query_options.go similarity index 100% rename from src/query/storage/restrict_fetch_options.go rename to src/query/storage/restrict_query_options.go diff --git a/src/query/storage/restrict_fetch_options_test.go b/src/query/storage/restrict_query_options_test.go similarity index 100% rename from src/query/storage/restrict_fetch_options_test.go rename to src/query/storage/restrict_query_options_test.go diff --git a/src/query/storage/types.go b/src/query/storage/types.go index d6bfc8fa31..9aeb599a5b 100644 --- a/src/query/storage/types.go +++ b/src/query/storage/types.go @@ -234,12 +234,12 @@ type RestrictByTag struct { // Restrict is a set of override matchers to apply to a fetch // regardless of the existing fetch matchers, they should replace any // existing matchers part of a fetch if they collide. - Restrict models.Matchers `json:"restrict"` + Restrict models.Matchers // Strip is a set of tag names to strip from the response. // // NB: If this is unset, but Restrict is set, all tag names appearing in any // of the Restrict matchers are removed. - Strip [][]byte `json:"strip"` + Strip [][]byte } // RestrictQueryOptions restricts the query to a specific set of conditions. @@ -248,7 +248,7 @@ type RestrictQueryOptions struct { RestrictByType *RestrictByType // RestrictByTag are specific restrictions to enforce behavior for given // tags. - RestrictByTag *RestrictByTag `json:"tags"` + RestrictByTag *RestrictByTag } // Querier handles queries against a storage. From bfaca7d7acae33b9a46b7168a474e525221f7f02 Mon Sep 17 00:00:00 2001 From: Artem Date: Mon, 2 Dec 2019 15:10:31 -0500 Subject: [PATCH 6/7] Add docker integration test --- .../query_fanout/restrict.go | 225 ++++++++++++++++++ .../query_fanout/restrict.sh | 19 ++ .../query_fanout/test.sh | 10 +- .../query_fanout/warning.sh | 2 + src/query/api/v1/handler/fetch_options.go | 4 +- .../api/v1/handler/fetch_options_test.go | 2 +- src/query/api/v1/handler/headers.go | 5 +- src/query/api/v1/handler/prometheus/common.go | 27 ++- src/query/api/v1/handler/tag_options.go | 17 +- src/query/api/v1/handler/tag_options_test.go | 144 +++++++++++ src/query/storage/fanout/storage.go | 2 + src/query/storage/m3/cluster_resolver.go | 16 +- src/query/tsdb/remote/codecs.go | 5 +- 13 files changed, 437 insertions(+), 41 deletions(-) create mode 100644 scripts/docker-integration-tests/query_fanout/restrict.go create mode 100755 scripts/docker-integration-tests/query_fanout/restrict.sh create mode 100644 src/query/api/v1/handler/tag_options_test.go diff --git a/scripts/docker-integration-tests/query_fanout/restrict.go b/scripts/docker-integration-tests/query_fanout/restrict.go new file mode 100644 index 0000000000..39527839a9 --- /dev/null +++ b/scripts/docker-integration-tests/query_fanout/restrict.go @@ -0,0 +1,225 @@ +// Copyright (c) 2019 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package main + +import ( + "encoding/json" + "flag" + "fmt" + "io/ioutil" + "net/http" + "os" + "runtime" + + "github.com/m3db/m3/src/query/api/v1/handler" + "github.com/m3db/m3/src/query/api/v1/handler/prometheus" + "github.com/m3db/m3/src/query/models" + + "github.com/stretchr/testify/require" +) + +func main() { + var ts int + flag.IntVar(&ts, "t", -1, "metric name to search") + flag.Parse() + + require.True(t, ts > 0, "no timestamp supplied") + name = fmt.Sprintf("foo_%d", ts) + instant := fmt.Sprintf("http://0.0.0.0:7201/api/v1/query?query=%s", name) + rnge := fmt.Sprintf("http://0.0.0.0:7201/api/v1/query_range?query=%s"+ + "&start=%d&end=%d&step=100", name, ts/100*100, (ts/100+1)*100) + + for _, url := range []string{instant, rnge} { + singleClusterDefaultStrip(url) + bothClusterCustomStrip(url) + bothClusterDefaultStrip(url) + bothClusterNoStrip(url) + bothClusterMultiStrip(url) + } +} + +func queryWithHeader(url string, h string) (prometheus.Response, error) { + var result prometheus.Response + req, err := http.NewRequest("GET", url, nil) + if err != nil { + return result, err + } + + req.Header.Add(handler.RestrictByTagsJSONHeader, h) + client := http.DefaultClient + resp, err := client.Do(req) + if err != nil { + return result, err + } + + if resp.StatusCode != http.StatusOK { + return result, fmt.Errorf("response failed with code %s", resp.Status) + } + + defer resp.Body.Close() + data, err := ioutil.ReadAll(resp.Body) + if err != nil { + return result, err + } + + json.Unmarshal(data, &result) + return result, err +} + +func mustMatcher(t models.MatchType, n string, v string) models.Matcher { + m, err := models.NewMatcher(models.MatchEqual, []byte("val"), []byte("1")) + if err != nil { + panic(err) + } + + return m +} + +type tester struct{} + +// Ensure tester is a TestingT and set a global `t`. +var t require.TestingT = &tester{} + +// name is global and set on startup. +var name string + +func (t *tester) Errorf(format string, args ...interface{}) { + _, fn, line, _ := runtime.Caller(4) + args[2] = fmt.Sprintf(" at %s:%d:\n%v", fn, line, args[2]) + fmt.Printf(format, args...) +} + +func (t *tester) FailNow() { + os.Exit(1) +} + +func mustParseOpts(o handler.StringTagOptions) string { + m, err := json.Marshal(o) + require.NoError(t, err, "cannot marshal to json") + return string(m) +} + +func bothClusterDefaultStrip(url string) { + m := mustParseOpts(handler.StringTagOptions{ + Restrict: []handler.StringMatch{ + handler.StringMatch{Name: "val", Type: "EQUAL", Value: "1"}, + }, + }) + + resp, err := queryWithHeader(url, string(m)) + require.NoError(t, err, "failed to query") + + data := resp.Data.Result + data.Sort() + require.Equal(t, len(data), 2) + clusters := []string{"coordinator-cluster-a", "coordinator-cluster-b"} + for i, d := range data { + require.Equal(t, 2, len(d.Metric)) + require.Equal(t, name, d.Metric["__name__"]) + require.Equal(t, clusters[i], d.Metric["cluster"]) + } +} + +func bothClusterCustomStrip(url string) { + m := mustParseOpts(handler.StringTagOptions{ + Restrict: []handler.StringMatch{ + handler.StringMatch{Name: "val", Type: "EQUAL", Value: "1"}, + }, + Strip: []string{"__name__"}, + }) + + resp, err := queryWithHeader(url, string(m)) + require.NoError(t, err, "failed to query") + + data := resp.Data.Result + data.Sort() + require.Equal(t, len(data), 2) + clusters := []string{"coordinator-cluster-a", "coordinator-cluster-b"} + for i, d := range data { + require.Equal(t, 2, len(d.Metric)) + require.Equal(t, clusters[i], d.Metric["cluster"]) + require.Equal(t, "1", d.Metric["val"]) + } +} + +func bothClusterNoStrip(url string) { + m := mustParseOpts(handler.StringTagOptions{ + Restrict: []handler.StringMatch{ + handler.StringMatch{Name: "val", Type: "EQUAL", Value: "1"}, + }, + Strip: []string{}, + }) + + resp, err := queryWithHeader(url, string(m)) + require.NoError(t, err, "failed to query") + + data := resp.Data.Result + data.Sort() + require.Equal(t, len(data), 2) + clusters := []string{"coordinator-cluster-a", "coordinator-cluster-b"} + for i, d := range data { + require.Equal(t, 3, len(d.Metric)) + require.Equal(t, name, d.Metric["__name__"]) + require.Equal(t, clusters[i], d.Metric["cluster"]) + require.Equal(t, "1", d.Metric["val"]) + } +} + +func bothClusterMultiStrip(url string) { + m := mustParseOpts(handler.StringTagOptions{ + Restrict: []handler.StringMatch{ + handler.StringMatch{Name: "val", Type: "EQUAL", Value: "1"}, + }, + Strip: []string{"val", "__name__"}, + }) + + resp, err := queryWithHeader(url, string(m)) + require.NoError(t, err, "failed to query") + + data := resp.Data.Result + data.Sort() + require.Equal(t, len(data), 2) + clusters := []string{"coordinator-cluster-a", "coordinator-cluster-b"} + for i, d := range data { + require.Equal(t, 1, len(d.Metric)) + require.Equal(t, clusters[i], d.Metric["cluster"]) + } +} + +// NB: cluster 1 is expected to have metrics with vals in range: [1,5] +// and cluster 2 is expected to have metrics with vals in range: [1,10] +// so setting the value to be in (5..10] should hit only a single metric. +func singleClusterDefaultStrip(url string) { + m := mustParseOpts(handler.StringTagOptions{ + Restrict: []handler.StringMatch{ + handler.StringMatch{Name: "val", Type: "EQUAL", Value: "9"}, + }, + }) + + resp, err := queryWithHeader(url, string(m)) + require.NoError(t, err, "failed to query") + + data := resp.Data.Result + require.Equal(t, len(data), 1, url) + require.Equal(t, 2, len(data[0].Metric)) + require.Equal(t, name, data[0].Metric["__name__"], "single") + require.Equal(t, "coordinator-cluster-b", data[0].Metric["cluster"]) +} diff --git a/scripts/docker-integration-tests/query_fanout/restrict.sh b/scripts/docker-integration-tests/query_fanout/restrict.sh new file mode 100755 index 0000000000..e648c572c7 --- /dev/null +++ b/scripts/docker-integration-tests/query_fanout/restrict.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash + +set -ex +TEST_PATH=$GOPATH/src/github.com/m3db/m3/scripts/docker-integration-tests +FANOUT_PATH=$TEST_PATH/query_fanout +source $TEST_PATH/common.sh +source $FANOUT_PATH/warning.sh + +function test_restrictions { + t=$(date +%s) + METRIC_NAME="foo_$t" + # # write 5 metrics to cluster a + write_metrics coordinator-cluster-a 5 + # write 10 metrics to cluster b + write_metrics coordinator-cluster-b 10 + + # unlimited query against cluster a has no header + ATTEMPTS=3 TIMEOUT=1 retry_with_backoff go run $FANOUT_PATH/restrict.go -t $t +} diff --git a/scripts/docker-integration-tests/query_fanout/test.sh b/scripts/docker-integration-tests/query_fanout/test.sh index 5d1f3ef905..5a4321e2dc 100755 --- a/scripts/docker-integration-tests/query_fanout/test.sh +++ b/scripts/docker-integration-tests/query_fanout/test.sh @@ -2,8 +2,11 @@ set -xe -source $GOPATH/src/github.com/m3db/m3/scripts/docker-integration-tests/common.sh -source $GOPATH/src/github.com/m3db/m3/scripts/docker-integration-tests/query_fanout/warning.sh +TEST_PATH=$GOPATH/src/github.com/m3db/m3/scripts/docker-integration-tests +FANOUT_PATH=$TEST_PATH/query_fanout +source $TEST_PATH/common.sh +source $FANOUT_PATH/warning.sh +source $FANOUT_PATH/restrict.sh REVISION=$(git rev-parse HEAD) COMPOSE_FILE=$GOPATH/src/github.com/m3db/m3/scripts/docker-integration-tests/query_fanout/docker-compose.yml @@ -216,3 +219,6 @@ ATTEMPTS=5 TIMEOUT=1 retry_with_backoff complete_tags echo "running fanout warning tests" test_fanout_warnings + +echo "running restrict tests" +test_restrictions diff --git a/scripts/docker-integration-tests/query_fanout/warning.sh b/scripts/docker-integration-tests/query_fanout/warning.sh index c2ed7dc358..dc12a5a398 100755 --- a/scripts/docker-integration-tests/query_fanout/warning.sh +++ b/scripts/docker-integration-tests/query_fanout/warning.sh @@ -337,6 +337,8 @@ function test_fanout_warning_missing_zone { ATTEMPTS=3 TIMEOUT=1 retry_with_backoff find_carbon 16 remote_store_cluster-c_complete_tags_warning ATTEMPTS=3 TIMEOUT=1 retry_with_backoff find_carbon 9 max_fetch_series_limit_applied,remote_store_cluster-c_complete_tags_warning + + docker-compose -f ${COMPOSE_FILE} start coordinator-cluster-c } function test_fanout_warnings { diff --git a/src/query/api/v1/handler/fetch_options.go b/src/query/api/v1/handler/fetch_options.go index 1e1e969564..d36ab9df01 100644 --- a/src/query/api/v1/handler/fetch_options.go +++ b/src/query/api/v1/handler/fetch_options.go @@ -134,8 +134,8 @@ func (b fetchOptionsBuilder) NewFetchOptions( fetchOpts.RestrictQueryOptions.RestrictByType.StoragePolicy = sp } - if str := req.Header.Get(QueryOptionsJSONHeader); str != "" { - var opts stringTagOptions + if str := req.Header.Get(RestrictByTagsJSONHeader); str != "" { + var opts StringTagOptions if err := json.Unmarshal([]byte(str), &opts); err != nil { return nil, xhttp.NewParseError(err, http.StatusBadRequest) } diff --git a/src/query/api/v1/handler/fetch_options_test.go b/src/query/api/v1/handler/fetch_options_test.go index 1178ac4cc0..175c284782 100644 --- a/src/query/api/v1/handler/fetch_options_test.go +++ b/src/query/api/v1/handler/fetch_options_test.go @@ -283,7 +283,7 @@ func TestFetchOptionsWithHeader(t *testing.T) { headers := map[string]string{ MetricsTypeHeader: storage.AggregatedMetricsType.String(), MetricsStoragePolicyHeader: "1m:14d", - QueryOptionsJSONHeader: `{ + RestrictByTagsJSONHeader: `{ "match":[ {"name":"a", "value":"b", "type":"EQUAL"}, {"name":"c", "value":"d", "type":"NOTEQUAL"}, diff --git a/src/query/api/v1/handler/headers.go b/src/query/api/v1/handler/headers.go index eff037e6e0..d0829e23f0 100644 --- a/src/query/api/v1/handler/headers.go +++ b/src/query/api/v1/handler/headers.go @@ -56,8 +56,9 @@ const ( // metrics type. MetricsStoragePolicyHeader = "M3-Storage-Policy" - // QueryOptionsJSONHeader provides tag options to enforces on queries. - QueryOptionsJSONHeader = "M3-Restrict-By-Tags-JSON" + // RestrictByTagsJSONHeader provides tag options to enforces on queries, + // in JSON format. See `handler.stringTagOptions` for definitions.` + RestrictByTagsJSONHeader = "M3-Restrict-By-Tags-JSON" // UnaggregatedStoragePolicy specifies the unaggregated storage policy. UnaggregatedStoragePolicy = "unaggregated" diff --git a/src/query/api/v1/handler/prometheus/common.go b/src/query/api/v1/handler/prometheus/common.go index b1828d7acb..a93a33c065 100644 --- a/src/query/api/v1/handler/prometheus/common.go +++ b/src/query/api/v1/handler/prometheus/common.go @@ -452,9 +452,10 @@ func (r results) Less(i, j int) bool { // Swap swaps the elements with indexes i and j. func (r results) Swap(i, j int) { r[i], r[j] = r[j], r[i] } -func (r results) sort() { - for _, result := range r { - result.genID() +// Sort sorts the results. +func (r results) Sort() { + for i, result := range r { + r[i] = result.genID() } sort.Sort(r) @@ -478,18 +479,22 @@ type Values []Value // Value is a single value for Prometheus result. type Value []interface{} -func (r *Result) genID() { +func (r *Result) genID() Result { + tags := make(sort.StringSlice, len(r.Metric)) + for k, v := range r.Metric { + tags = append(tags, fmt.Sprintf("%s:%s,", k, v)) + } + + sort.Sort(tags) var sb strings.Builder // NB: this may clash but exact tag values are also checked, and this is a // validation endpoint so there's less concern over correctness. - for k, v := range r.Metric { - sb.WriteString(k) - sb.WriteString(`:"`) - sb.WriteString(v) - sb.WriteString(`",`) + for _, t := range tags { + sb.WriteString(t) } r.id = sb.String() + return *r } // MatchInformation describes how well two responses match. @@ -534,8 +539,8 @@ func (r results) matches(other results) (MatchInformation, error) { }, err } - r.sort() - other.sort() + r.Sort() + other.Sort() for i, result := range r { if err := result.matches(other[i]); err != nil { return MatchInformation{ diff --git a/src/query/api/v1/handler/tag_options.go b/src/query/api/v1/handler/tag_options.go index affd918fbe..664376aeb7 100644 --- a/src/query/api/v1/handler/tag_options.go +++ b/src/query/api/v1/handler/tag_options.go @@ -52,7 +52,7 @@ func matchByName(name string) (models.MatchType, error) { return t, nil } -func (m stringMatch) toMatcher() (models.Matcher, error) { +func (m StringMatch) toMatcher() (models.Matcher, error) { t, err := matchByName(m.Type) if err != nil { return models.Matcher{}, err @@ -61,7 +61,7 @@ func (m stringMatch) toMatcher() (models.Matcher, error) { return models.NewMatcher(t, []byte(m.Name), []byte(m.Value)) } -func (o *stringTagOptions) toOptions() (*storage.RestrictByTag, error) { +func (o *StringTagOptions) toOptions() (*storage.RestrictByTag, error) { if len(o.Restrict) == 0 && len(o.Strip) == 0 { return nil, nil } @@ -96,15 +96,18 @@ func (o *stringTagOptions) toOptions() (*storage.RestrictByTag, error) { return opts, nil } -type stringMatch struct { +// StringMatch is an easy to use JSON representation of models.Matcher that +// allows plaintext fields rather than forcing base64 encoded values. +type StringMatch struct { Name string `json:"name"` Type string `json:"type"` Value string `json:"value"` } -// This is an easy to use JSON representation of storage.RestrictByTag that -// allows plaintext string fields rather than forcing base64 encoded values. -type stringTagOptions struct { - Restrict []stringMatch `json:"match"` +// StringTagOptions is an easy to use JSON representation of +// storage.RestrictByTag that allows plaintext string fields rather than +// forcing base64 encoded values. +type StringTagOptions struct { + Restrict []StringMatch `json:"match"` Strip []string `json:"strip"` } diff --git a/src/query/api/v1/handler/tag_options_test.go b/src/query/api/v1/handler/tag_options_test.go new file mode 100644 index 0000000000..71204704a4 --- /dev/null +++ b/src/query/api/v1/handler/tag_options_test.go @@ -0,0 +1,144 @@ +// Copyright (c) 2019 Uber Technologies, Inc. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +package handler + +import ( + "encoding/json" + "testing" + + "github.com/m3db/m3/src/query/models" + "github.com/m3db/m3/src/query/storage" + + "github.com/stretchr/testify/require" +) + +func toStrip(strs ...string) [][]byte { + b := make([][]byte, 0, len(strs)) + for _, s := range strs { + b = append(b, []byte(s)) + } + + return b +} + +func mustMatcher(n string, v string, t models.MatchType) models.Matcher { + m, err := models.NewMatcher(t, []byte(n), []byte(v)) + if err != nil { + panic(err) + } + + return m +} + +func TestParse(t *testing.T) { + tests := []struct { + json string + expected *storage.RestrictByTag + expectedError bool + }{ + {"{}", nil, false}, + { + `{ + "match":[ + {"name":"a", "value":"b", "type":"EQUAL"}, + {"name":"c", "value":"d", "type":"NOTEQUAL"}, + {"name":"e", "value":"f", "type":"REGEXP"}, + {"name":"g", "value":"h", "type":"NOTREGEXP"}, + {"name":"i", "type":"EXISTS"}, + {"name":"j", "type":"NOTEXISTS"} + ] + }`, + &storage.RestrictByTag{ + Restrict: models.Matchers{ + mustMatcher("a", "b", models.MatchEqual), + mustMatcher("c", "d", models.MatchNotEqual), + mustMatcher("e", "f", models.MatchRegexp), + mustMatcher("g", "h", models.MatchNotRegexp), + mustMatcher("i", "", models.MatchField), + mustMatcher("j", "", models.MatchNotField), + }, + Strip: toStrip("a", "c", "e", "g", "i", "j"), + }, + false, + }, + { + `{ + "match":[ + {"name":"a", "value":"b", "type":"EQUAL"}, + {"name":"c", "value":"d", "type":"NOTEQUAL"}, + {"name":"e", "value":"f", "type":"REGEXP"}, + {"name":"g", "value":"h", "type":"NOTREGEXP"}, + {"name":"i", "value":"j", "type":"EXISTS"}, + {"name":"k", "value":"l", "type":"NOTEXISTS"} + ], + "strip":["foo"] + }`, + &storage.RestrictByTag{ + Restrict: models.Matchers{ + mustMatcher("a", "b", models.MatchEqual), + mustMatcher("c", "d", models.MatchNotEqual), + mustMatcher("e", "f", models.MatchRegexp), + mustMatcher("g", "h", models.MatchNotRegexp), + mustMatcher("i", "j", models.MatchField), + mustMatcher("k", "l", models.MatchNotField), + }, + Strip: toStrip("foo"), + }, + false, + }, + { + `{"match":[{"name":"i", "value":"j", "type":"EXISTS"}],"strip":[]}`, + &storage.RestrictByTag{ + Restrict: models.Matchers{ + mustMatcher("i", "j", models.MatchField), + }, + Strip: [][]byte{}, + }, + false, + }, + { + `{"strip":["foo"]}`, + &storage.RestrictByTag{ + Strip: toStrip("foo"), + }, + false, + }, + {`{"match":[{}]}`, nil, true}, + {`{"match":[{"type":"ALL"}]}`, nil, true}, + {`{"match":[{"type":"invalid"}]}`, nil, true}, + {`{"match":[{"name":"a","type":"EQUAL"}]}`, nil, true}, + } + + for _, tt := range tests { + var opts StringTagOptions + err := json.Unmarshal([]byte(tt.json), &opts) + require.NoError(t, err) + + a, err := opts.toOptions() + if tt.expectedError { + require.Error(t, err) + require.Nil(t, a) + } else { + require.NoError(t, err) + require.Equal(t, tt.expected, a) + } + } +} diff --git a/src/query/storage/fanout/storage.go b/src/query/storage/fanout/storage.go index b603b0b38c..81430369f8 100644 --- a/src/query/storage/fanout/storage.go +++ b/src/query/storage/fanout/storage.go @@ -364,6 +364,8 @@ func applyOptions( filteredList = append(filteredList, s) } + + result.CompletedTags = filteredList } return result diff --git a/src/query/storage/m3/cluster_resolver.go b/src/query/storage/m3/cluster_resolver.go index a38d1f66f3..4ddecca550 100644 --- a/src/query/storage/m3/cluster_resolver.go +++ b/src/query/storage/m3/cluster_resolver.go @@ -21,7 +21,6 @@ package m3 import ( - "errors" "fmt" "sort" "time" @@ -79,10 +78,10 @@ func resolveClusterNamespacesForQuery( opts *storage.FanoutOptions, restrict *storage.RestrictQueryOptions, ) (queryFanoutType, ClusterNamespaces, error) { - if restrict != nil { + if typeRestrict := restrict.GetRestrictByType(); typeRestrict != nil { // If a specific restriction is set, then attempt to satisfy. return resolveClusterNamespacesForQueryWithRestrictQueryOptions(now, - start, clusters, restrict) + start, clusters, *typeRestrict) } // First check if the unaggregated cluster can fully satisfy the query range. @@ -302,22 +301,13 @@ func aggregatedNamespaces( func resolveClusterNamespacesForQueryWithRestrictQueryOptions( now, start time.Time, clusters Clusters, - fetchOptions *storage.RestrictQueryOptions, + restrict storage.RestrictByType, ) (queryFanoutType, ClusterNamespaces, error) { coversRangeFilter := newCoversRangeFilter(coversRangeFilterOptions{ now: now, queryStart: start, }) - if fetchOptions == nil { - return 0, nil, errors.New("fetch options must not be nil") - } - - restrict := fetchOptions.RestrictByType - if restrict == nil { - return 0, nil, errors.New("fetch options type restriction must not be nil") - } - result := func( namespace ClusterNamespace, err error, diff --git a/src/query/tsdb/remote/codecs.go b/src/query/tsdb/remote/codecs.go index 0e65dc8f5b..706866a597 100644 --- a/src/query/tsdb/remote/codecs.go +++ b/src/query/tsdb/remote/codecs.go @@ -22,7 +22,6 @@ package remote import ( "context" - "errors" "fmt" "net/http" "strings" @@ -381,11 +380,11 @@ func decodeFanoutOption(opt rpc.FanoutOption) (storage.FanoutOption, error) { func decodeRestrictQueryOptionsByType( p *rpc.RestrictFetchType, ) (*storage.RestrictByType, error) { - result := &storage.RestrictByType{} if p == nil { - return result, errors.New("no restrict fetch options by type") + return nil, nil } + result := &storage.RestrictByType{} switch p.GetMetricsType() { case rpcpb.MetricsType_UNAGGREGATED_METRICS_TYPE: result.MetricsType = storage.UnaggregatedMetricsType From 1ca734e28b8918e0d69b5b30a045a8c416584ca6 Mon Sep 17 00:00:00 2001 From: Artem Date: Mon, 2 Dec 2019 15:55:32 -0500 Subject: [PATCH 7/7] Fix build --- src/query/generated/proto/rpcpb/query.pb.go | 170 ++++++++++---------- src/query/tsdb/remote/codecs_test.go | 4 - 2 files changed, 85 insertions(+), 89 deletions(-) diff --git a/src/query/generated/proto/rpcpb/query.pb.go b/src/query/generated/proto/rpcpb/query.pb.go index 89f2e498aa..ae904e0ef8 100644 --- a/src/query/generated/proto/rpcpb/query.pb.go +++ b/src/query/generated/proto/rpcpb/query.pb.go @@ -459,8 +459,8 @@ func (m *FetchOptions) GetIncludeResolution() bool { } type RestrictQueryOptions struct { - RestrictFetchType *RestrictFetchType `protobuf:"bytes,1,opt,name=RestrictFetchType" json:"RestrictFetchType,omitempty"` - RestrictFetchTags *RestrictFetchTags `protobuf:"bytes,2,opt,name=RestrictFetchTags" json:"RestrictFetchTags,omitempty"` + RestrictFetchType *RestrictFetchType `protobuf:"bytes,3,opt,name=RestrictFetchType" json:"RestrictFetchType,omitempty"` + RestrictFetchTags *RestrictFetchTags `protobuf:"bytes,4,opt,name=RestrictFetchTags" json:"RestrictFetchTags,omitempty"` } func (m *RestrictQueryOptions) Reset() { *m = RestrictQueryOptions{} } @@ -2154,7 +2154,7 @@ func (m *RestrictQueryOptions) MarshalTo(dAtA []byte) (int, error) { var l int _ = l if m.RestrictFetchType != nil { - dAtA[i] = 0xa + dAtA[i] = 0x1a i++ i = encodeVarintQuery(dAtA, i, uint64(m.RestrictFetchType.Size())) n5, err := m.RestrictFetchType.MarshalTo(dAtA[i:]) @@ -2164,7 +2164,7 @@ func (m *RestrictQueryOptions) MarshalTo(dAtA []byte) (int, error) { i += n5 } if m.RestrictFetchTags != nil { - dAtA[i] = 0x12 + dAtA[i] = 0x22 i++ i = encodeVarintQuery(dAtA, i, uint64(m.RestrictFetchTags.Size())) n6, err := m.RestrictFetchTags.MarshalTo(dAtA[i:]) @@ -4555,7 +4555,7 @@ func (m *RestrictQueryOptions) Unmarshal(dAtA []byte) error { return fmt.Errorf("proto: RestrictQueryOptions: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { - case 1: + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field RestrictFetchType", wireType) } @@ -4588,7 +4588,7 @@ func (m *RestrictQueryOptions) Unmarshal(dAtA []byte) error { return err } iNdEx = postIndex - case 2: + case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field RestrictFetchTags", wireType) } @@ -7769,7 +7769,7 @@ func init() { } var fileDescriptorQuery = []byte{ - // 1636 bytes of a gzipped FileDescriptorProto + // 1640 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x58, 0xdb, 0x72, 0xdb, 0x4e, 0x19, 0xb7, 0xac, 0xf8, 0xf4, 0xf9, 0x10, 0x67, 0x13, 0xfe, 0x75, 0x42, 0x09, 0x1e, 0x01, 0x7f, 0x42, 0x5a, 0xe2, 0xd6, 0x69, 0x29, 0x65, 0x86, 0x83, 0x13, 0xbb, 0x49, 0xa6, 0x89, 0x9d, 0xae, @@ -7795,82 +7795,82 @@ var fileDescriptorQuery = []byte{ 0xfc, 0x37, 0x6b, 0xfd, 0x2d, 0x99, 0x2f, 0x28, 0x6f, 0xb3, 0x86, 0x7d, 0x01, 0x7d, 0x17, 0x56, 0xbc, 0x1b, 0x9b, 0xf2, 0x0e, 0x1b, 0xa2, 0x43, 0x91, 0x45, 0xbd, 0xb1, 0x29, 0xe6, 0x56, 0xe5, 0xbf, 0x79, 0x31, 0x47, 0xd1, 0x05, 0x4b, 0x36, 0xd7, 0x0d, 0x3d, 0x9c, 0x23, 0x17, 0xd0, 0x63, - 0x28, 0x3b, 0xd4, 0x65, 0xc8, 0xf0, 0x78, 0x95, 0x6a, 0x77, 0x93, 0x27, 0xc4, 0x42, 0x99, 0x18, - 0x44, 0xe8, 0x8a, 0x76, 0xa1, 0x39, 0xb7, 0xac, 0xeb, 0x09, 0xd1, 0xae, 0xc3, 0xdd, 0x97, 0x79, - 0xde, 0x94, 0x1e, 0x3d, 0x86, 0xda, 0xc2, 0x24, 0xb3, 0x99, 0x43, 0x67, 0x0c, 0x76, 0x7c, 0xce, - 0x8d, 0x60, 0xce, 0xc4, 0xb4, 0x16, 0x9e, 0x9f, 0x1f, 0x27, 0xdc, 0xd0, 0x43, 0x80, 0x58, 0x50, - 0xe1, 0xb6, 0xa0, 0x98, 0x13, 0x3a, 0x84, 0xf5, 0x48, 0x62, 0x76, 0x43, 0x7f, 0x4f, 0xa7, 0xad, - 0xe2, 0x6d, 0xb1, 0x59, 0xde, 0x0c, 0xae, 0xba, 0xa9, 0xcd, 0x17, 0x53, 0x8a, 0xa9, 0x6b, 0xcd, - 0x17, 0xbc, 0xb7, 0x52, 0x5b, 0xda, 0x29, 0xe3, 0xb4, 0x41, 0xf9, 0x8b, 0x04, 0x1b, 0x59, 0xb3, - 0x42, 0x7d, 0x58, 0x4b, 0xe8, 0xd9, 0xd6, 0xf0, 0xd1, 0x57, 0xbb, 0x5f, 0xa5, 0x27, 0xcc, 0x37, - 0x2e, 0x1d, 0x90, 0xce, 0x42, 0x66, 0xae, 0xd8, 0xa7, 0xac, 0x2c, 0x64, 0xe6, 0xe2, 0x74, 0x80, - 0xf2, 0x67, 0x29, 0x63, 0x31, 0xa8, 0x0b, 0x55, 0xc1, 0x09, 0xe1, 0xda, 0x42, 0x38, 0x45, 0x7a, - 0x1c, 0x77, 0x42, 0xcf, 0x61, 0x43, 0x88, 0x63, 0xcf, 0x72, 0xc8, 0x8c, 0x9e, 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x93, 0xa0, 0xc0, 0xbf, 0x2f, 0xd0, 0x43, 0x28, 0xfa, + 0x1f, 0xe2, 0xc8, 0xe7, 0xca, 0xc4, 0x67, 0xfa, 0xd6, 0x7a, 0x42, 0x27, 0x50, 0xfc, 0x00, 0x0a, + 0x9c, 0x18, 0x50, 0x8c, 0x24, 0x82, 0x00, 0x14, 0x57, 0xf9, 0xfe, 0x0f, 0x24, 0xb4, 0xcf, 0x5e, + 0xb8, 0x8c, 0xae, 0x45, 0x91, 0xc4, 0x85, 0xbb, 0xb5, 0x9e, 0xd0, 0x85, 0x41, 0x03, 0xa8, 0xc5, + 0x3b, 0x42, 0xad, 0xdb, 0x78, 0x61, 0x6b, 0x33, 0xc3, 0x12, 0xa4, 0x39, 0xb8, 0xf3, 0xcf, 0x8f, + 0xdb, 0xd2, 0xbf, 0x3e, 0x6e, 0x4b, 0xff, 0xfe, 0xb8, 0x2d, 0xfd, 0xf1, 0x3f, 0xdb, 0xb9, 0x5f, + 0x17, 0xf8, 0x5f, 0x1d, 0x93, 0x22, 0xff, 0x6b, 0x62, 0xff, 0xff, 0x01, 0x00, 0x00, 0xff, 0xff, + 0x66, 0x87, 0x8b, 0xa9, 0x27, 0x11, 0x00, 0x00, } diff --git a/src/query/tsdb/remote/codecs_test.go b/src/query/tsdb/remote/codecs_test.go index ba94607ccf..e0b5a0d8c2 100644 --- a/src/query/tsdb/remote/codecs_test.go +++ b/src/query/tsdb/remote/codecs_test.go @@ -298,10 +298,6 @@ func TestNewRestrictQueryOptionsFromProto(t *testing.T) { }, }, }, - { - value: nil, - errContains: "no restrict fetch options", - }, { value: &rpcpb.RestrictQueryOptions{ RestrictFetchType: &rpcpb.RestrictFetchType{