Skip to content

Commit 13efec0

Browse files
authored
Update Thanos to latest and use label matchers in LabelValues call. (#4133)
* Update Thanos to latest main. Signed-off-by: Peter Štibraný <[email protected]> * Add matchers to LabelValuesRequest. Signed-off-by: Peter Štibraný <[email protected]> * Include matchers in the tests. Signed-off-by: Peter Štibraný <[email protected]> * Removed matchers tests... they were not really testing what we want. Signed-off-by: Peter Štibraný <[email protected]> * CHANGELOG.md Signed-off-by: Peter Štibraný <[email protected]> * Move entry. Signed-off-by: Peter Štibraný <[email protected]> * Clarify. Signed-off-by: Peter Štibraný <[email protected]> * Extend integration test to verify label values with matches. Signed-off-by: Peter Štibraný <[email protected]>
1 parent 0da720f commit 13efec0

File tree

12 files changed

+334
-139
lines changed

12 files changed

+334
-139
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
* [ENHANCEMENT] Store-gateway: retry synching blocks if a per-tenant sync fails. #3975 #4088
6161
* [ENHANCEMENT] Add metric `cortex_tcp_connections` exposing the current number of accepted TCP connections. #4099
6262
* [ENHANCEMENT] Querier: Allow federated queries to run concurrently. #4065
63+
* [ENHANCEMENT] Label Values API call now supports `match[]` parameter when querying blocks on storage (assuming `-querier.query-store-for-labels-enabled` is enabled). #4133
6364
* [BUGFIX] Ruler-API: fix bug where `/api/v1/rules/<namespace>/<group_name>` endpoint return `400` instead of `404`. #4013
6465
* [BUGFIX] Distributor: reverted changes done to rate limiting in #3825. #3948
6566
* [BUGFIX] Ingester: Fix race condition when opening and closing tsdb concurrently. #3959

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ require (
5252
github.com/sony/gobreaker v0.4.1
5353
github.com/spf13/afero v1.2.2
5454
github.com/stretchr/testify v1.7.0
55-
github.com/thanos-io/thanos v0.19.1-0.20210423085824-268cc30e2dd8
55+
github.com/thanos-io/thanos v0.19.1-0.20210427154226-d5bd651319d2
5656
github.com/uber/jaeger-client-go v2.25.0+incompatible
5757
github.com/weaveworks/common v0.0.0-20210419092856-009d1eebd624
5858
go.etcd.io/bbolt v1.3.5

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,8 +1351,8 @@ github.com/thanos-io/thanos v0.13.1-0.20210204123931-82545cdd16fe/go.mod h1:ZLDG
13511351
github.com/thanos-io/thanos v0.13.1-0.20210224074000-659446cab117/go.mod h1:kdqFpzdkveIKpNNECVJd75RPvgsAifQgJymwCdfev1w=
13521352
github.com/thanos-io/thanos v0.13.1-0.20210226164558-03dace0a1aa1/go.mod h1:gMCy4oCteKTT7VuXVvXLTPGzzjovX1VPE5p+HgL1hyU=
13531353
github.com/thanos-io/thanos v0.13.1-0.20210401085038-d7dff0c84d17/go.mod h1:zU8KqE+6A+HksK4wiep8e/3UvCZLm+Wrw9AqZGaAm9k=
1354-
github.com/thanos-io/thanos v0.19.1-0.20210423085824-268cc30e2dd8 h1:M1t8SnLQgsF8x6HWS4TMUB7SmrmJBffnXZKu0CmYZcg=
1355-
github.com/thanos-io/thanos v0.19.1-0.20210423085824-268cc30e2dd8/go.mod h1:zvSf4uKtey4KjSVcalV/5oUuGthaTzI8kVDrO42I8II=
1354+
github.com/thanos-io/thanos v0.19.1-0.20210427154226-d5bd651319d2 h1:L6U4VYeIConcO4GaFOAaZW4Gwr+lIVfBprW9a0+py/k=
1355+
github.com/thanos-io/thanos v0.19.1-0.20210427154226-d5bd651319d2/go.mod h1:zvSf4uKtey4KjSVcalV/5oUuGthaTzI8kVDrO42I8II=
13561356
github.com/themihai/gomemcache v0.0.0-20180902122335-24332e2d58ab h1:7ZR3hmisBWw77ZpO1/o86g+JV3VKlk3d48jopJxzTjU=
13571357
github.com/themihai/gomemcache v0.0.0-20180902122335-24332e2d58ab/go.mod h1:eheTFp954zcWZXCU8d0AT76ftsQOTo4DTqkN/h3k1MY=
13581358
github.com/tidwall/pretty v0.0.0-20180105212114-65a9db5fad51/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=

integration/e2ecortex/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,8 @@ func (c *Client) Series(matches []string, start, end time.Time) ([]model.LabelSe
185185
}
186186

187187
// LabelValues gets label values
188-
func (c *Client) LabelValues(label string, start, end time.Time) (model.LabelValues, error) {
189-
result, _, err := c.querierClient.LabelValues(context.Background(), label, nil, start, end)
188+
func (c *Client) LabelValues(label string, start, end time.Time, matches []string) (model.LabelValues, error) {
189+
result, _, err := c.querierClient.LabelValues(context.Background(), label, matches, start, end)
190190
return result, err
191191
}
192192

integration/getting_started_single_process_config_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func TestGettingStartedSingleProcessConfigWithChunksStorage(t *testing.T) {
4545
require.Equal(t, model.ValVector, result.Type())
4646
assert.Equal(t, expectedVector, result.(model.Vector))
4747

48-
labelValues, err := c.LabelValues("foo", time.Time{}, time.Time{})
48+
labelValues, err := c.LabelValues("foo", time.Time{}, time.Time{}, nil)
4949
require.NoError(t, err)
5050
require.Equal(t, model.LabelValues{"bar"}, labelValues)
5151

@@ -100,7 +100,7 @@ func TestGettingStartedSingleProcessConfigWithBlocksStorage(t *testing.T) {
100100
require.Equal(t, model.ValVector, result.Type())
101101
assert.Equal(t, expectedVector, result.(model.Vector))
102102

103-
labelValues, err := c.LabelValues("foo", time.Time{}, time.Time{})
103+
labelValues, err := c.LabelValues("foo", time.Time{}, time.Time{}, nil)
104104
require.NoError(t, err)
105105
require.Equal(t, model.LabelValues{"bar"}, labelValues)
106106

integration/querier_test.go

Lines changed: 50 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -483,8 +483,9 @@ func testMetadataQueriesWithBlocksStorage(
483483
resp []prompb.Label
484484
}
485485
type labelValuesTest struct {
486-
label string
487-
resp []string
486+
label string
487+
matches []string
488+
resp []string
488489
}
489490

490491
testCases := map[string]struct {
@@ -520,6 +521,16 @@ func testMetadataQueriesWithBlocksStorage(
520521
label: labels.MetricName,
521522
resp: []string{firstSeriesInIngesterHeadName},
522523
},
524+
{
525+
label: labels.MetricName,
526+
resp: []string{firstSeriesInIngesterHeadName},
527+
matches: []string{firstSeriesInIngesterHeadName},
528+
},
529+
{
530+
label: labels.MetricName,
531+
resp: []string{},
532+
matches: []string{lastSeriesInStorageName},
533+
},
523534
},
524535
labelNames: []string{labels.MetricName, firstSeriesInIngesterHeadName},
525536
},
@@ -546,6 +557,17 @@ func testMetadataQueriesWithBlocksStorage(
546557
label: labels.MetricName,
547558
resp: []string{lastSeriesInIngesterBlocksName},
548559
},
560+
561+
{
562+
label: labels.MetricName,
563+
resp: []string{lastSeriesInIngesterBlocksName},
564+
matches: []string{lastSeriesInIngesterBlocksName},
565+
},
566+
{
567+
label: labels.MetricName,
568+
resp: []string{},
569+
matches: []string{firstSeriesInIngesterHeadName},
570+
},
549571
},
550572
labelNames: []string{labels.MetricName, lastSeriesInIngesterBlocksName},
551573
},
@@ -574,6 +596,21 @@ func testMetadataQueriesWithBlocksStorage(
574596
label: labels.MetricName,
575597
resp: []string{lastSeriesInStorageName, lastSeriesInIngesterBlocksName, firstSeriesInIngesterHeadName},
576598
},
599+
{
600+
label: labels.MetricName,
601+
resp: []string{lastSeriesInStorageName},
602+
matches: []string{lastSeriesInStorageName},
603+
},
604+
{
605+
label: labels.MetricName,
606+
resp: []string{lastSeriesInIngesterBlocksName},
607+
matches: []string{lastSeriesInIngesterBlocksName},
608+
},
609+
{
610+
label: labels.MetricName,
611+
resp: []string{lastSeriesInStorageName, lastSeriesInIngesterBlocksName},
612+
matches: []string{lastSeriesInStorageName, lastSeriesInIngesterBlocksName},
613+
},
577614
},
578615
labelNames: []string{labels.MetricName, lastSeriesInStorageName, lastSeriesInIngesterBlocksName, firstSeriesInIngesterHeadName},
579616
},
@@ -601,6 +638,16 @@ func testMetadataQueriesWithBlocksStorage(
601638
label: labels.MetricName,
602639
resp: []string{lastSeriesInStorageName, firstSeriesInIngesterHeadName},
603640
},
641+
{
642+
label: labels.MetricName,
643+
resp: []string{lastSeriesInStorageName},
644+
matches: []string{lastSeriesInStorageName},
645+
},
646+
{
647+
label: labels.MetricName,
648+
resp: []string{firstSeriesInIngesterHeadName},
649+
matches: []string{firstSeriesInIngesterHeadName},
650+
},
604651
},
605652
labelNames: []string{labels.MetricName, lastSeriesInStorageName, firstSeriesInIngesterHeadName},
606653
},
@@ -620,7 +667,7 @@ func testMetadataQueriesWithBlocksStorage(
620667
}
621668

622669
for _, lvt := range tc.labelValuesTests {
623-
labelsRes, err := c.LabelValues(lvt.label, tc.from, tc.to)
670+
labelsRes, err := c.LabelValues(lvt.label, tc.from, tc.to, lvt.matches)
624671
require.NoError(t, err)
625672
exp := model.LabelValues{}
626673
for _, val := range lvt.resp {

pkg/querier/blocks_store_queryable.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -875,11 +875,11 @@ func createLabelNamesRequest(minT, maxT int64, blockIDs []ulid.ULID) (*storepb.L
875875
}
876876

877877
func createLabelValuesRequest(minT, maxT int64, label string, blockIDs []ulid.ULID, matchers ...*labels.Matcher) (*storepb.LabelValuesRequest, error) {
878-
// TODO(replay): add matchers to LabelValuesRequest once it has that property
879878
req := &storepb.LabelValuesRequest{
880-
Start: minT,
881-
End: maxT,
882-
Label: label,
879+
Start: minT,
880+
End: maxT,
881+
Label: label,
882+
Matchers: convertMatchersToLabelMatcher(matchers),
883883
}
884884

885885
// Selectively query only specific blocks.

vendor/github.com/thanos-io/thanos/pkg/block/indexheader/header.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)