Skip to content

Commit

Permalink
Merge pull request #3804 from replay/update_prometheus_and_cortex
Browse files Browse the repository at this point in the history
Update prometheus and cortex
  • Loading branch information
yeya24 authored Feb 19, 2021
2 parents a5084b8 + bd10173 commit e80836f
Show file tree
Hide file tree
Showing 9 changed files with 373 additions and 163 deletions.
40 changes: 20 additions & 20 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
module github.com/thanos-io/thanos

require (
cloud.google.com/go v0.65.0
cloud.google.com/go v0.74.0
cloud.google.com/go/storage v1.10.0
github.com/Azure/azure-pipeline-go v0.2.2
github.com/Azure/azure-storage-blob-go v0.8.0
github.com/NYTimes/gziphandler v1.1.1
github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d
github.com/alecthomas/units v0.0.0-20210208195552-ff826a37aa15
github.com/aliyun/aliyun-oss-go-sdk v2.0.4+incompatible
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b
github.com/cespare/xxhash v1.1.0
github.com/chromedp/cdproto v0.0.0-20200424080200-0de008e41fa0
github.com/chromedp/chromedp v0.5.3
github.com/cortexproject/cortex v1.6.1-0.20210108144208-6c2dab103f20
github.com/cortexproject/cortex v1.6.1-0.20210215155036-dfededd9f331
github.com/davecgh/go-spew v1.1.1
github.com/facette/natsort v0.0.0-20181210072756-2cd4dd1e2dcb
github.com/fatih/structtag v1.1.0
github.com/felixge/fgprof v0.9.1
github.com/fsnotify/fsnotify v1.4.9
github.com/go-kit/kit v0.10.0
github.com/go-openapi/strfmt v0.19.11
github.com/gogo/protobuf v1.3.1
github.com/go-openapi/strfmt v0.20.0
github.com/gogo/protobuf v1.3.2
github.com/gogo/status v1.0.3
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e
github.com/golang/snappy v0.0.2
github.com/golang/snappy v0.0.3-0.20201103224600-674baa8c7fc3
github.com/googleapis/gax-go v2.0.2+incompatible
github.com/grpc-ecosystem/go-grpc-middleware v1.1.0
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
Expand All @@ -32,7 +32,7 @@ require (
github.com/leanovate/gopter v0.2.4
github.com/lightstep/lightstep-tracer-go v0.18.1
github.com/lovoo/gcloud-opentracing v0.3.0
github.com/miekg/dns v1.1.35
github.com/miekg/dns v1.1.38
github.com/minio/minio-go/v7 v7.0.2
github.com/mozillazg/go-cos v0.13.0
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f
Expand All @@ -45,29 +45,29 @@ require (
github.com/pkg/errors v0.9.1
github.com/pmezard/go-difflib v1.0.0
github.com/prometheus/alertmanager v0.21.1-0.20201106142418-c39b78780054
github.com/prometheus/client_golang v1.8.0
github.com/prometheus/client_golang v1.9.0
github.com/prometheus/client_model v0.2.0
github.com/prometheus/common v0.15.0
github.com/prometheus/prometheus v1.8.2-0.20201119181812-c8f810083d3f
github.com/prometheus/prometheus v1.8.2-0.20210215121130-6f488061dfb4
github.com/uber/jaeger-client-go v2.25.0+incompatible
github.com/uber/jaeger-lib v2.4.0+incompatible
github.com/weaveworks/common v0.0.0-20201119133501-0619918236ec
github.com/weaveworks/common v0.0.0-20210112142934-23c8d7fa6120
go.elastic.co/apm v1.5.0
go.elastic.co/apm/module/apmot v1.5.0
go.uber.org/atomic v1.7.0
go.uber.org/automaxprocs v1.2.0
go.uber.org/goleak v1.1.10
golang.org/x/crypto v0.0.0-20201002170205-7f63de1d35b0
golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58
golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9
golang.org/x/text v0.3.4
google.golang.org/api v0.35.0
google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d
google.golang.org/grpc v1.33.1
golang.org/x/crypto v0.0.0-20201208171446-5f87f3452ae9
golang.org/x/oauth2 v0.0.0-20210210192628-66670185b0cd
golang.org/x/sync v0.0.0-20201207232520-09787c993a3a
golang.org/x/text v0.3.5
google.golang.org/api v0.39.0
google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d
google.golang.org/grpc v1.34.0
gopkg.in/alecthomas/kingpin.v2 v2.2.6
gopkg.in/fsnotify.v1 v1.4.7
gopkg.in/yaml.v2 v2.3.0
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776
gopkg.in/yaml.v2 v2.4.0
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
)

replace (
Expand All @@ -77,7 +77,7 @@ replace (
// Update to v1.1.1 to make sure windows CI pass.
github.com/elastic/go-sysinfo => github.com/elastic/go-sysinfo v1.1.1
// Make sure Prometheus version is pinned as Prometheus semver does not include Go APIs.
github.com/prometheus/prometheus => github.com/prometheus/prometheus v1.8.2-0.20201119142752-3ad25a6dc3d9
github.com/prometheus/prometheus => github.com/prometheus/prometheus v1.8.2-0.20210215121130-6f488061dfb4
github.com/sercand/kuberesolver => github.com/sercand/kuberesolver v2.4.0+incompatible
google.golang.org/grpc => google.golang.org/grpc v1.29.1

Expand Down
246 changes: 189 additions & 57 deletions go.sum

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion pkg/query/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,18 +333,24 @@ func sortDedupLabels(set []storepb.Series, replicaLabels map[string]struct{}) {
}

// LabelValues returns all potential values for a label name.
func (q *querier) LabelValues(name string) ([]string, storage.Warnings, error) {
func (q *querier) LabelValues(name string, matchers ...*labels.Matcher) ([]string, storage.Warnings, error) {
span, ctx := tracing.StartSpan(q.ctx, "querier_label_values")
defer span.Finish()

// TODO(bwplotka): Pass it using the SeriesRequest instead of relying on context.
ctx = context.WithValue(ctx, store.StoreMatcherKey, q.storeDebugMatchers)

pbMatchers, err := storepb.PromMatchersToMatchers(matchers...)
if err != nil {
return nil, nil, errors.Wrap(err, "convert matchers")
}

resp, err := q.proxy.LabelValues(ctx, &storepb.LabelValuesRequest{
Label: name,
PartialResponseDisabled: !q.partialResponse,
Start: q.mint,
End: q.maxt,
Matchers: pbMatchers,
})
if err != nil {
return nil, nil, errors.Wrap(err, "proxy LabelValues()")
Expand Down
30 changes: 20 additions & 10 deletions pkg/store/bucket_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import (
"github.com/prometheus/prometheus/storage"
"github.com/prometheus/prometheus/tsdb"
"github.com/prometheus/prometheus/tsdb/chunkenc"
"github.com/prometheus/prometheus/tsdb/chunks"
"github.com/prometheus/prometheus/tsdb/encoding"
"go.uber.org/atomic"

Expand Down Expand Up @@ -1033,7 +1032,10 @@ func BenchmarkBucketIndexReader_ExpandedPostings(b *testing.B) {
}

func uploadTestBlock(t testing.TB, tmpDir string, bkt objstore.Bucket, series int) ulid.ULID {
h, err := tsdb.NewHead(nil, nil, nil, 1000, tmpDir, nil, chunks.DefaultWriteBufferSize, tsdb.DefaultStripeSize, nil)
headOpts := tsdb.DefaultHeadOptions()
headOpts.ChunkDirRoot = tmpDir
headOpts.ChunkRange = 1000
h, err := tsdb.NewHead(nil, nil, nil, headOpts)
testutil.Ok(t, err)
defer func() {
testutil.Ok(t, h.Close())
Expand Down Expand Up @@ -1404,13 +1406,16 @@ func TestBucketSeries_OneBlock_InMemIndexCacheSegfault(t *testing.T) {
var b1 *bucketBlock

const numSeries = 100
headOpts := tsdb.DefaultHeadOptions()
headOpts.ChunkDirRoot = tmpDir
headOpts.ChunkRange = 1

// Create 4 blocks. Each will have numSeriesPerBlock number of series that have 1 sample only.
// Timestamp will be counted for each new series, so each series will have unique timestamp.
// This allows to pick time range that will correspond to number of series picked 1:1.
{
// Block 1.
h, err := tsdb.NewHead(nil, nil, nil, 1, tmpDir, nil, chunks.DefaultWriteBufferSize, tsdb.DefaultStripeSize, nil)
h, err := tsdb.NewHead(nil, nil, nil, headOpts)
testutil.Ok(t, err)
defer func() { testutil.Ok(t, h.Close()) }()

Expand Down Expand Up @@ -1449,7 +1454,7 @@ func TestBucketSeries_OneBlock_InMemIndexCacheSegfault(t *testing.T) {
var b2 *bucketBlock
{
// Block 2, do not load this block yet.
h, err := tsdb.NewHead(nil, nil, nil, 1, tmpDir, nil, chunks.DefaultWriteBufferSize, tsdb.DefaultStripeSize, nil)
h, err := tsdb.NewHead(nil, nil, nil, headOpts)
testutil.Ok(t, err)
defer func() { testutil.Ok(t, h.Close()) }()

Expand Down Expand Up @@ -1698,9 +1703,11 @@ func TestSeries_BlockWithMultipleChunks(t *testing.T) {

// Create a block with 1 series but an high number of samples,
// so that they will span across multiple chunks.
blkDir := filepath.Join(tmpDir, "block")
headOpts := tsdb.DefaultHeadOptions()
headOpts.ChunkDirRoot = filepath.Join(tmpDir, "block")
headOpts.ChunkRange = 10000000000

h, err := tsdb.NewHead(nil, nil, nil, 10000000000, blkDir, nil, chunks.DefaultWriteBufferSize, tsdb.DefaultStripeSize, nil)
h, err := tsdb.NewHead(nil, nil, nil, headOpts)
testutil.Ok(t, err)
defer func() { testutil.Ok(t, h.Close()) }()

Expand All @@ -1714,15 +1721,15 @@ func TestSeries_BlockWithMultipleChunks(t *testing.T) {
testutil.Ok(t, app.Commit())
}

blk := createBlockFromHead(t, blkDir, h)
blk := createBlockFromHead(t, headOpts.ChunkDirRoot, h)

thanosMeta := metadata.Thanos{
Labels: labels.Labels{{Name: "ext1", Value: "1"}}.Map(),
Downsample: metadata.ThanosDownsample{Resolution: 0},
Source: metadata.TestSource,
}

_, err = metadata.InjectThanos(log.NewNopLogger(), filepath.Join(blkDir, blk.String()), thanosMeta, nil)
_, err = metadata.InjectThanos(log.NewNopLogger(), filepath.Join(headOpts.ChunkDirRoot, blk.String()), thanosMeta, nil)
testutil.Ok(t, err)

// Create a bucket and upload the block there.
Expand All @@ -1733,7 +1740,7 @@ func TestSeries_BlockWithMultipleChunks(t *testing.T) {

instrBkt := objstore.WithNoopInstr(bkt)
logger := log.NewNopLogger()
testutil.Ok(t, block.Upload(context.Background(), logger, bkt, filepath.Join(blkDir, blk.String())))
testutil.Ok(t, block.Upload(context.Background(), logger, bkt, filepath.Join(headOpts.ChunkDirRoot, blk.String())))

// Instance a real bucket store we'll use to query the series.
fetcher, err := block.NewMetaFetcher(logger, 10, instrBkt, tmpDir, nil, nil, nil)
Expand Down Expand Up @@ -1979,7 +1986,10 @@ func createBlockWithLargeChunk(t testutil.TB, dir string, lbls labels.Labels, ra
}

func createBlockWithOneSeriesWithStep(t testutil.TB, dir string, lbls labels.Labels, blockIndex int, totalSamples int, random *rand.Rand, step int64) ulid.ULID {
h, err := tsdb.NewHead(nil, nil, nil, int64(totalSamples)*step, dir, nil, chunks.DefaultWriteBufferSize, tsdb.DefaultStripeSize, nil)
headOpts := tsdb.DefaultHeadOptions()
headOpts.ChunkDirRoot = dir
headOpts.ChunkRange = int64(totalSamples) * step
h, err := tsdb.NewHead(nil, nil, nil, headOpts)
testutil.Ok(t, err)
defer func() { testutil.Ok(t, h.Close()) }()

Expand Down
6 changes: 4 additions & 2 deletions pkg/store/postings_codec_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (

"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/tsdb"
"github.com/prometheus/prometheus/tsdb/chunks"
"github.com/prometheus/prometheus/tsdb/index"
storetestutil "github.com/thanos-io/thanos/pkg/store/storepb/testutil"
"github.com/thanos-io/thanos/pkg/testutil"
Expand All @@ -24,7 +23,10 @@ func TestDiffVarintCodec(t *testing.T) {
chunksDir, err := ioutil.TempDir("", "diff_varint_codec")
testutil.Ok(t, err)

h, err := tsdb.NewHead(nil, nil, nil, 1000, chunksDir, nil, chunks.DefaultWriteBufferSize, tsdb.DefaultStripeSize, nil)
headOpts := tsdb.DefaultHeadOptions()
headOpts.ChunkDirRoot = chunksDir
headOpts.ChunkRange = 1000
h, err := tsdb.NewHead(nil, nil, nil, headOpts)
testutil.Ok(t, err)
defer func() {
testutil.Ok(t, h.Close())
Expand Down
Loading

0 comments on commit e80836f

Please sign in to comment.