Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion cmd/thanos/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,8 @@ func registerQuery(app *extkingpin.App) {
enforceTenancy := cmd.Flag("query.enforce-tenancy", "Enforce tenancy on Query APIs. Responses are returned only if the label value of the configured tenant-label-name and the value of the tenant header matches.").Default("false").Bool()
tenantLabel := cmd.Flag("query.tenant-label-name", "Label name to use when enforcing tenancy (if --query.enforce-tenancy is enabled).").Default(tenancy.DefaultTenantLabel).String()

rewriteAggregationLabelTo := cmd.Flag("query.aggregation-label-value-override", "The value override for __rollup__ label for aggregated metrics. If set to x, all queries on aggregated metrics will have a __rollup__=x matcher. Leave empty to disable this behavior. Default is empty.").Default("").String()
rewriteAggregationLabelStrategy := cmd.Flag("query.aggregation-label-strategy", "The strategy to use when rewriting aggregation labels. Used during aggregator migration only.").Default(string(query.NoopLabelRewriter)).Hidden().Enum(string(query.NoopLabelRewriter), string(query.UpsertLabelRewriter), string(query.InsertOnlyLabelRewriter))
rewriteAggregationLabelTo := cmd.Flag("query.aggregation-label-value-override", "The value override for aggregation label. If set to x, all queries on aggregated metrics will have a `__agg_rule_type__=x` matcher. If empty, this behavior is disabled. Default is empty.").Hidden().Default("").String()

var storeRateLimits store.SeriesSelectLimits
storeRateLimits.RegisterFlags(cmd)
Expand Down Expand Up @@ -386,6 +387,7 @@ func registerQuery(app *extkingpin.App) {
*enforceTenancy,
*tenantLabel,
*enableGroupReplicaPartialStrategy,
*rewriteAggregationLabelStrategy,
*rewriteAggregationLabelTo,
)
})
Expand Down Expand Up @@ -471,6 +473,7 @@ func runQuery(
enforceTenancy bool,
tenantLabel string,
groupReplicaPartialResponseStrategy bool,
rewriteAggregationLabelStrategy string,
rewriteAggregationLabelTo string,
) error {
comp := component.Query
Expand Down Expand Up @@ -601,6 +604,7 @@ func runQuery(
opts := query.Options{
GroupReplicaPartialResponseStrategy: groupReplicaPartialResponseStrategy,
DeduplicationFunc: queryDeduplicationFunc,
RewriteAggregationLabelStrategy: rewriteAggregationLabelStrategy,
RewriteAggregationLabelTo: rewriteAggregationLabelTo,
}
level.Info(logger).Log("msg", "databricks querier features", "opts", fmt.Sprintf("%+v", opts))
Expand Down
7 changes: 5 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ require (
)

require (
capnproto.org/go/capnp/v3 v3.0.1-alpha.2.0.20240830165715-46ccd63a72af
capnproto.org/go/capnp/v3 v3.0.0-alpha.30
github.com/Azure/azure-sdk-for-go/sdk/storage/azdatalake v1.4.0
github.com/cortexproject/promqlsmith v0.0.0-20240506042652-6cfdd9739a5e
github.com/grpc-ecosystem/go-grpc-middleware/providers/prometheus v1.0.1
Expand All @@ -135,7 +135,6 @@ require (
github.com/HdrHistogram/hdrhistogram-go v1.1.2 // indirect
github.com/bboreham/go-loser v0.0.0-20230920113527-fcc2c21820a3 // indirect
github.com/cilium/ebpf v0.11.0 // indirect
github.com/colega/zeropool v0.0.0-20230505084239-6fb4a4f75381 // indirect
github.com/containerd/cgroups/v3 v3.0.3 // indirect
github.com/docker/go-units v0.5.0 // indirect
github.com/elastic/go-licenser v0.3.1 // indirect
Expand Down Expand Up @@ -169,6 +168,7 @@ require (
k8s.io/client-go v0.31.0 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
zenhack.net/go/util v0.0.0-20230414204917-531d38494cf5 // indirect
)

require (
Expand Down Expand Up @@ -289,6 +289,9 @@ replace (
// Required by Cortex https://github.com/cortexproject/cortex/pull/3051.
github.com/bradfitz/gomemcache => github.com/themihai/gomemcache v0.0.0-20180902122335-24332e2d58ab

// Use Prometheus fork to include some fixes
github.com/prometheus/prometheus => github.com/yuchen-db/prometheus v0.0.0-20250424212119-34c3b01ad3f9

// Pin kuberesolver/v5 to support new grpc version. Need to upgrade kuberesolver version on weaveworks/common.
github.com/sercand/kuberesolver/v4 => github.com/sercand/kuberesolver/v5 v5.1.1

Expand Down
22 changes: 10 additions & 12 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
capnproto.org/go/capnp/v3 v3.0.1-alpha.2.0.20240830165715-46ccd63a72af h1:A5wxH0ZidOtYYUGjhtBaRuB87M73bGfc06uWB8sHpg0=
capnproto.org/go/capnp/v3 v3.0.1-alpha.2.0.20240830165715-46ccd63a72af/go.mod h1:2vT5D2dtG8sJGEoEKU17e+j7shdaYp1Myl8X03B3hmc=
capnproto.org/go/capnp/v3 v3.0.0-alpha.30 h1:iABQan/YiHFCgSXym5aNj27osapnEgAk4WaWYqb4sQM=
capnproto.org/go/capnp/v3 v3.0.0-alpha.30/go.mod h1:+ysMHvOh1EWNOyorxJWs1omhRFiDoKxKkWQACp54jKM=
cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw=
cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU=
cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU=
Expand Down Expand Up @@ -1506,8 +1506,6 @@ github.com/cncf/xds/go v0.0.0-20231128003011-0fa0005c9caa/go.mod h1:x/1Gn8zydmfq
github.com/cncf/xds/go v0.0.0-20240423153145-555b57ec207b h1:ga8SEFjZ60pxLcmhnThWgvH2wg8376yUJmPhEH4H3kw=
github.com/cncf/xds/go v0.0.0-20240423153145-555b57ec207b/go.mod h1:W+zGtBO5Y1IgJhy4+A9GOqVhqLpfZi+vwmdNXUehLA8=
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
github.com/colega/zeropool v0.0.0-20230505084239-6fb4a4f75381 h1:d5EKgQfRQvO97jnISfR89AiCCCJMwMFoSxUiU0OGCRU=
github.com/colega/zeropool v0.0.0-20230505084239-6fb4a4f75381/go.mod h1:OU76gHeRo8xrzGJU3F3I1CqX1ekM8dfJw0+wPeMwnp0=
github.com/containerd/cgroups/v3 v3.0.3 h1:S5ByHZ/h9PMe5IOQoN7E+nMc2UcLEM/V48DGDJ9kip0=
github.com/containerd/cgroups/v3 v3.0.3/go.mod h1:8HBe7V3aWGLFPd/k03swSIsGjZhHI2WzJmticMgVuz0=
github.com/coreos/go-systemd/v22 v22.4.0/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc=
Expand Down Expand Up @@ -2116,8 +2114,8 @@ github.com/ovh/go-ovh v1.6.0 h1:ixLOwxQdzYDx296sXcgS35TOPEahJkpjMGtzPadCjQI=
github.com/ovh/go-ovh v1.6.0/go.mod h1:cTVDnl94z4tl8pP1uZ/8jlVxntjSIf09bNcQ5TJSC7c=
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58 h1:onHthvaw9LFnH4t2DcNVpwGmV9E1BkGknEliJkfwQj0=
github.com/pbnjay/memory v0.0.0-20210728143218-7b4eea64cf58/go.mod h1:DXv8WO4yhMYhSNPKjeNKa5WY9YCIEBRbNzFFPJbWO6Y=
github.com/philhofer/fwd v1.1.2 h1:bnDivRJ1EWPjUIRXV5KfORO897HTbpFAQddBdE8t7Gw=
github.com/philhofer/fwd v1.1.2/go.mod h1:qkPdfjR2SIEbspLqpe1tO4n5yICnr2DY7mqEx2tUTP0=
github.com/philhofer/fwd v1.1.1 h1:GdGcTjf5RNAxwS4QLsiMzJYj5KEvPJD3Abr261yRQXQ=
github.com/philhofer/fwd v1.1.1/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU=
github.com/phpdave11/gofpdf v1.4.2/go.mod h1:zpO6xFn9yxo3YLyMvW8HcKWVdbNqgIfOOp2dXMnm1mY=
github.com/phpdave11/gofpdi v1.0.12/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI=
github.com/phpdave11/gofpdi v1.0.13/go.mod h1:vBmVV0Do6hSBHC8uKUQ71JGW+ZGQq74llk/7bXwjDoI=
Expand Down Expand Up @@ -2191,8 +2189,6 @@ github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0ua
github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY=
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
github.com/prometheus/prometheus v0.55.1-0.20241102120812-a6fd22b9d2c8 h1:hCxAh6+hxwy7dqUPE5ndnilMeCWrqQkJVjPDXtiYRVo=
github.com/prometheus/prometheus v0.55.1-0.20241102120812-a6fd22b9d2c8/go.mod h1:GGS7QlWKCqCbcEzWsVahYIfQwiGhcExkarHyLJTsv6I=
github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E=
github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw=
github.com/redis/rueidis v1.0.45-alpha.1 h1:69Bu1l7gVC/qDYuGGwMwGg2rjOjSyxESol/Zila62gY=
Expand Down Expand Up @@ -2276,10 +2272,8 @@ github.com/thanos-io/promql-engine v0.0.0-20241106100125-097e6e9f425a h1:BhWU58V
github.com/thanos-io/promql-engine v0.0.0-20241106100125-097e6e9f425a/go.mod h1:wx0JlRZtsB2S10JYUgeg5GqLfMxw31SzArP+28yyE00=
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/tinylib/msgp v1.1.9 h1:SHf3yoO2sGA0veCJeCBYLHuttAVFHGm2RHgNodW7wQU=
github.com/tinylib/msgp v1.1.9/go.mod h1:BCXGB54lDD8qUEPmiG0cQQUANC4IUQyB2ItS2UDlO/k=
github.com/tj/assert v0.0.3 h1:Df/BlaZ20mq6kuai7f5z2TvPFiwC3xaWJSDQNiIS3Rk=
github.com/tj/assert v0.0.3/go.mod h1:Ne6X72Q+TB1AteidzQncjw9PabbMp4PBMZ1k+vd1Pvk=
github.com/tinylib/msgp v1.1.5 h1:2gXmtWueD2HefZHQe1QOy9HVzmFrLOVvsXwXBQ0ayy0=
github.com/tinylib/msgp v1.1.5/go.mod h1:eQsjooMTnV42mHu917E26IogZ2930nFyBQdofk10Udg=
github.com/tklauser/go-sysconf v0.3.4/go.mod h1:Cl2c8ZRWfHD5IrfHo9VN+FX9kCFjIOyVklgXycLB6ek=
github.com/tklauser/go-sysconf v0.3.10 h1:IJ1AZGZRWbY8T5Vfk04D9WOA5WSejdflXxP03OUqALw=
github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk=
Expand All @@ -2301,6 +2295,8 @@ github.com/weaveworks/promrus v1.2.0/go.mod h1:SaE82+OJ91yqjrE1rsvBWVzNZKcHYFtMU
github.com/x448/float16 v0.8.4 h1:qLwI1I70+NjRFUR3zs1JPUCgaCXSh3SW62uAKT1mSBM=
github.com/x448/float16 v0.8.4/go.mod h1:14CWIYCyZA/cWjXOioeEpHeN/83MdbZDRQHoFcYsOfg=
github.com/xhit/go-str2duration v1.2.0/go.mod h1:3cPSlfZlUHVlneIVfePFWcJZsuwf+P1v2SRTV4cUmp4=
github.com/yuchen-db/prometheus v0.0.0-20250424212119-34c3b01ad3f9 h1:hNgEopLMPL0Ol+MOif0rqebCYAtqiBeR54lmt+GyhsA=
github.com/yuchen-db/prometheus v0.0.0-20250424212119-34c3b01ad3f9/go.mod h1:GGS7QlWKCqCbcEzWsVahYIfQwiGhcExkarHyLJTsv6I=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down Expand Up @@ -3350,3 +3346,5 @@ sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+s
sigs.k8s.io/structured-merge-diff/v4 v4.4.1/go.mod h1:N8hJocpFajUSSeSJ9bOZ77VzejKZaXsTtZo4/u7Io08=
sigs.k8s.io/yaml v1.4.0 h1:Mk1wCc2gy/F0THH0TAp1QYyJNzRm2KCLy3o5ASXVI5E=
sigs.k8s.io/yaml v1.4.0/go.mod h1:Ejl7/uTz7PSA4eKMyQCUTnhZYNmLIl+5c2lQPGR2BPY=
zenhack.net/go/util v0.0.0-20230414204917-531d38494cf5 h1:yksDCGMVzyn3vlyf0GZ3huiF5FFaMGQpQ3UJvR0EoGA=
zenhack.net/go/util v0.0.0-20230414204917-531d38494cf5/go.mod h1:1LtNdPAs8WH+BTcQiZAOo2MIKD/5jyK/u7sZ9ZPe5SE=
40 changes: 30 additions & 10 deletions pkg/query/aggregation_label_rewriter.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,26 @@ import (
"github.com/prometheus/prometheus/model/labels"
)

// RewriterStrategy defines the strategy used by the AggregationLabelRewriter.
type RewriterStrategy string

const (
aggregationLabelName = "__rollup__"
// NoopLabelRewriter is a no-op strategy that basically disables the rewriter.
NoopLabelRewriter RewriterStrategy = "noop"
// UpsertLabelRewriter is a strategy that upserts the aggregation label.
UpsertLabelRewriter RewriterStrategy = "upsert"
// InsertOnlyLabelRewriter is a strategy that only inserts the aggregation label if it does not exist.
InsertOnlyLabelRewriter RewriterStrategy = "insert-only"
)

type AggregationLabelRewriter struct {
logger log.Logger
metrics *aggregationLabelRewriterMetrics
const (
aggregationLabelName = "__agg_rule_type__"
)

enabled bool
type AggregationLabelRewriter struct {
logger log.Logger
metrics *aggregationLabelRewriterMetrics
strategy RewriterStrategy
desiredLabelValue string
}

Expand Down Expand Up @@ -70,24 +81,27 @@ func newAggregationLabelRewriterMetrics(reg prometheus.Registerer, desiredLabelV

func NewNopAggregationLabelRewriter() *AggregationLabelRewriter {
return &AggregationLabelRewriter{
enabled: false,
strategy: NoopLabelRewriter,
}
}

func NewAggregationLabelRewriter(logger log.Logger, reg prometheus.Registerer, desiredLabelValue string) *AggregationLabelRewriter {
func NewAggregationLabelRewriter(logger log.Logger, reg prometheus.Registerer, strategy RewriterStrategy, desiredLabelValue string) *AggregationLabelRewriter {
if logger == nil {
logger = log.NewNopLogger()
}
if desiredLabelValue == "" {
strategy = NoopLabelRewriter
}
return &AggregationLabelRewriter{
enabled: desiredLabelValue != "",
strategy: strategy,
logger: logger,
metrics: newAggregationLabelRewriterMetrics(reg, desiredLabelValue),
desiredLabelValue: desiredLabelValue,
}
}

func (a *AggregationLabelRewriter) Rewrite(ms []*labels.Matcher) []*labels.Matcher {
if !a.enabled {
if a.strategy == NoopLabelRewriter {
return ms
}

Expand Down Expand Up @@ -123,12 +137,18 @@ func (a *AggregationLabelRewriter) Rewrite(ms []*labels.Matcher) []*labels.Match
aggregationLabelIndex = i
}
}

if aggregationLabelMatcher != nil && a.strategy == InsertOnlyLabelRewriter {
needsRewrite = false
skipReason = "insert-only"
}

// After the for loop, if needsRewrite is false, no need to do anything
// but if it is true, we either append or modify an aggregation label
if needsRewrite {
newMatcher := &labels.Matcher{
Name: aggregationLabelName,
Type: labels.MatchEqual,
Type: labels.MatchRegexp,
Value: a.desiredLabelValue,
}
if aggregationLabelMatcher != nil {
Expand Down
55 changes: 51 additions & 4 deletions pkg/query/aggregation_label_rewriter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func TestAggregationLabelRewriter_Rewrite(t *testing.T) {
for _, tc := range []struct {
name string
desiredLabelValue string // Empty means disabled
strategy RewriterStrategy
inputMatchers []*labels.Matcher
expectedMatchers []*labels.Matcher
expectedSkipCount float64
Expand All @@ -25,7 +26,19 @@ func TestAggregationLabelRewriter_Rewrite(t *testing.T) {
}{
{
name: "disabled rewriter should not modify label matchers",
desiredLabelValue: "v1",
strategy: NoopLabelRewriter,
inputMatchers: []*labels.Matcher{
labels.MustNewMatcher(labels.MatchEqual, "__name__", "test:sum"),
},
expectedMatchers: []*labels.Matcher{
labels.MustNewMatcher(labels.MatchEqual, "__name__", "test:sum"),
},
},
{
name: "no desired label value makes a disabled rewriter and should not modify label matchers",
desiredLabelValue: "",
strategy: UpsertLabelRewriter,
inputMatchers: []*labels.Matcher{
labels.MustNewMatcher(labels.MatchEqual, "__name__", "test:sum"),
},
Expand All @@ -36,31 +49,48 @@ func TestAggregationLabelRewriter_Rewrite(t *testing.T) {
{
name: "should add label for aggregated metric if no existing aggregation label",
desiredLabelValue: "5m",
strategy: UpsertLabelRewriter,
inputMatchers: []*labels.Matcher{
labels.MustNewMatcher(labels.MatchEqual, "__name__", "test:sum"),
},
expectedMatchers: []*labels.Matcher{
labels.MustNewMatcher(labels.MatchEqual, "__name__", "test:sum"),
labels.MustNewMatcher(labels.MatchEqual, "__rollup__", "5m"),
labels.MustNewMatcher(labels.MatchRegexp, aggregationLabelName, "5m"),
},
expectedAddCount: 1,
},
{
name: "should rewrite existing aggregation label for aggregated metric",
name: "should rewrite existing equal aggregation label for aggregated metric",
desiredLabelValue: "5m",
strategy: UpsertLabelRewriter,
inputMatchers: []*labels.Matcher{
labels.MustNewMatcher(labels.MatchEqual, "__name__", "test:sum"),
labels.MustNewMatcher(labels.MatchEqual, aggregationLabelName, "1h"),
},
expectedMatchers: []*labels.Matcher{
labels.MustNewMatcher(labels.MatchEqual, "__name__", "test:sum"),
labels.MustNewMatcher(labels.MatchRegexp, aggregationLabelName, "5m"),
},
expectedRewriteMap: map[string]float64{"1h": 1},
},
{
name: "should rewrite existing regex aggregation label for aggregated metric",
desiredLabelValue: "5m",
strategy: UpsertLabelRewriter,
inputMatchers: []*labels.Matcher{
labels.MustNewMatcher(labels.MatchEqual, "__name__", "test:sum"),
labels.MustNewMatcher(labels.MatchEqual, "__rollup__", "1h"),
labels.MustNewMatcher(labels.MatchRegexp, aggregationLabelName, "1h"),
},
expectedMatchers: []*labels.Matcher{
labels.MustNewMatcher(labels.MatchEqual, "__name__", "test:sum"),
labels.MustNewMatcher(labels.MatchEqual, "__rollup__", "5m"),
labels.MustNewMatcher(labels.MatchRegexp, aggregationLabelName, "5m"),
},
expectedRewriteMap: map[string]float64{"1h": 1},
},
{
name: "should skip non-aggregated metric",
desiredLabelValue: "5m",
strategy: UpsertLabelRewriter,
inputMatchers: []*labels.Matcher{
labels.MustNewMatcher(labels.MatchEqual, "__name__", "test_metric"),
},
Expand All @@ -72,6 +102,7 @@ func TestAggregationLabelRewriter_Rewrite(t *testing.T) {
{
name: "should skip non-equal name matcher",
desiredLabelValue: "5m",
strategy: UpsertLabelRewriter,
inputMatchers: []*labels.Matcher{
labels.MustNewMatcher(labels.MatchRegexp, "__name__", "test:sum"),
},
Expand All @@ -83,6 +114,7 @@ func TestAggregationLabelRewriter_Rewrite(t *testing.T) {
{
name: "should skip when no name matcher",
desiredLabelValue: "5m",
strategy: UpsertLabelRewriter,
inputMatchers: []*labels.Matcher{
labels.MustNewMatcher(labels.MatchEqual, "job", "prometheus"),
},
Expand All @@ -91,12 +123,27 @@ func TestAggregationLabelRewriter_Rewrite(t *testing.T) {
},
expectedSkipCount: 1,
},
{
name: "if insert only, should NOT rewrite existing aggregation label for aggregated metric",
desiredLabelValue: "5m",
strategy: InsertOnlyLabelRewriter,
inputMatchers: []*labels.Matcher{
labels.MustNewMatcher(labels.MatchEqual, "__name__", "test:sum"),
labels.MustNewMatcher(labels.MatchEqual, aggregationLabelName, "1h"),
},
expectedMatchers: []*labels.Matcher{
labels.MustNewMatcher(labels.MatchEqual, "__name__", "test:sum"),
labels.MustNewMatcher(labels.MatchEqual, aggregationLabelName, "1h"),
},
expectedSkipCount: 1,
},
} {
t.Run(tc.name, func(t *testing.T) {
reg := prometheus.NewRegistry()
rewriter := NewAggregationLabelRewriter(
nil,
reg,
tc.strategy,
tc.desiredLabelValue,
)

Expand Down
2 changes: 2 additions & 0 deletions pkg/query/querier.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ type QueryableCreator func(
type Options struct {
GroupReplicaPartialResponseStrategy bool
DeduplicationFunc string
RewriteAggregationLabelStrategy string
RewriteAggregationLabelTo string
}

Expand Down Expand Up @@ -94,6 +95,7 @@ func NewQueryableCreatorWithOptions(
aggregationLabelRewriter := NewAggregationLabelRewriter(
logger,
extprom.WrapRegistererWithPrefix("aggregation_label_rewriter_", reg),
RewriterStrategy(opts.RewriteAggregationLabelStrategy),
opts.RewriteAggregationLabelTo,
)
return func(
Expand Down
15 changes: 1 addition & 14 deletions pkg/receive/writecapnp/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,22 +69,9 @@ func (r *RemoteWriteClient) writeWithReconnect(ctx context.Context, numReconnect
if err := r.connect(ctx); err != nil {
return nil, err
}
arena := capnp.SingleSegment(nil)
defer arena.Release()

result, release := r.writer.Write(ctx, func(params Writer_write_Params) error {
_, seg, err := capnp.NewMessage(arena)
if err != nil {
return err
}
wr, err := NewRootWriteRequest(seg)
if err != nil {
return err
}
if err := params.SetWr(wr); err != nil {
return err
}
wr, err = params.Wr()
wr, err := params.NewWr()
if err != nil {
return err
}
Expand Down
Loading
Loading