From 51ba819b680ea15b62a5224b1bd8b2e00f29b228 Mon Sep 17 00:00:00 2001 From: Cyril Tovena Date: Mon, 8 Jul 2019 13:07:40 -0400 Subject: [PATCH] rebased --- Gopkg.lock | 68 +------------------ pkg/logproto/logproto.pb.go | 54 ++------------- pkg/querier/querier.go | 1 + .../cortex/pkg/chunk/chunk_store.go | 48 ------------- .../cortex/pkg/chunk/series_store.go | 9 +-- 5 files changed, 11 insertions(+), 169 deletions(-) diff --git a/Gopkg.lock b/Gopkg.lock index c76b09091e8d9..35077a3a2d6bb 100644 --- a/Gopkg.lock +++ b/Gopkg.lock @@ -222,7 +222,7 @@ [[projects]] branch = "master" - digest = "1:2f0846dd85df3365a80c32ff994eb1fcee5eec2c51a812ceec182398f3ef85f4" + digest = "1:5a07b5363e4c2aa127a3afd1e8e323d3a288ba1d90d37793d2e14843f5b5b82e" name = "github.com/cortexproject/cortex" packages = [ "pkg/chunk", @@ -248,16 +248,7 @@ "pkg/util/validation", ] pruneopts = "UT" -<<<<<<< HEAD -<<<<<<< HEAD - revision = "e1ab5495e8a846891e3b6b8e757e63201b886bec" -======= - revision = "823897b6a214f4db92d611fcd76331ff68b1791f" - source = "https://github.com/grafana/cortex" ->>>>>>> Query label values and names are now fetched from the store. -======= revision = "ef492f6bbafb185bbe61ae7a6955b7a4af5f3d9a" ->>>>>>> update vendor [[projects]] digest = "1:ffe9824d294da03b391f44e1ae8281281b4afc1bdaa9588c9097785e3af10cec" @@ -569,39 +560,6 @@ revision = "66b9c49e59c6c48f0ffce28c2d8b8a5678502c6d" version = "v1.4.0" -[[projects]] - branch = "master" - digest = "1:1f4181cfeacebef71babf22e99d727c1667e1f620982787c7035653d6e887dbb" - name = "github.com/grafana/loki" - packages = [ - "pkg/chunkenc", - "pkg/distributor", - "pkg/helpers", - "pkg/ingester", - "pkg/ingester/client", - "pkg/iter", - "pkg/logentry/metric", - "pkg/logentry/stages", - "pkg/logproto", - "pkg/logql", - "pkg/loki", - "pkg/promtail", - "pkg/promtail/api", - "pkg/promtail/client", - "pkg/promtail/client/fake", - "pkg/promtail/config", - "pkg/promtail/positions", - "pkg/promtail/scrape", - "pkg/promtail/server", - "pkg/promtail/server/ui", - "pkg/promtail/targets", - "pkg/querier", - "pkg/util", - "pkg/util/flagext", - ] - pruneopts = "UT" - revision = "4c7138231f77997909564616efc5d0cdbcb1ead8" - [[projects]] digest = "1:1168584a5881d371e96cb0e66ef6db71d7cef0856cc7f311490bc856627f8328" name = "github.com/grpc-ecosystem/go-grpc-middleware" @@ -1628,30 +1586,6 @@ "github.com/golang/snappy", "github.com/gorilla/mux", "github.com/gorilla/websocket", - "github.com/grafana/loki/pkg/chunkenc", - "github.com/grafana/loki/pkg/distributor", - "github.com/grafana/loki/pkg/helpers", - "github.com/grafana/loki/pkg/ingester", - "github.com/grafana/loki/pkg/ingester/client", - "github.com/grafana/loki/pkg/iter", - "github.com/grafana/loki/pkg/logentry/metric", - "github.com/grafana/loki/pkg/logentry/stages", - "github.com/grafana/loki/pkg/logproto", - "github.com/grafana/loki/pkg/logql", - "github.com/grafana/loki/pkg/loki", - "github.com/grafana/loki/pkg/promtail", - "github.com/grafana/loki/pkg/promtail/api", - "github.com/grafana/loki/pkg/promtail/client", - "github.com/grafana/loki/pkg/promtail/client/fake", - "github.com/grafana/loki/pkg/promtail/config", - "github.com/grafana/loki/pkg/promtail/positions", - "github.com/grafana/loki/pkg/promtail/scrape", - "github.com/grafana/loki/pkg/promtail/server", - "github.com/grafana/loki/pkg/promtail/server/ui", - "github.com/grafana/loki/pkg/promtail/targets", - "github.com/grafana/loki/pkg/querier", - "github.com/grafana/loki/pkg/util", - "github.com/grafana/loki/pkg/util/flagext", "github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc", "github.com/hpcloud/tail", "github.com/jmespath/go-jmespath", diff --git a/pkg/logproto/logproto.pb.go b/pkg/logproto/logproto.pb.go index b3130f276be8c..e63820f2282b2 100644 --- a/pkg/logproto/logproto.pb.go +++ b/pkg/logproto/logproto.pb.go @@ -6,17 +6,18 @@ package logproto import ( context "context" fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - proto "github.com/gogo/protobuf/proto" - _ "github.com/gogo/protobuf/types" - github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" - grpc "google.golang.org/grpc" io "io" math "math" reflect "reflect" strconv "strconv" strings "strings" time "time" + + _ "github.com/gogo/protobuf/gogoproto" + proto "github.com/gogo/protobuf/proto" + _ "github.com/gogo/protobuf/types" + github_com_gogo_protobuf_types "github.com/gogo/protobuf/types" + grpc "google.golang.org/grpc" ) // Reference imports to suppress errors if they are not otherwise used. @@ -655,7 +656,6 @@ func init() { func init() { proto.RegisterFile("logproto.proto", fileDescriptor_7a8976f235a02f79) } var fileDescriptor_7a8976f235a02f79 = []byte{ -<<<<<<< HEAD // 728 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x54, 0x4d, 0x4f, 0x13, 0x4f, 0x18, 0xdf, 0xe9, 0x7b, 0x9f, 0xbe, 0x40, 0xe6, 0xff, 0x17, 0x9a, 0xc6, 0x6c, 0x9b, 0x3d, 0x68, @@ -703,48 +703,6 @@ var fileDescriptor_7a8976f235a02f79 = []byte{ 0x26, 0xfa, 0x19, 0x9a, 0xe8, 0x57, 0x68, 0x1a, 0xe7, 0xa1, 0x89, 0x0e, 0x4e, 0x4d, 0xe3, 0xe8, 0xd4, 0x34, 0x8e, 0x4f, 0x4d, 0xa3, 0x97, 0x93, 0xb7, 0x3d, 0xfc, 0x13, 0x00, 0x00, 0xff, 0xff, 0x37, 0x0c, 0xea, 0x1a, 0x0f, 0x06, 0x00, 0x00, -======= - // 613 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x53, 0x4d, 0x6f, 0xd3, 0x40, - 0x10, 0xf5, 0xb6, 0x89, 0x13, 0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x3e, 0x67, 0x04, 0x9d, 0x64, 0x04, 0x9d, 0x66, 0x04, 0x7d, - 0xcb, 0x08, 0xfa, 0x9e, 0x11, 0xe5, 0x22, 0x23, 0xe8, 0x78, 0x4a, 0x94, 0xd3, 0x29, 0x51, 0xce, - 0xa6, 0x44, 0x19, 0xab, 0xb2, 0xd8, 0xbd, 0x9f, 0x01, 0x00, 0x00, 0xff, 0xff, 0x61, 0x32, 0x5b, - 0xc6, 0xdd, 0x04, 0x00, 0x00, ->>>>>>> fix http querystring and update doc } func (x Direction) String() string { diff --git a/pkg/querier/querier.go b/pkg/querier/querier.go index d0dbbf1cdcf41..eacf22fb0edd6 100644 --- a/pkg/querier/querier.go +++ b/pkg/querier/querier.go @@ -10,6 +10,7 @@ import ( "github.com/cortexproject/cortex/pkg/ring" "github.com/cortexproject/cortex/pkg/util" token_util "github.com/grafana/loki/pkg/util" + "github.com/prometheus/common/model" "github.com/weaveworks/common/user" "google.golang.org/grpc/health/grpc_health_v1" diff --git a/vendor/github.com/cortexproject/cortex/pkg/chunk/chunk_store.go b/vendor/github.com/cortexproject/cortex/pkg/chunk/chunk_store.go index 679b35324281f..f93472c09cfcf 100644 --- a/vendor/github.com/cortexproject/cortex/pkg/chunk/chunk_store.go +++ b/vendor/github.com/cortexproject/cortex/pkg/chunk/chunk_store.go @@ -64,12 +64,9 @@ type StoreConfig struct { // Limits query start time to be greater than now() - MaxLookBackPeriod, if set. MaxLookBackPeriod time.Duration `yaml:"max_look_back_period"` -<<<<<<< HEAD -======= // Not visible in yaml because the setting shouldn't be common between ingesters and queriers chunkCacheStubs bool // don't write the full chunk to cache, just a stub entry ->>>>>>> update vendor } // RegisterFlags adds the flags required to config this to the given FlagSet @@ -273,51 +270,6 @@ func (c *store) LabelNamesForMetricName(ctx context.Context, from, through model return labelNamesFromChunks(allChunks), nil } -<<<<<<< HEAD -// LabelValuesForMetricName retrieves all label values for a single label name and metric name. -func (c *store) LabelValuesForMetricName(ctx context.Context, from, through model.Time, metricName, labelName string) ([]string, error) { - log, ctx := spanlogger.New(ctx, "ChunkStore.LabelValues") - defer log.Span.Finish() - level.Debug(log).Log("from", from, "through", through, "metricName", metricName, "labelName", labelName) - - userID, err := user.ExtractOrgID(ctx) - if err != nil { - return nil, err - } - - shortcut, err := c.validateQueryTimeRange(ctx, &from, &through) - if err != nil { - return nil, err - } else if shortcut { - return nil, nil - } - - queries, err := c.schema.GetReadQueriesForMetricLabel(from, through, userID, metricName, labelName) - if err != nil { - return nil, err - } - - entries, err := c.lookupEntriesByQueries(ctx, queries) - if err != nil { - return nil, err - } - - var result []string - for _, entry := range entries { - _, labelValue, _, _, err := parseChunkTimeRangeValue(entry.RangeValue, entry.Value) - if err != nil { - return nil, err - } - result = append(result, string(labelValue)) - } - - sort.Strings(result) - result = uniqueStrings(result) - return result, nil -} - -======= ->>>>>>> update vendor func (c *store) validateQueryTimeRange(ctx context.Context, from *model.Time, through *model.Time) (bool, error) { log, ctx := spanlogger.New(ctx, "store.validateQueryTimeRange") defer log.Span.Finish() diff --git a/vendor/github.com/cortexproject/cortex/pkg/chunk/series_store.go b/vendor/github.com/cortexproject/cortex/pkg/chunk/series_store.go index 7698848063bdc..38bd313a51cf3 100644 --- a/vendor/github.com/cortexproject/cortex/pkg/chunk/series_store.go +++ b/vendor/github.com/cortexproject/cortex/pkg/chunk/series_store.go @@ -201,8 +201,7 @@ func (c *seriesStore) LabelNamesForMetricName(ctx context.Context, from, through return nil, err } - // Validate the query is within reasonable bounds. - metricName, matchers, shortcut, err := c.validateQuery(ctx, &from, &through, allMatchers) + shortcut, err := c.validateQueryTimeRange(ctx, &from, &through) if err != nil { return nil, err } else if shortcut { @@ -210,10 +209,8 @@ func (c *seriesStore) LabelNamesForMetricName(ctx context.Context, from, through } level.Debug(log).Log("metric", metricName) - // Fetch the series IDs from the index, based on non-empty matchers from - // the query. - _, matchers = util.SplitFiltersAndMatchers(matchers) - seriesIDs, err := c.lookupSeriesByMetricNameMatchers(ctx, from, through, userID, metricName, matchers) + // Fetch the series IDs from the index + seriesIDs, err := c.lookupSeriesByMetricNameMatchers(ctx, from, through, userID, metricName, nil) if err != nil { return nil, err }