Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update thanos to bring sharding support for label manipulation functions #4966

Merged
merged 1 commit into from
Nov 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ require (
github.com/spf13/afero v1.6.0
github.com/stretchr/testify v1.8.0
github.com/thanos-io/objstore v0.0.0-20221006135717-79dcec7fe604
github.com/thanos-io/thanos v0.29.1-0.20221111094505-b2badad930d6
github.com/thanos-io/thanos v0.29.1-0.20221115064008-fe45cfc66b7d
github.com/uber/jaeger-client-go v2.30.0+incompatible
github.com/weaveworks/common v0.0.0-20220706100410-67d27ed40fae
go.etcd.io/etcd/api/v3 v3.5.4
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -927,8 +927,8 @@ github.com/thanos-community/galaxycache v0.0.0-20211122094458-3a32041a1f1e h1:f1
github.com/thanos-community/galaxycache v0.0.0-20211122094458-3a32041a1f1e/go.mod h1:jXcofnrSln/cLI6/dhlBxPQZEEQHVPCcFaH75M+nSzM=
github.com/thanos-io/objstore v0.0.0-20221006135717-79dcec7fe604 h1:9dceDSKKsLWNHjrMpyzK1t7eVcAZv9Dp3FX+uokUS2Y=
github.com/thanos-io/objstore v0.0.0-20221006135717-79dcec7fe604/go.mod h1:Vx5dZs9ElxEhNLnum/OgB0pNTqNdI2zdXL82BeJr3T4=
github.com/thanos-io/thanos v0.29.1-0.20221111094505-b2badad930d6 h1:8q0LB3XOhscrqEYU0g5+ekB1ZHERk8tUl1l/y9DbeXA=
github.com/thanos-io/thanos v0.29.1-0.20221111094505-b2badad930d6/go.mod h1:odqdxSO+o/UaVgNpdkYYaQUW/JpT7LByXyZmxoe6uoc=
github.com/thanos-io/thanos v0.29.1-0.20221115064008-fe45cfc66b7d h1:cfGwZH4LBrkFbQHea7HUlNDOQhILGBRPxDWjy4FhAME=
github.com/thanos-io/thanos v0.29.1-0.20221115064008-fe45cfc66b7d/go.mod h1:odqdxSO+o/UaVgNpdkYYaQUW/JpT7LByXyZmxoe6uoc=
github.com/themihai/gomemcache v0.0.0-20180902122335-24332e2d58ab h1:7ZR3hmisBWw77ZpO1/o86g+JV3VKlk3d48jopJxzTjU=
github.com/themihai/gomemcache v0.0.0-20180902122335-24332e2d58ab/go.mod h1:eheTFp954zcWZXCU8d0AT76ftsQOTo4DTqkN/h3k1MY=
github.com/tidwall/pretty v0.0.0-20180105212114-65a9db5fad51/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
Expand Down
57 changes: 53 additions & 4 deletions pkg/querier/tripperware/test_shard_by_query_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,6 @@ func TestQueryShardQuery(t *testing.T, instantQueryCodec Codec, shardedPrometheu
name: "binary aggregation with different grouping labels",
expression: `sum by (pod) (http_requests_total{code="400"}) / sum by (cluster) (http_requests_total)`,
},
{
name: "binary expression with vector matching and label_replace",
expression: `http_requests_total{code="400"} / on (pod) label_replace(metric, "dst_label", "$1", "src_label", "re")`,
},
{
name: "multiple binary expressions",
expression: `(http_requests_total{code="400"} + http_requests_total{code="500"}) / http_requests_total`,
Expand All @@ -86,6 +82,14 @@ http_requests_total`,
name: "problematic query",
expression: `sum(a by(lanel)`,
},
{
name: "aggregate by expression with label_replace, sharding label is dynamic",
expression: `sum by (dst_label) (label_replace(metric, "dst_label", "$1", "src_label", "re"))`,
},
{
name: "aggregate by expression with label_join, sharding label is dynamic",
expression: `sum by (dst_label) (label_join(metric, "dst_label", ",", "src_label"))`,
},
}

shardableByLabels := []queries{
Expand Down Expand Up @@ -147,6 +151,36 @@ sum by (container) (
expression: "histogram_quantile(0.95, sum(rate(metric[1m])) by (le, cluster))",
shardingLabels: []string{"cluster"},
},
{
name: "aggregate by expression with label_replace, sharding label is not dynamic",
expression: `sum by (pod) (label_replace(metric, "dst_label", "$1", "src_label", "re"))`,
shardingLabels: []string{"pod"},
},
{
name: "aggregate by expression with label_join, sharding label is not dynamic",
expression: `sum by (pod) (label_join(metric, "dst_label", ",", "src_label"))`,
shardingLabels: []string{"pod"},
},
{
name: "label_join and aggregation on multiple labels. Can be sharded by the static one",
expression: `sum by (pod, dst_label) (label_join(metric, "dst_label", ",", "src_label"))`,
shardingLabels: []string{"pod"},
},
{
name: "binary expression with vector matching and label_replace",
expression: `http_requests_total{code="400"} / on (pod) label_replace(metric, "dst_label", "$1", "src_label", "re")`,
shardingLabels: []string{"pod"},
},
{
name: "nested label joins",
expression: `label_join(sum by (pod) (label_join(metric, "dst_label", ",", "src_label")), "dst_label1", ",", "dst_label")`,
shardingLabels: []string{"pod"},
},
{
name: "complex query with label_replace, binary expr and aggregations on dynamic label",
expression: `sum(sum_over_time(container_memory_working_set_bytes{container_name!="POD",container_name!="",namespace="kube-system"}[1d:5m])) by (instance, cluster) / avg(label_replace(sum(sum_over_time(kube_node_status_capacity_memory_bytes[1d:5m])) by (node, cluster), "instance", "$1", "node", "(.*)")) by (instance, cluster)`,
shardingLabels: []string{"cluster"},
},
}

// Shardable by labels instant queries with matrix response
Expand Down Expand Up @@ -197,6 +231,21 @@ sum by (container) (
http_requests_total`,
shardingLabels: []string{"cluster", "pod", model.MetricNameLabel},
},
{
name: "aggregate without expression with label_replace, sharding label is not dynamic",
expression: `sum without (dst_label) (label_replace(metric, "dst_label", "$1", "src_label", "re"))`,
shardingLabels: []string{"dst_label"},
},
{
name: "aggregate without expression with label_join, sharding label is not dynamic",
expression: `sum without (dst_label) (label_join(metric, "dst_label", ",", "src_label"))`,
shardingLabels: []string{"dst_label"},
},
{
name: "aggregate without expression with label_replace",
expression: `sum without (pod) (label_replace(metric, "dst_label", "$1", "src_label", "re"))`,
shardingLabels: []string{"pod", "dst_label"},
},
}

type testCase struct {
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 56 additions & 24 deletions vendor/github.com/thanos-io/thanos/pkg/querysharding/analyzer.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion vendor/modules.txt

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.