From 3cf01e87dd11bc8f126e213e2cd479a6cb5910c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20=C3=81guas?= Date: Tue, 14 Feb 2023 10:06:41 +0100 Subject: [PATCH 1/2] Deduplicate metamonitoring queries (#6121) * Deduplicate metamonitoring queries Signed-off-by: Andre Baptista Aguas Signed-off-by: Andre Baptista Aguas * Update CHANGELOG Signed-off-by: Andre Baptista Aguas Signed-off-by: Andre Baptista Aguas * do not remove empty line from CHANGELOG Signed-off-by: Andre Baptista Aguas --------- Signed-off-by: Andre Baptista Aguas Signed-off-by: Andre Baptista Aguas Co-authored-by: Andre Baptista Aguas --- CHANGELOG.md | 1 + pkg/receive/head_series_limiter.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index abc3d2ad4c..99ea95e825 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,7 @@ We use *breaking :warning:* to mark changes that are not backward compatible (re - [#6082](https://github.com/thanos-io/thanos/pull/6082) Store: Don't error when no stores are matched. - [#6098](https://github.com/thanos-io/thanos/pull/6098) Cache/Redis: upgrade `rueidis` to v0.0.93 to fix potential panic when the client-side caching is disabled. - [#6103](https://github.com/thanos-io/thanos/pull/6103) Mixins(Rule): Fix query for long rule evaluations. +- [#6121](https://github.com/thanos-io/thanos/pull/6121) Receive: Deduplicate metamonitoring queries. ### Changed diff --git a/pkg/receive/head_series_limiter.go b/pkg/receive/head_series_limiter.go index 746b92d990..c088dc6495 100644 --- a/pkg/receive/head_series_limiter.go +++ b/pkg/receive/head_series_limiter.go @@ -106,7 +106,7 @@ func NewHeadSeriesLimit(w WriteLimitsConfig, registerer prometheus.Registerer, l func (h *headSeriesLimit) QueryMetaMonitoring(ctx context.Context) error { c := promclient.NewWithTracingClient(h.logger, h.metaMonitoringClient, httpconfig.ThanosUserAgent) - vectorRes, _, err := c.QueryInstant(ctx, h.metaMonitoringURL, h.metaMonitoringQuery, time.Now(), promclient.QueryOptions{}) + vectorRes, _, err := c.QueryInstant(ctx, h.metaMonitoringURL, h.metaMonitoringQuery, time.Now(), promclient.QueryOptions{Deduplicate: true}) if err != nil { h.metaMonitoringErr.Inc() return err From 1e16ba53c52add8c4d28d64fab8f091f091a8472 Mon Sep 17 00:00:00 2001 From: Filip Petkovski Date: Tue, 14 Feb 2023 11:13:23 +0100 Subject: [PATCH 2/2] Update prometheus to 0.42.0 (#6119) * Update prometheus to 0.42.0 Signed-off-by: Filip Petkovski * Change type in e2e tests Signed-off-by: Filip Petkovski * Fix lint Signed-off-by: Filip Petkovski * Do not reuse any chunk iterators Signed-off-by: Filip Petkovski * Make chunkenc.Iterator an unnamed parameter Signed-off-by: Filip Petkovski --------- Signed-off-by: Filip Petkovski --- go.mod | 26 ++++---- go.sum | 70 ++++++++++---------- internal/cortex/querier/series/series_set.go | 2 +- pkg/alert/alert.go | 5 +- pkg/block/fetcher.go | 2 +- pkg/block/index.go | 12 ++-- pkg/block/index_test.go | 5 +- pkg/compact/downsample/downsample.go | 7 +- pkg/compact/downsample/downsample_test.go | 11 ++- pkg/compactv2/chunk_series_set.go | 10 ++- pkg/compactv2/compactor.go | 2 +- pkg/compactv2/compactor_test.go | 5 +- pkg/compactv2/modifiers.go | 18 ++--- pkg/dedup/chunk_iter.go | 12 ++-- pkg/dedup/chunk_iter_test.go | 41 ++++++------ pkg/dedup/iter.go | 50 +++++++------- pkg/dedup/iter_test.go | 4 +- pkg/query/iter.go | 2 +- pkg/query/querier_test.go | 3 +- pkg/query/query_bench_test.go | 5 +- pkg/receive/handler.go | 5 +- pkg/receive/handler_test.go | 3 +- pkg/receive/writer.go | 2 +- pkg/rules/manager_test.go | 3 +- pkg/store/storepb/testutil/series.go | 6 +- pkg/store/tsdb.go | 2 +- test/e2e/native_histograms_test.go | 3 +- 27 files changed, 170 insertions(+), 146 deletions(-) diff --git a/go.mod b/go.mod index 3f0d951488..da28015b29 100644 --- a/go.mod +++ b/go.mod @@ -62,13 +62,13 @@ require ( github.com/prometheus/alertmanager v0.25.0 github.com/prometheus/client_golang v1.14.0 github.com/prometheus/client_model v0.3.0 - github.com/prometheus/common v0.39.1-0.20230110141620-846591a16635 + github.com/prometheus/common v0.39.1-0.20230202092144-f9c1994be032 github.com/prometheus/exporter-toolkit v0.8.2 // Prometheus maps version 2.x.y to tags v0.x.y. - github.com/prometheus/prometheus v0.41.0 + github.com/prometheus/prometheus v0.42.0 github.com/sony/gobreaker v0.5.0 github.com/stretchr/testify v1.8.1 - github.com/thanos-community/promql-engine v0.0.0-20230124070417-9e293186b7e4 + github.com/thanos-community/promql-engine v0.0.0-20230213101639-ab3d8dcea3f3 github.com/thanos-io/objstore v0.0.0-20230201072718-11ffbc490204 github.com/uber/jaeger-client-go v2.30.0+incompatible github.com/uber/jaeger-lib v2.4.1+incompatible // indirect @@ -89,9 +89,9 @@ require ( golang.org/x/sync v0.1.0 golang.org/x/text v0.6.0 golang.org/x/time v0.3.0 - google.golang.org/api v0.104.0 // indirect + google.golang.org/api v0.108.0 // indirect google.golang.org/genproto v0.0.0-20230131230820-1c016267d619 // indirect - google.golang.org/grpc v1.52.0 + google.golang.org/grpc v1.52.1 google.golang.org/grpc/examples v0.0.0-20211119005141-f45e61797429 gopkg.in/alecthomas/kingpin.v2 v2.2.6 gopkg.in/fsnotify.v1 v1.4.7 @@ -106,7 +106,7 @@ require ( require ( cloud.google.com/go v0.105.0 // indirect - cloud.google.com/go/compute v1.13.0 // indirect + cloud.google.com/go/compute v1.14.0 // indirect cloud.google.com/go/iam v0.8.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/azcore v1.2.0 // indirect github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.2.0 // indirect @@ -123,13 +123,13 @@ require ( require ( go.opentelemetry.io/contrib/propagators/autoprop v0.38.0 go4.org/intern v0.0.0-20220617035311-6925f38cc365 - golang.org/x/exp v0.0.0-20221212164502-fae10dda9338 + golang.org/x/exp v0.0.0-20230124195608-d38c7dcee874 ) require go4.org/unsafe/assume-no-moving-gc v0.0.0-20220617031537-928513b29760 // indirect require ( - cloud.google.com/go/compute/metadata v0.2.2 // indirect + cloud.google.com/go/compute/metadata v0.2.3 // indirect github.com/GoogleCloudPlatform/opentelemetry-operations-go/internal/resourcemapping v0.32.3 // indirect github.com/OneOfOne/xxhash v1.2.6 // indirect github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect @@ -137,7 +137,7 @@ require ( github.com/aliyun/aliyun-oss-go-sdk v2.2.2+incompatible // indirect github.com/armon/go-radix v1.0.0 // indirect github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d // indirect - github.com/aws/aws-sdk-go v1.44.159 // indirect + github.com/aws/aws-sdk-go v1.44.187 // indirect github.com/aws/aws-sdk-go-v2 v1.16.0 // indirect github.com/aws/aws-sdk-go-v2/config v1.15.1 // indirect github.com/aws/aws-sdk-go-v2/credentials v1.11.0 // indirect @@ -183,9 +183,9 @@ require ( github.com/golang-jwt/jwt/v4 v4.4.3 // indirect github.com/google/go-cmp v0.5.9 // indirect github.com/google/go-querystring v1.1.0 // indirect - github.com/google/pprof v0.0.0-20221212185716-aee1124e3a93 // indirect + github.com/google/pprof v0.0.0-20230111200839-76d1ae5aea2b // indirect github.com/google/uuid v1.3.0 // indirect - github.com/googleapis/enterprise-certificate-proxy v0.2.0 // indirect + github.com/googleapis/enterprise-certificate-proxy v0.2.1 // indirect github.com/googleapis/gax-go/v2 v2.7.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.11.1 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect @@ -240,9 +240,9 @@ require ( go.opentelemetry.io/proto/otlp v0.19.0 // indirect go.uber.org/multierr v1.9.0 // indirect golang.org/x/mod v0.7.0 // indirect - golang.org/x/oauth2 v0.3.0 // indirect + golang.org/x/oauth2 v0.4.0 // indirect golang.org/x/sys v0.5.0 // indirect - golang.org/x/tools v0.4.0 // indirect + golang.org/x/tools v0.5.0 // indirect golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect gonum.org/v1/gonum v0.12.0 // indirect google.golang.org/appengine v1.6.7 // indirect diff --git a/go.sum b/go.sum index e6ed2bac62..45626fed2d 100644 --- a/go.sum +++ b/go.sum @@ -41,10 +41,10 @@ cloud.google.com/go/compute v1.5.0/go.mod h1:9SMHyhJlzhlkJqrPAc839t2BZFTSk6Jdj6m cloud.google.com/go/compute v1.6.0/go.mod h1:T29tfhtVbq1wvAPo0E3+7vhgmkOYeXjhFvz/FMzPu0s= cloud.google.com/go/compute v1.6.1/go.mod h1:g85FgpzFvNULZ+S8AYq87axRKuf2Kh7deLqV/jJ3thU= cloud.google.com/go/compute v1.7.0/go.mod h1:435lt8av5oL9P3fv1OEzSbSUe+ybHXGMPQHHZWZxy9U= -cloud.google.com/go/compute v1.13.0 h1:AYrLkB8NPdDRslNp4Jxmzrhdr03fUAIDbiGFjLWowoU= -cloud.google.com/go/compute v1.13.0/go.mod h1:5aPTS0cUNMIc1CE546K+Th6weJUNQErARyZtRXDJ8GE= -cloud.google.com/go/compute/metadata v0.2.2 h1:aWKAjYaBaOSrpKl57+jnS/3fJRQnxL7TvR/u1VVbt6k= -cloud.google.com/go/compute/metadata v0.2.2/go.mod h1:jgHgmJd2RKBGzXqF5LR2EZMGxBkeanZ9wwa75XHJgOM= +cloud.google.com/go/compute v1.14.0 h1:hfm2+FfxVmnRlh6LpB7cg1ZNU+5edAHmW679JePztk0= +cloud.google.com/go/compute v1.14.0/go.mod h1:YfLtxrj9sU4Yxv+sXzZkyPjEyPBZfXHUvjxega5vAdo= +cloud.google.com/go/compute/metadata v0.2.3 h1:mg4jlk7mCAj6xXp9UJ4fjI9VUI5rubuGBW5aJ7UnBMY= +cloud.google.com/go/compute/metadata v0.2.3/go.mod h1:VAV5nSsACxMJvgaAuX6Pk2AawlZn8kiOGuCv6gTkwuA= cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= cloud.google.com/go/iam v0.3.0/go.mod h1:XzJPvDayI+9zsASAFO68Hk07u3z+f+JrT2xXNdp4bnY= @@ -78,7 +78,7 @@ github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.5.1 h1:BMTdr+ib5ljLa9MxT github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v0.5.1/go.mod h1:c6WvOhtmjNUWbLfOG1qxM/q0SPvQNSVJvolm+C52dIU= github.com/Azure/go-autorest v14.2.0+incompatible h1:V5VMDjClD3GiElqLWO7mz2MxNAK/vTfRHdAubSIPRgs= github.com/Azure/go-autorest/autorest v0.11.28 h1:ndAExarwr5Y+GaHE6VCaY1kyS/HwwGGyuimVhWsHOEM= -github.com/Azure/go-autorest/autorest/adal v0.9.21 h1:jjQnVFXPfekaqb8vIsv2G1lxshoW+oGv4MDlhRtnYZk= +github.com/Azure/go-autorest/autorest/adal v0.9.22 h1:/GblQdIudfEM3AWWZ0mrYJQSd7JS4S/Mbzh6F0ov0Xc= github.com/Azure/go-autorest/autorest/date v0.3.0 h1:7gUk1U5M/CQbp9WoqinNzJar+8KY+LPI6wiWrP/myHw= github.com/Azure/go-autorest/autorest/to v0.4.0 h1:oXVqrxakqqV1UZdSazDOPOLvOIz+XA683u8EctwboHk= github.com/Azure/go-autorest/autorest/validation v0.3.1 h1:AgyqjAd94fwNAoTjl/WQXg4VvFeRFpO+UhNyRXqF1ac= @@ -144,8 +144,8 @@ github.com/asaskevich/govalidator v0.0.0-20210307081110-f21760c49a8d/go.mod h1:W github.com/aws/aws-lambda-go v1.13.3/go.mod h1:4UKl9IzQMoD+QF79YdCuzCwp8VbmG4VAQwij/eHl5CU= github.com/aws/aws-sdk-go v1.27.0/go.mod h1:KmX6BPdI08NWTb3/sm4ZGu5ShLoqVDhKgpiN924inxo= github.com/aws/aws-sdk-go v1.38.35/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro= -github.com/aws/aws-sdk-go v1.44.159 h1:9odtuHAYQE9tQKyuX6ny1U1MHeH5/yzeCJi96g9H4DU= -github.com/aws/aws-sdk-go v1.44.159/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= +github.com/aws/aws-sdk-go v1.44.187 h1:D5CsRomPnlwDHJCanL2mtaLIcbhjiWxNh5j8zvaWdJA= +github.com/aws/aws-sdk-go v1.44.187/go.mod h1:aVsgQcEevwlmQ7qHE9I3h+dtQgpqhFB+i8Phjh7fkwI= github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g= github.com/aws/aws-sdk-go-v2 v1.16.0 h1:cBAYjiiexRAg9v2z9vb6IdxAa7ef4KCtjW7w7e3GxGo= github.com/aws/aws-sdk-go-v2 v1.16.0/go.mod h1:lJYcuZZEHWNIb6ugJjbQY1fykdoobWbOS7kJYb4APoI= @@ -229,11 +229,11 @@ github.com/dennwc/varint v1.0.0/go.mod h1:hnItb35rvZvJrbTALZtY/iQfDs48JKRG1RPpgz github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= -github.com/digitalocean/godo v1.91.1 h1:1o30VOCu1aC6488qBd0SkQiBeAZ35RSTvLwCA1pQMhc= +github.com/digitalocean/godo v1.95.0 h1:S48/byPKui7RHZc1wYEPfRvkcEvToADNb5I3guu95xg= github.com/dnaeon/go-vcr v1.2.0 h1:zHCHvJYTMh1N7xnV7zf1m1GPBF9Ad0Jk/whtQ1663qI= github.com/dnaeon/go-vcr v1.2.0/go.mod h1:R4UdLID7HZT3taECzJs4YgbbH6PIGXB6W/sc5OLb6RQ= github.com/docker/distribution v2.8.1+incompatible h1:Q50tZOPR6T/hjNsyc9g8/syEs6bk8XXApsHjKukMl68= -github.com/docker/docker v20.10.21+incompatible h1:UTLdBmHk3bEY+w8qeO5KttOhy6OmXWsl/FEet9Uswog= +github.com/docker/docker v20.10.23+incompatible h1:1ZQUUYAdh+oylOT85aA2ZcfRp22jmLhoaEcVEfK8dyA= github.com/docker/go-connections v0.4.0 h1:El9xVISelRB7BuFusrZozjnkIM5YnzCViNKohAFqRJQ= github.com/docker/go-units v0.5.0 h1:69rxXcBk27SvSaaxTtLh/8llcHD8vYHT7WSdRZ/jvr4= github.com/dustin/go-humanize v0.0.0-20171111073723-bb3d318650d4/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk= @@ -479,8 +479,8 @@ github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLe github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= github.com/google/pprof v0.0.0-20211214055906-6f57359322fd/go.mod h1:KgnwoLYCZ8IQu3XUZ8Nc/bM9CCZFOyjUNOSygVozoDg= -github.com/google/pprof v0.0.0-20221212185716-aee1124e3a93 h1:D5iJJZKAi0rU4e/5E58BkrnN+xeCDjAIqcm1GGxAGSI= -github.com/google/pprof v0.0.0-20221212185716-aee1124e3a93/go.mod h1:dDKJzRmX4S37WGHujM7tX//fmj1uioxKzKxz3lo4HJo= +github.com/google/pprof v0.0.0-20230111200839-76d1ae5aea2b h1:8htHrh2bw9c7Idkb7YNac+ZpTqLMjRpI+FWu51ltaQc= +github.com/google/pprof v0.0.0-20230111200839-76d1ae5aea2b/go.mod h1:dDKJzRmX4S37WGHujM7tX//fmj1uioxKzKxz3lo4HJo= github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.0.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -488,8 +488,8 @@ github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+ github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/googleapis/enterprise-certificate-proxy v0.0.0-20220520183353-fd19c99a87aa/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= -github.com/googleapis/enterprise-certificate-proxy v0.2.0 h1:y8Yozv7SZtlU//QXbezB6QkpuE6jMD2/gfzk4AftXjs= -github.com/googleapis/enterprise-certificate-proxy v0.2.0/go.mod h1:8C0jb7/mgJe/9KK8Lm7X9ctZC2t60YyIpYEI16jx0Qg= +github.com/googleapis/enterprise-certificate-proxy v0.2.1 h1:RY7tHKZcRlk788d5WSo/e83gOyyy742E8GSs771ySpg= +github.com/googleapis/enterprise-certificate-proxy v0.2.1/go.mod h1:AwSRAtLfXpU5Nm3pW+v7rGDHp09LsPtGY9MduiEsR9k= github.com/googleapis/gax-go v2.0.2+incompatible h1:silFMLAnr330+NRuag/VjIGF7TLp/LBrV2CJKFLWEww= github.com/googleapis/gax-go v2.0.2+incompatible/go.mod h1:SFVmujtThgffbyetf+mdk2eWhX2bMyUtNHzFKcPA9HY= github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= @@ -535,6 +535,7 @@ github.com/hashicorp/consul/api v1.3.0/go.mod h1:MmDNSzIMUjNpY/mQ398R4bk2FnqQLoP github.com/hashicorp/consul/api v1.18.0 h1:R7PPNzTCeN6VuQNDwwhZWJvzCtGSrNpJqfb22h3yH9g= github.com/hashicorp/consul/sdk v0.3.0/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= github.com/hashicorp/cronexpr v1.1.1 h1:NJZDd87hGXjoZBdvyCF9mX4DCq5Wy7+A/w+A7q0wn6c= +github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= @@ -544,6 +545,7 @@ github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjh github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= github.com/hashicorp/go-retryablehttp v0.7.1 h1:sUiuQAnLlbvmExtFQs72iFW/HXeUn8Z1aJLQ4LJJbTQ= github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= @@ -561,10 +563,10 @@ github.com/hashicorp/golang-lru v0.6.0/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uG github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= -github.com/hashicorp/nomad/api v0.0.0-20221214074818-7dbbf6bc584d h1:kEWrUx7mld3c6HRcO2KhfD1MYBkofuZfEfDwCRQ9aMU= +github.com/hashicorp/nomad/api v0.0.0-20230124213148-69fd1a0e4bf7 h1:XOdd3JHyeQnBRxotBo9ibxBFiYGuYhQU25s/YeV2cTU= github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= github.com/hashicorp/serf v0.10.1 h1:Z1H2J60yRKvfDYAOZLd2MU0ND4AH/WDz7xYHDWQsIPY= -github.com/hetznercloud/hcloud-go v1.38.0 h1:K6Pd/mMdcLfBhvwG39qyAaacp4pCS3dKa8gChmLKxLg= +github.com/hetznercloud/hcloud-go v1.39.0 h1:RUlzI458nGnPR6dlcZlrsGXYC1hQlFbKdm8tVtEQQB0= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/hudl/fargo v1.3.0/go.mod h1:y3CKSmjA+wD2gak7sUSXTAoopbhU08POFhmITJgmKTg= github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= @@ -637,7 +639,7 @@ github.com/lightstep/lightstep-tracer-common/golang/gogo v0.0.0-20210210170715-a github.com/lightstep/lightstep-tracer-go v0.18.1/go.mod h1:jlF1pusYV4pidLvZ+XD0UBX0ZE6WURAspgAczcDHrL4= github.com/lightstep/lightstep-tracer-go v0.25.0 h1:sGVnz8h3jTQuHKMbUe2949nXm3Sg09N1UcR3VoQNN5E= github.com/lightstep/lightstep-tracer-go v0.25.0/go.mod h1:G1ZAEaqTHFPWpWunnbUn1ADEY/Jvzz7jIOaXwAfD6A8= -github.com/linode/linodego v1.9.3 h1:+lxNZw4avRxhCqGjwfPgQ2PvMT+vOL0OMsTdzixR7hQ= +github.com/linode/linodego v1.12.0 h1:33mOIrZ+gVva14gyJMKPZ85mQGovAvZCEP1ftgmFBjA= github.com/lovoo/gcloud-opentracing v0.3.0 h1:nAeKG70rIsog0TelcEtt6KU0Y1s5qXtsDLnHp0urPLU= github.com/lovoo/gcloud-opentracing v0.3.0/go.mod h1:ZFqk2y38kMDDikZPAK7ynTTGuyt17nSPdS3K5e+ZTBY= github.com/lufia/plan9stats v0.0.0-20211012122336-39d0f177ccd0 h1:6E+4a0GO5zZEnZ81pIr0yLvtUWk2if982qA3F3QD6H4= @@ -800,8 +802,8 @@ github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9 github.com/prometheus/common v0.29.0/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= github.com/prometheus/common v0.37.0/go.mod h1:phzohg0JFMnBEFGxTDbfu3QyL5GI8gTQJFhYO5B3mfA= -github.com/prometheus/common v0.39.1-0.20230110141620-846591a16635 h1:hK3y58iUBjRFZ6kFNJTWsES1GnVKsqEYUeiyeRXridQ= -github.com/prometheus/common v0.39.1-0.20230110141620-846591a16635/go.mod h1:6XBZ7lYdLCbkAVhwRsWTZn+IN5AB9F/NXd5w0BbEX0Y= +github.com/prometheus/common v0.39.1-0.20230202092144-f9c1994be032 h1:OKL/rHv39LgZmRQZZcUOCzl0UuFu3OC6IMofPoseG0Y= +github.com/prometheus/common v0.39.1-0.20230202092144-f9c1994be032/go.mod h1:L65ZJPSmfn/UBWLQIHV7dBrKFidB/wPlF1y5TlSt9OE= github.com/prometheus/common/sigv4 v0.1.0 h1:qoVebwtwwEhS85Czm2dSROY5fTo2PAPEVdDeppTwGX4= github.com/prometheus/common/sigv4 v0.1.0/go.mod h1:2Jkxxk9yYvCkE5G1sQT7GuEXm57JrvHu9k5YwTjsNtI= github.com/prometheus/exporter-toolkit v0.8.2 h1:sbJAfBXQFkG6sUkbwBun8MNdzW9+wd5YfPYofbmj0YM= @@ -818,8 +820,8 @@ github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1 github.com/prometheus/procfs v0.8.0/go.mod h1:z7EfXMXOkbkqb9IINtpCn86r/to3BnA0uaxHdg830/4= github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= -github.com/prometheus/prometheus v0.41.0 h1:+QR4QpzwE54zsKk2K7EUkof3tHxa3b/fyw7xJ4jR1Ns= -github.com/prometheus/prometheus v0.41.0/go.mod h1:Uu5817xm7ibU/VaDZ9pu1ssGzcpO9Bd+LyoZ76RpHyo= +github.com/prometheus/prometheus v0.42.0 h1:G769v8covTkOiNckXFIwLx01XE04OE6Fr0JPA0oR2nI= +github.com/prometheus/prometheus v0.42.0/go.mod h1:Pfqb/MLnnR2KK+0vchiaH39jXxvLMBk+3lnIGP4N7Vk= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= github.com/rivo/uniseg v0.2.0 h1:S1pD9weZBuJdFmowNwbpi7BJ8TNftyUImj/0WQi72jY= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= @@ -840,7 +842,7 @@ github.com/samuel/go-zookeeper v0.0.0-20190923202752-2cc03de413da/go.mod h1:gi+0 github.com/santhosh-tekuri/jsonschema v1.2.4 h1:hNhW8e7t+H1vgY+1QeEQpveR6D4+OwKPXCfD2aieJis= github.com/santhosh-tekuri/jsonschema v1.2.4/go.mod h1:TEAUOeZSmIxTTuHatJzrvARHiuO9LYd+cIxzgEHCQI4= github.com/satori/go.uuid v1.2.1-0.20181028125025-b2ce2384e17b h1:gQZ0qzfKHQIybLANtM3mBXNUtOfsCFXeTsnBqCsx1KM= -github.com/scaleway/scaleway-sdk-go v1.0.0-beta.10 h1:wsfMs0iv+MJiViM37qh5VEKISi3/ZUq2nNKNdqmumAs= +github.com/scaleway/scaleway-sdk-go v1.0.0-beta.12 h1:Aaz4T7dZp7cB2cv7D/tGtRdSMh48sRaDYr7Jh0HV4qQ= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/sercand/kuberesolver v2.4.0+incompatible h1:WE2OlRf6wjLxHwNkkFLQGaZcVLEXjMjBPjjEU5vksH8= github.com/sercand/kuberesolver v2.4.0+incompatible/go.mod h1:lWF3GL0xptCB/vCiJPl/ZshwPsX/n4Y7u0CW9E7aQIQ= @@ -893,8 +895,8 @@ github.com/tencentyun/cos-go-sdk-v5 v0.7.40 h1:W6vDGKCHe4wBACI1d2UgE6+50sJFhRWU4 github.com/tencentyun/cos-go-sdk-v5 v0.7.40/go.mod h1:4dCEtLHGh8QPxHEkgq+nFaky7yZxQuYwgSJM87icDaw= github.com/thanos-community/galaxycache v0.0.0-20211122094458-3a32041a1f1e h1:f1Zsv7OAU9iQhZwigp50Yl38W10g/vd5NC8Rdk1Jzng= github.com/thanos-community/galaxycache v0.0.0-20211122094458-3a32041a1f1e/go.mod h1:jXcofnrSln/cLI6/dhlBxPQZEEQHVPCcFaH75M+nSzM= -github.com/thanos-community/promql-engine v0.0.0-20230124070417-9e293186b7e4 h1:D0ruzvS/U+49eMLg/7IIYK2iMdVP4PrJLpVHgguMVkg= -github.com/thanos-community/promql-engine v0.0.0-20230124070417-9e293186b7e4/go.mod h1:d52Wfzxs6L3xhc2snodyWvM2bZMMVn0XT2q4vsfBPVo= +github.com/thanos-community/promql-engine v0.0.0-20230213101639-ab3d8dcea3f3 h1:Uu7UEw9o3DbZRZwonnCa3LhXCUgGOmY94/Z7+uGa2Ok= +github.com/thanos-community/promql-engine v0.0.0-20230213101639-ab3d8dcea3f3/go.mod h1:gREn4JarQ2DZdWirOtqZQd3p+c1xH+UVpGRjGKVoWx8= github.com/thanos-io/objstore v0.0.0-20230201072718-11ffbc490204 h1:W4w5Iph7j32Sf1QFWLJDCqvO0WgZS0jHGID+qnq3wV0= github.com/thanos-io/objstore v0.0.0-20230201072718-11ffbc490204/go.mod h1:STSgpY8M6EKF2G/raUFdbIMf2U9GgYlEjAEHJxjvpAo= github.com/themihai/gomemcache v0.0.0-20180902122335-24332e2d58ab h1:7ZR3hmisBWw77ZpO1/o86g+JV3VKlk3d48jopJxzTjU= @@ -1049,8 +1051,8 @@ golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u0 golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20221212164502-fae10dda9338 h1:OvjRkcNHnf6/W5FZXSxODbxwD+X7fspczG7Jn/xQVD4= -golang.org/x/exp v0.0.0-20221212164502-fae10dda9338/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= +golang.org/x/exp v0.0.0-20230124195608-d38c7dcee874 h1:kWC3b7j6Fu09SnEBr7P4PuQyM0R6sqyH9R+EjIvT1nQ= +golang.org/x/exp v0.0.0-20230124195608-d38c7dcee874/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= @@ -1159,8 +1161,8 @@ golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= golang.org/x/oauth2 v0.0.0-20220608161450-d0670ef3b1eb/go.mod h1:jaDAt6Dkxork7LmZnYtzbRWj0W47D86a3TGe0YHBvmE= golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= -golang.org/x/oauth2 v0.3.0 h1:6l90koy8/LaBLmLu8jpHeHexzMwEita0zFfYlggy2F8= -golang.org/x/oauth2 v0.3.0/go.mod h1:rQrIauxkUhJ6CuwEXwymO2/eh4xz2ZWF1nBkcxS+tGk= +golang.org/x/oauth2 v0.4.0 h1:NF0gk8LVPg1Ml7SSbGyySuoxdsXitj7TvgvuRxIMc/M= +golang.org/x/oauth2 v0.4.0/go.mod h1:RznEsdpjGAINPTOF0UH/t+xJ75L18YO3Ho6Pyn+uRec= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1358,8 +1360,8 @@ golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.6-0.20210726203631-07bc1bf47fb2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.4.0 h1:7mTAgkunk3fr4GAloyyCasadO6h9zSsQZbwvcaIciV4= -golang.org/x/tools v0.4.0/go.mod h1:UE5sM2OK9E/d67R0ANs2xJizIymRP5gJU295PvKXxjQ= +golang.org/x/tools v0.5.0 h1:+bSpV5HIeWkuvgaMfI3UmKRThoTA5ODJTUd8T17NO+4= +golang.org/x/tools v0.5.0/go.mod h1:N+Kgy78s5I24c24dU8OfWNEotWjutIs8SnJvn5IDq+k= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -1411,8 +1413,8 @@ google.golang.org/api v0.75.0/go.mod h1:pU9QmyHLnzlpar1Mjt4IbapUCy8J+6HD6GeELN69 google.golang.org/api v0.78.0/go.mod h1:1Sg78yoMLOhlQTeF+ARBoytAcH1NNyyl390YMy6rKmw= google.golang.org/api v0.80.0/go.mod h1:xY3nI94gbvBrE0J6NHXhxOmW97HG7Khjkku6AFB3Hyg= google.golang.org/api v0.84.0/go.mod h1:NTsGnUFJMYROtiquksZHBWtHfeMC7iYthki7Eq3pa8o= -google.golang.org/api v0.104.0 h1:KBfmLRqdZEbwQleFlSLnzpQJwhjpmNOk4cKQIBDZ9mg= -google.golang.org/api v0.104.0/go.mod h1:JCspTXJbBxa5ySXw4UgUqVer7DfVxbvc/CTUFqAED5U= +google.golang.org/api v0.108.0 h1:WVBc/faN0DkKtR43Q/7+tPny9ZoLZdIiAyG5Q9vFClg= +google.golang.org/api v0.108.0/go.mod h1:2Ts0XTHNVWxypznxWOYUeI4g3WdP9Pk2Qk58+a/O9MY= google.golang.org/appengine v1.2.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= @@ -1568,9 +1570,9 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= howett.net/plist v0.0.0-20181124034731-591f970eefbb h1:jhnBjNi9UFpfpl8YZhA9CrOqpnJdvzuiHsl/dnxl11M= howett.net/plist v0.0.0-20181124034731-591f970eefbb/go.mod h1:vMygbs4qMhSZSc4lCUl2OEE+rDiIIJAIdR4m7MiMcm0= -k8s.io/api v0.26.0 h1:IpPlZnxBpV1xl7TGk/X6lFtpgjgntCg8PJ+qrPHAC7I= -k8s.io/apimachinery v0.26.0 h1:1feANjElT7MvPqp0JT6F3Ss6TWDwmcjLypwoPpEf7zg= -k8s.io/client-go v0.26.0 h1:lT1D3OfO+wIi9UFolCrifbjUUgu7CpLca0AD8ghRLI8= +k8s.io/api v0.26.1 h1:f+SWYiPd/GsiWwVRz+NbFyCgvv75Pk9NK6dlkZgpCRQ= +k8s.io/apimachinery v0.26.1 h1:8EZ/eGJL+hY/MYCNwhmDzVqq2lPl3N3Bo8rvweJwXUQ= +k8s.io/client-go v0.26.1 h1:87CXzYJnAMGaa/IDDfRdhTzxk/wzGZ+/HUQpqgVSZXU= k8s.io/kube-openapi v0.0.0-20221207184640-f3cff1453715 h1:tBEbstoM+K0FiBV5KGAKQ0kuvf54v/hwpldiJt69w1s= k8s.io/utils v0.0.0-20221128185143-99ec85e7a448 h1:KTgPnR10d5zhztWptI952TNtt/4u5h3IzDXkdIMuo2Y= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= diff --git a/internal/cortex/querier/series/series_set.go b/internal/cortex/querier/series/series_set.go index d86d3d1f1e..ff213d183e 100644 --- a/internal/cortex/querier/series/series_set.go +++ b/internal/cortex/querier/series/series_set.go @@ -86,7 +86,7 @@ func (c *ConcreteSeries) Labels() labels.Labels { } // Iterator implements storage.Series -func (c *ConcreteSeries) Iterator() chunkenc.Iterator { +func (c *ConcreteSeries) Iterator(chunkenc.Iterator) chunkenc.Iterator { return NewConcreteSeriesIterator(c) } diff --git a/pkg/alert/alert.go b/pkg/alert/alert.go index 42bc9f7bf1..45b6ae2fda 100644 --- a/pkg/alert/alert.go +++ b/pkg/alert/alert.go @@ -183,8 +183,9 @@ func (q *Queue) Push(alerts []*notifier.Alert) { for _, l := range q.toAddLset { lb.Set(l.Name, l.Value) } - a.Labels = relabel.Process(lb.Labels(nil), q.alertRelabelConfigs...) - if a.Labels != nil { + + if lset, keep := relabel.Process(lb.Labels(nil), q.alertRelabelConfigs...); keep { + a.Labels = lset relabeledAlerts = append(relabeledAlerts, a) } } diff --git a/pkg/block/fetcher.go b/pkg/block/fetcher.go index 700aef952a..e97fc62f8b 100644 --- a/pkg/block/fetcher.go +++ b/pkg/block/fetcher.go @@ -569,7 +569,7 @@ func (f *LabelShardedMetaFilter) Filter(_ context.Context, metas map[ulid.ULID]* lbls = append(lbls, labels.Label{Name: k, Value: v}) } - if processedLabels := relabel.Process(lbls, f.relabelConfig...); len(processedLabels) == 0 { + if processedLabels, _ := relabel.Process(lbls, f.relabelConfig...); len(processedLabels) == 0 { synced.WithLabelValues(labelExcludedMeta).Inc() delete(metas, id) } diff --git a/pkg/block/index.go b/pkg/block/index.go index 0696cbbcd3..0aa7a74a75 100644 --- a/pkg/block/index.go +++ b/pkg/block/index.go @@ -223,6 +223,7 @@ func GatherIndexHealthStats(logger log.Logger, fn string, minTime, maxTime int64 var ( lastLset labels.Labels lset labels.Labels + builder labels.ScratchBuilder chks []chunks.Meta seriesLifeDuration = newMinMaxSumInt64() @@ -251,9 +252,10 @@ func GatherIndexHealthStats(logger log.Logger, fn string, minTime, maxTime int64 id := p.At() stats.TotalSeries++ - if err := r.Series(id, &lset, &chks); err != nil { + if err := r.Series(id, &builder, &chks); err != nil { return stats, errors.Wrap(err, "read series") } + lset = builder.Labels() if len(lset) == 0 { return stats, errors.Errorf("empty label set detected for series %d", id) } @@ -567,16 +569,16 @@ func rewrite( series = []seriesRepair{} ) - var lset labels.Labels + var builder labels.ScratchBuilder var chks []chunks.Meta for all.Next() { id := all.At() - if err := indexr.Series(id, &lset, &chks); err != nil { + if err := indexr.Series(id, &builder, &chks); err != nil { return errors.Wrap(err, "series") } // Make sure labels are in sorted order. - sort.Sort(lset) + builder.Sort() for i, c := range chks { chks[i].Chunk, err = chunkr.Chunk(c) @@ -595,7 +597,7 @@ func rewrite( } series = append(series, seriesRepair{ - lset: lset, + lset: builder.Labels(), chks: chks, }) } diff --git a/pkg/block/index_test.go b/pkg/block/index_test.go index 03620aa5a6..56fac51261 100644 --- a/pkg/block/index_test.go +++ b/pkg/block/index_test.go @@ -17,6 +17,7 @@ import ( "github.com/prometheus/prometheus/tsdb/index" "github.com/efficientgo/core/testutil" + "github.com/thanos-io/thanos/pkg/block/metadata" "github.com/thanos-io/thanos/pkg/testutil/e2eutil" ) @@ -76,10 +77,10 @@ func TestRewrite(t *testing.T) { testutil.Ok(t, err) for p := ir2.SortedPostings(all); p.Next(); { - var lset labels.Labels + var builder labels.ScratchBuilder var chks []chunks.Meta - testutil.Ok(t, ir2.Series(p.At(), &lset, &chks)) + testutil.Ok(t, ir2.Series(p.At(), &builder, &chks)) testutil.Equals(t, 1, len(chks)) } } diff --git a/pkg/compact/downsample/downsample.go b/pkg/compact/downsample/downsample.go index e698421dc0..07cf294f06 100644 --- a/pkg/compact/downsample/downsample.go +++ b/pkg/compact/downsample/downsample.go @@ -28,6 +28,7 @@ import ( "golang.org/x/sync/errgroup" "github.com/thanos-io/objstore" + "github.com/thanos-io/thanos/pkg/block" "github.com/thanos-io/thanos/pkg/block/metadata" "github.com/thanos-io/thanos/pkg/errutil" @@ -112,20 +113,20 @@ func Downsample( aggrChunks []*AggrChunk all []sample chks []chunks.Meta - lset labels.Labels + builder labels.ScratchBuilder reuseIt chunkenc.Iterator ) for postings.Next() { - lset = lset[:0] chks = chks[:0] all = all[:0] aggrChunks = aggrChunks[:0] // Get series labels and chunks. Downsampled data is sensitive to chunk boundaries // and we need to preserve them to properly downsample previously downsampled data. - if err := indexr.Series(postings.At(), &lset, &chks); err != nil { + if err := indexr.Series(postings.At(), &builder, &chks); err != nil { return id, errors.Wrapf(err, "get series %d", postings.At()) } + lset := builder.Labels() for i, c := range chks[1:] { if chks[i].MaxTime >= c.MinTime { diff --git a/pkg/compact/downsample/downsample_test.go b/pkg/compact/downsample/downsample_test.go index eba55f1154..d86f610007 100644 --- a/pkg/compact/downsample/downsample_test.go +++ b/pkg/compact/downsample/downsample_test.go @@ -25,6 +25,7 @@ import ( "go.uber.org/goleak" "github.com/efficientgo/core/testutil" + "github.com/thanos-io/thanos/pkg/block" "github.com/thanos-io/thanos/pkg/block/metadata" ) @@ -475,9 +476,12 @@ func TestDownsample(t *testing.T) { testutil.Ok(t, pall.Err()) testutil.Equals(t, 1, len(series)) + var builder labels.ScratchBuilder var lset labels.Labels var chks []chunks.Meta - testutil.Ok(t, indexr.Series(series[0], &lset, &chks)) + testutil.Ok(t, indexr.Series(series[0], &builder, &chks)) + + lset = builder.Labels() testutil.Equals(t, labels.FromStrings("__name__", "a"), lset) var got []map[AggrType][]sample @@ -996,13 +1000,14 @@ func (b *memBlock) Postings(name string, val ...string) (index.Postings, error) return index.NewListPostings(b.postings), nil } -func (b *memBlock) Series(id storage.SeriesRef, lset *labels.Labels, chks *[]chunks.Meta) error { +func (b *memBlock) Series(id storage.SeriesRef, builder *labels.ScratchBuilder, chks *[]chunks.Meta) error { if int(id) >= len(b.series) { return errors.Wrapf(storage.ErrNotFound, "series with ID %d does not exist", id) } s := b.series[id] - *lset = append((*lset)[:0], s.lset...) + builder.Reset() + builder.Assign(s.lset) *chks = append((*chks)[:0], s.chunks...) return nil diff --git a/pkg/compactv2/chunk_series_set.go b/pkg/compactv2/chunk_series_set.go index bccf30ded0..188f5e28af 100644 --- a/pkg/compactv2/chunk_series_set.go +++ b/pkg/compactv2/chunk_series_set.go @@ -24,7 +24,7 @@ type lazyPopulateChunkSeriesSet struct { all index.Postings bufChks []chunks.Meta - bufLbls labels.Labels + bufLbls labels.ScratchBuilder curr *storage.ChunkSeriesEntry err error @@ -53,13 +53,11 @@ func (s *lazyPopulateChunkSeriesSet) Next() bool { s.bufChks[i].Chunk = &lazyPopulatableChunk{cr: s.sReader.cr, m: &s.bufChks[i]} } s.curr = &storage.ChunkSeriesEntry{ - Lset: make(labels.Labels, len(s.bufLbls)), - ChunkIteratorFn: func() chunks.Iterator { + Lset: s.bufLbls.Labels(), + ChunkIteratorFn: func(_ chunks.Iterator) chunks.Iterator { return storage.NewListChunkSeriesIterator(s.bufChks...) }, } - // TODO: Do we need to copy this? - copy(s.curr.Lset, s.bufLbls) return true } return false @@ -187,7 +185,7 @@ func (w *Compactor) write(ctx context.Context, symbols index.StringIter, populat } s := populatedSet.At() - chksIter := s.Iterator() + chksIter := s.Iterator(nil) chks = chks[:0] for chksIter.Next() { // We are not iterating in streaming way over chunk as it's more efficient to do bulk write for index and diff --git a/pkg/compactv2/compactor.go b/pkg/compactv2/compactor.go index e5eb3e0497..f5c05fddc2 100644 --- a/pkg/compactv2/compactor.go +++ b/pkg/compactv2/compactor.go @@ -131,7 +131,7 @@ func (w *Compactor) WriteSeries(ctx context.Context, readers []block.Reader, sWr } s := set.At() - iter := s.Iterator() + iter := s.Iterator(nil) for iter.Next() { } if err := iter.Err(); err != nil { diff --git a/pkg/compactv2/compactor_test.go b/pkg/compactv2/compactor_test.go index eb23d1d1c4..e0ac1e4bd4 100644 --- a/pkg/compactv2/compactor_test.go +++ b/pkg/compactv2/compactor_test.go @@ -27,6 +27,7 @@ import ( "github.com/prometheus/prometheus/tsdb/tombstones" "github.com/efficientgo/core/testutil" + "github.com/thanos-io/thanos/pkg/block" "github.com/thanos-io/thanos/pkg/block/metadata" ) @@ -662,11 +663,13 @@ func readBlockSeries(t *testing.T, bDir string) []seriesSamples { testutil.Ok(t, err) all = indexr.SortedPostings(all) + var builder labels.ScratchBuilder var series []seriesSamples var chks []chunks.Meta for all.Next() { s := seriesSamples{} - testutil.Ok(t, indexr.Series(all.At(), &s.lset, &chks)) + testutil.Ok(t, indexr.Series(all.At(), &builder, &chks)) + s.lset = builder.Labels() for _, c := range chks { c.Chunk, err = chunkr.Chunk(c) diff --git a/pkg/compactv2/modifiers.go b/pkg/compactv2/modifiers.go index 8a259192fa..a6e369e3b4 100644 --- a/pkg/compactv2/modifiers.go +++ b/pkg/compactv2/modifiers.go @@ -83,7 +83,7 @@ SeriesLoop: } // Special case: Delete whole series. - chksIter := s.Iterator() + chksIter := s.Iterator(nil) var chks []chunks.Meta for chksIter.Next() { chks = append(chks, chksIter.At()) @@ -103,8 +103,8 @@ SeriesLoop: d.curr = &storage.ChunkSeriesEntry{ Lset: lbls, - ChunkIteratorFn: func() chunks.Iterator { - return NewDelGenericSeriesIterator(s.Iterator(), intervals, func(intervals tombstones.Intervals) { + ChunkIteratorFn: func(it chunks.Iterator) chunks.Iterator { + return NewDelGenericSeriesIterator(s.Iterator(it), intervals, func(intervals tombstones.Intervals) { d.log.DeleteSeries(lbls, intervals) }).ToChunkSeriesIterator() }, @@ -370,11 +370,11 @@ func (d *RelabelModifier) Modify(_ index.StringIter, set storage.ChunkSeriesSet, for set.Next() { s := set.At() lbls := s.Labels() - chksIter := s.Iterator() + chksIter := s.Iterator(nil) // The labels have to be copied because `relabel.Process` is now overwriting the original // labels to same memory. This happens since Prometheus v2.39.0. - if processedLabels := relabel.Process(lbls.Copy(), d.relabels...); len(processedLabels) == 0 { + if processedLabels, _ := relabel.Process(lbls.Copy(), d.relabels...); len(processedLabels) == 0 { // Special case: Delete whole series if no labels are present. var ( minT int64 = math.MaxInt64 @@ -461,7 +461,7 @@ func newChunkSeriesBuilder(lset labels.Labels) *mergeChunkSeries { func (s *mergeChunkSeries) addIter(iter chunkenc.Iterator) { s.ss = append(s.ss, &storage.SeriesEntry{ - SampleIteratorFn: func() chunkenc.Iterator { + SampleIteratorFn: func(iterator chunkenc.Iterator) chunkenc.Iterator { return iter }, }) @@ -471,15 +471,15 @@ func (s *mergeChunkSeries) Labels() labels.Labels { return s.lset } -func (s *mergeChunkSeries) Iterator() chunks.Iterator { +func (s *mergeChunkSeries) Iterator(iterator chunks.Iterator) chunks.Iterator { if len(s.ss) == 0 { return nil } if len(s.ss) == 1 { - return storage.NewSeriesToChunkEncoder(s.ss[0]).Iterator() + return storage.NewSeriesToChunkEncoder(s.ss[0]).Iterator(iterator) } - return storage.NewSeriesToChunkEncoder(storage.ChainedSeriesMerge(s.ss...)).Iterator() + return storage.NewSeriesToChunkEncoder(storage.ChainedSeriesMerge(s.ss...)).Iterator(iterator) } type errorOnlyStringIter struct { diff --git a/pkg/dedup/chunk_iter.go b/pkg/dedup/chunk_iter.go index 2055ade87b..c01be07a1d 100644 --- a/pkg/dedup/chunk_iter.go +++ b/pkg/dedup/chunk_iter.go @@ -23,10 +23,10 @@ func NewChunkSeriesMerger() storage.VerticalChunkSeriesMergeFunc { } return &storage.ChunkSeriesEntry{ Lset: series[0].Labels(), - ChunkIteratorFn: func() chunks.Iterator { + ChunkIteratorFn: func(iterator chunks.Iterator) chunks.Iterator { iterators := make([]chunks.Iterator, 0, len(series)) for _, s := range series { - iterators = append(iterators, s.Iterator()) + iterators = append(iterators, s.Iterator(nil)) } return &dedupChunksIterator{ iterators: iterators, @@ -196,13 +196,13 @@ func (o *overlappingMerger) iterator(baseChk chunks.Meta) chunks.Iterator { case chunkenc.EncXOR: // If XOR encoding, we need to deduplicate the samples and re-encode them to chunks. return storage.NewSeriesToChunkEncoder(&storage.SeriesEntry{ - SampleIteratorFn: func() chunkenc.Iterator { + SampleIteratorFn: func(_ chunkenc.Iterator) chunkenc.Iterator { it = baseChk.Chunk.Iterator(nil) for _, i := range o.xorIterators { it = o.samplesMergeFunc(it, i) } return it - }}).Iterator() + }}).Iterator(nil) case downsample.ChunkEncAggr: // If Aggr encoding, each aggregated chunks need to be expanded and deduplicated, @@ -243,10 +243,10 @@ func newAggrChunkIterator(iters [5]chunkenc.Iterator) chunks.Iterator { return &aggrChunkIterator{ iters: iters, countChkIter: storage.NewSeriesToChunkEncoder(&storage.SeriesEntry{ - SampleIteratorFn: func() chunkenc.Iterator { + SampleIteratorFn: func(_ chunkenc.Iterator) chunkenc.Iterator { return iters[downsample.AggrCount] }, - }).Iterator(), + }).Iterator(nil), } } diff --git a/pkg/dedup/chunk_iter_test.go b/pkg/dedup/chunk_iter_test.go index 9392425a1f..29ee674e03 100644 --- a/pkg/dedup/chunk_iter_test.go +++ b/pkg/dedup/chunk_iter_test.go @@ -13,6 +13,7 @@ import ( "github.com/prometheus/prometheus/tsdb/tsdbutil" "github.com/efficientgo/core/testutil" + "github.com/thanos-io/thanos/pkg/compact/downsample" ) @@ -135,8 +136,8 @@ func TestDedupChunkSeriesMerger(t *testing.T) { t.Run(tc.name, func(t *testing.T) { merged := m(tc.input...) testutil.Equals(t, tc.expected.Labels(), merged.Labels()) - actChks, actErr := storage.ExpandChunks(merged.Iterator()) - expChks, expErr := storage.ExpandChunks(tc.expected.Iterator()) + actChks, actErr := storage.ExpandChunks(merged.Iterator(nil)) + expChks, expErr := storage.ExpandChunks(tc.expected.Iterator(nil)) testutil.Equals(t, expErr, actErr) testutil.Equals(t, expChks, actChks) @@ -166,14 +167,14 @@ func TestDedupChunkSeriesMergerDownsampledChunks(t *testing.T) { input: []storage.ChunkSeries{ &storage.ChunkSeriesEntry{ Lset: defaultLabels, - ChunkIteratorFn: func() chunks.Iterator { + ChunkIteratorFn: func(chunks.Iterator) chunks.Iterator { return storage.NewListChunkSeriesIterator(downsample.DownsampleRaw(emptySamples, downsample.ResLevel1)...) }, }, }, expected: &storage.ChunkSeriesEntry{ Lset: defaultLabels, - ChunkIteratorFn: func() chunks.Iterator { + ChunkIteratorFn: func(chunks.Iterator) chunks.Iterator { return storage.NewListChunkSeriesIterator() }, }, @@ -183,14 +184,14 @@ func TestDedupChunkSeriesMergerDownsampledChunks(t *testing.T) { input: []storage.ChunkSeries{ &storage.ChunkSeriesEntry{ Lset: defaultLabels, - ChunkIteratorFn: func() chunks.Iterator { + ChunkIteratorFn: func(chunks.Iterator) chunks.Iterator { return storage.NewListChunkSeriesIterator(downsample.DownsampleRaw(samples1, downsample.ResLevel1)...) }, }, }, expected: &storage.ChunkSeriesEntry{ Lset: defaultLabels, - ChunkIteratorFn: func() chunks.Iterator { + ChunkIteratorFn: func(chunks.Iterator) chunks.Iterator { return storage.NewListChunkSeriesIterator(downsample.DownsampleRaw(samples1, downsample.ResLevel1)...) }, }, @@ -200,20 +201,20 @@ func TestDedupChunkSeriesMergerDownsampledChunks(t *testing.T) { input: []storage.ChunkSeries{ &storage.ChunkSeriesEntry{ Lset: defaultLabels, - ChunkIteratorFn: func() chunks.Iterator { + ChunkIteratorFn: func(chunks.Iterator) chunks.Iterator { return storage.NewListChunkSeriesIterator(downsample.DownsampleRaw(emptySamples, downsample.ResLevel1)...) }, }, &storage.ChunkSeriesEntry{ Lset: defaultLabels, - ChunkIteratorFn: func() chunks.Iterator { + ChunkIteratorFn: func(chunks.Iterator) chunks.Iterator { return storage.NewListChunkSeriesIterator(downsample.DownsampleRaw(emptySamples, downsample.ResLevel1)...) }, }, }, expected: &storage.ChunkSeriesEntry{ Lset: defaultLabels, - ChunkIteratorFn: func() chunks.Iterator { + ChunkIteratorFn: func(chunks.Iterator) chunks.Iterator { return storage.NewListChunkSeriesIterator() }, }, @@ -223,20 +224,20 @@ func TestDedupChunkSeriesMergerDownsampledChunks(t *testing.T) { input: []storage.ChunkSeries{ &storage.ChunkSeriesEntry{ Lset: defaultLabels, - ChunkIteratorFn: func() chunks.Iterator { + ChunkIteratorFn: func(chunks.Iterator) chunks.Iterator { return storage.NewListChunkSeriesIterator(downsample.DownsampleRaw(samples1, downsample.ResLevel1)...) }, }, &storage.ChunkSeriesEntry{ Lset: defaultLabels, - ChunkIteratorFn: func() chunks.Iterator { + ChunkIteratorFn: func(chunks.Iterator) chunks.Iterator { return storage.NewListChunkSeriesIterator(downsample.DownsampleRaw(samples2, downsample.ResLevel1)...) }, }, }, expected: &storage.ChunkSeriesEntry{ Lset: defaultLabels, - ChunkIteratorFn: func() chunks.Iterator { + ChunkIteratorFn: func(chunks.Iterator) chunks.Iterator { return storage.NewListChunkSeriesIterator( append(downsample.DownsampleRaw(samples1, downsample.ResLevel1), downsample.DownsampleRaw(samples2, downsample.ResLevel1)...)...) @@ -249,20 +250,20 @@ func TestDedupChunkSeriesMergerDownsampledChunks(t *testing.T) { input: []storage.ChunkSeries{ &storage.ChunkSeriesEntry{ Lset: defaultLabels, - ChunkIteratorFn: func() chunks.Iterator { + ChunkIteratorFn: func(chunks.Iterator) chunks.Iterator { return storage.NewListChunkSeriesIterator(downsample.DownsampleRaw(samples1, downsample.ResLevel1)...) }, }, &storage.ChunkSeriesEntry{ Lset: defaultLabels, - ChunkIteratorFn: func() chunks.Iterator { + ChunkIteratorFn: func(chunks.Iterator) chunks.Iterator { return storage.NewListChunkSeriesIterator(downsample.DownsampleRaw(samples1, downsample.ResLevel1)...) }, }, }, expected: &storage.ChunkSeriesEntry{ Lset: defaultLabels, - ChunkIteratorFn: func() chunks.Iterator { + ChunkIteratorFn: func(chunks.Iterator) chunks.Iterator { return storage.NewListChunkSeriesIterator( downsample.DownsampleRaw(samples1, downsample.ResLevel1)...) }, @@ -273,20 +274,20 @@ func TestDedupChunkSeriesMergerDownsampledChunks(t *testing.T) { input: []storage.ChunkSeries{ &storage.ChunkSeriesEntry{ Lset: defaultLabels, - ChunkIteratorFn: func() chunks.Iterator { + ChunkIteratorFn: func(chunks.Iterator) chunks.Iterator { return storage.NewListChunkSeriesIterator(downsample.DownsampleRaw(samples1, downsample.ResLevel1)...) }, }, &storage.ChunkSeriesEntry{ Lset: defaultLabels, - ChunkIteratorFn: func() chunks.Iterator { + ChunkIteratorFn: func(chunks.Iterator) chunks.Iterator { return storage.NewListChunkSeriesIterator(downsample.DownsampleRaw(samples3, downsample.ResLevel1)...) }, }, }, expected: &storage.ChunkSeriesEntry{ Lset: defaultLabels, - ChunkIteratorFn: func() chunks.Iterator { + ChunkIteratorFn: func(chunks.Iterator) chunks.Iterator { return storage.NewListChunkSeriesIterator(chunks.Meta{ MinTime: 299999, MaxTime: 540000, @@ -305,8 +306,8 @@ func TestDedupChunkSeriesMergerDownsampledChunks(t *testing.T) { t.Run(tc.name, func(t *testing.T) { merged := m(tc.input...) testutil.Equals(t, tc.expected.Labels(), merged.Labels()) - actChks, actErr := storage.ExpandChunks(merged.Iterator()) - expChks, expErr := storage.ExpandChunks(tc.expected.Iterator()) + actChks, actErr := storage.ExpandChunks(merged.Iterator(nil)) + expChks, expErr := storage.ExpandChunks(tc.expected.Iterator(nil)) testutil.Equals(t, expErr, actErr) testutil.Equals(t, expChks, actChks) diff --git a/pkg/dedup/iter.go b/pkg/dedup/iter.go index a84ea54767..7573d00c76 100644 --- a/pkg/dedup/iter.go +++ b/pkg/dedup/iter.go @@ -185,21 +185,21 @@ func (s *dedupSeries) Labels() labels.Labels { // pushdownIterator creates an iterator that handles // all pushed down series. -func (s *dedupSeries) pushdownIterator() chunkenc.Iterator { +func (s *dedupSeries) pushdownIterator(_ chunkenc.Iterator) chunkenc.Iterator { var pushedDownIterator adjustableSeriesIterator if s.isCounter { - pushedDownIterator = &counterErrAdjustSeriesIterator{Iterator: s.pushedDown[0].Iterator()} + pushedDownIterator = &counterErrAdjustSeriesIterator{Iterator: s.pushedDown[0].Iterator(nil)} } else { - pushedDownIterator = noopAdjustableSeriesIterator{Iterator: s.pushedDown[0].Iterator()} + pushedDownIterator = noopAdjustableSeriesIterator{Iterator: s.pushedDown[0].Iterator(nil)} } for _, o := range s.pushedDown[1:] { var replicaIterator adjustableSeriesIterator if s.isCounter { - replicaIterator = &counterErrAdjustSeriesIterator{Iterator: o.Iterator()} + replicaIterator = &counterErrAdjustSeriesIterator{Iterator: o.Iterator(nil)} } else { - replicaIterator = noopAdjustableSeriesIterator{Iterator: o.Iterator()} + replicaIterator = noopAdjustableSeriesIterator{Iterator: o.Iterator(nil)} } pushedDownIterator = noopAdjustableSeriesIterator{newPushdownSeriesIterator(pushedDownIterator, replicaIterator, s.f)} @@ -210,21 +210,21 @@ func (s *dedupSeries) pushdownIterator() chunkenc.Iterator { // allSeriesIterator creates an iterator over all series - pushed down // and regular replicas. -func (s *dedupSeries) allSeriesIterator() chunkenc.Iterator { +func (s *dedupSeries) allSeriesIterator(_ chunkenc.Iterator) chunkenc.Iterator { var replicasIterator, pushedDownIterator adjustableSeriesIterator if len(s.replicas) != 0 { if s.isCounter { - replicasIterator = &counterErrAdjustSeriesIterator{Iterator: s.replicas[0].Iterator()} + replicasIterator = &counterErrAdjustSeriesIterator{Iterator: s.replicas[0].Iterator(nil)} } else { - replicasIterator = noopAdjustableSeriesIterator{Iterator: s.replicas[0].Iterator()} + replicasIterator = noopAdjustableSeriesIterator{Iterator: s.replicas[0].Iterator(nil)} } for _, o := range s.replicas[1:] { var replicaIter adjustableSeriesIterator if s.isCounter { - replicaIter = &counterErrAdjustSeriesIterator{Iterator: o.Iterator()} + replicaIter = &counterErrAdjustSeriesIterator{Iterator: o.Iterator(nil)} } else { - replicaIter = noopAdjustableSeriesIterator{Iterator: o.Iterator()} + replicaIter = noopAdjustableSeriesIterator{Iterator: o.Iterator(nil)} } replicasIterator = newDedupSeriesIterator(replicasIterator, replicaIter) } @@ -232,17 +232,17 @@ func (s *dedupSeries) allSeriesIterator() chunkenc.Iterator { if len(s.pushedDown) != 0 { if s.isCounter { - pushedDownIterator = &counterErrAdjustSeriesIterator{Iterator: s.pushedDown[0].Iterator()} + pushedDownIterator = &counterErrAdjustSeriesIterator{Iterator: s.pushedDown[0].Iterator(nil)} } else { - pushedDownIterator = noopAdjustableSeriesIterator{Iterator: s.pushedDown[0].Iterator()} + pushedDownIterator = noopAdjustableSeriesIterator{Iterator: s.pushedDown[0].Iterator(nil)} } for _, o := range s.pushedDown[1:] { var replicaIter adjustableSeriesIterator if s.isCounter { - replicaIter = &counterErrAdjustSeriesIterator{Iterator: o.Iterator()} + replicaIter = &counterErrAdjustSeriesIterator{Iterator: o.Iterator(nil)} } else { - replicaIter = noopAdjustableSeriesIterator{Iterator: o.Iterator()} + replicaIter = noopAdjustableSeriesIterator{Iterator: o.Iterator(nil)} } pushedDownIterator = newDedupSeriesIterator(pushedDownIterator, replicaIter) } @@ -257,16 +257,16 @@ func (s *dedupSeries) allSeriesIterator() chunkenc.Iterator { return newDedupSeriesIterator(pushedDownIterator, replicasIterator) } -func (s *dedupSeries) Iterator() chunkenc.Iterator { +func (s *dedupSeries) Iterator(_ chunkenc.Iterator) chunkenc.Iterator { // This function needs a regular iterator over all series. Behavior is identical // whether it was pushed down or not. if s.f == "group" { - return s.allSeriesIterator() + return s.allSeriesIterator(nil) } // If there are no replicas then jump straight to constructing an iterator // for pushed down series. if len(s.replicas) == 0 { - return s.pushdownIterator() + return s.pushdownIterator(nil) } // Finally, if we have both then construct a tree out of them. @@ -274,17 +274,17 @@ func (s *dedupSeries) Iterator() chunkenc.Iterator { // We deduplicate everything in the end. var it adjustableSeriesIterator if s.isCounter { - it = &counterErrAdjustSeriesIterator{Iterator: s.replicas[0].Iterator()} + it = &counterErrAdjustSeriesIterator{Iterator: s.replicas[0].Iterator(nil)} } else { - it = noopAdjustableSeriesIterator{Iterator: s.replicas[0].Iterator()} + it = noopAdjustableSeriesIterator{Iterator: s.replicas[0].Iterator(nil)} } for _, o := range s.replicas[1:] { var replicaIter adjustableSeriesIterator if s.isCounter { - replicaIter = &counterErrAdjustSeriesIterator{Iterator: o.Iterator()} + replicaIter = &counterErrAdjustSeriesIterator{Iterator: o.Iterator(nil)} } else { - replicaIter = noopAdjustableSeriesIterator{Iterator: o.Iterator()} + replicaIter = noopAdjustableSeriesIterator{Iterator: o.Iterator(nil)} } it = newDedupSeriesIterator(it, replicaIter) } @@ -296,18 +296,18 @@ func (s *dedupSeries) Iterator() chunkenc.Iterator { // Join all of the pushed down iterators into one. var pushedDownIterator adjustableSeriesIterator if s.isCounter { - pushedDownIterator = &counterErrAdjustSeriesIterator{Iterator: s.pushedDown[0].Iterator()} + pushedDownIterator = &counterErrAdjustSeriesIterator{Iterator: s.pushedDown[0].Iterator(nil)} } else { - pushedDownIterator = noopAdjustableSeriesIterator{Iterator: s.pushedDown[0].Iterator()} + pushedDownIterator = noopAdjustableSeriesIterator{Iterator: s.pushedDown[0].Iterator(nil)} } for _, o := range s.pushedDown[1:] { var replicaIterator adjustableSeriesIterator if s.isCounter { - replicaIterator = &counterErrAdjustSeriesIterator{Iterator: o.Iterator()} + replicaIterator = &counterErrAdjustSeriesIterator{Iterator: o.Iterator(nil)} } else { - replicaIterator = noopAdjustableSeriesIterator{Iterator: o.Iterator()} + replicaIterator = noopAdjustableSeriesIterator{Iterator: o.Iterator(nil)} } pushedDownIterator = noopAdjustableSeriesIterator{newPushdownSeriesIterator(pushedDownIterator, replicaIterator, s.f)} diff --git a/pkg/dedup/iter_test.go b/pkg/dedup/iter_test.go index 2ecd74473f..06da71db8b 100644 --- a/pkg/dedup/iter_test.go +++ b/pkg/dedup/iter_test.go @@ -51,7 +51,7 @@ type series struct { } func (s series) Labels() labels.Labels { return s.lset } -func (s series) Iterator() chunkenc.Iterator { +func (s series) Iterator(chunkenc.Iterator) chunkenc.Iterator { return newMockedSeriesIterator(s.samples) } @@ -477,7 +477,7 @@ func TestDedupSeriesSet(t *testing.T) { for i, s := range ats { testutil.Equals(t, tcase.exp[i].lset, s.Labels(), "labels mismatch for series %v", i) - res := expandSeries(t, s.Iterator()) + res := expandSeries(t, s.Iterator(nil)) testutil.Equals(t, tcase.exp[i].samples, res, "values mismatch for series :%v", i) } }) diff --git a/pkg/query/iter.go b/pkg/query/iter.go index 6213d2c031..9b6b79e9a8 100644 --- a/pkg/query/iter.go +++ b/pkg/query/iter.go @@ -159,7 +159,7 @@ func (s *chunkSeries) Labels() labels.Labels { return s.lset } -func (s *chunkSeries) Iterator() chunkenc.Iterator { +func (s *chunkSeries) Iterator(_ chunkenc.Iterator) chunkenc.Iterator { var sit chunkenc.Iterator its := make([]chunkenc.Iterator, 0, len(s.chunks)) diff --git a/pkg/query/querier_test.go b/pkg/query/querier_test.go index 2789d72cce..7affdf3408 100644 --- a/pkg/query/querier_test.go +++ b/pkg/query/querier_test.go @@ -28,6 +28,7 @@ import ( "github.com/prometheus/prometheus/util/gate" "github.com/efficientgo/core/testutil" + "github.com/thanos-io/thanos/pkg/component" "github.com/thanos-io/thanos/pkg/dedup" "github.com/thanos-io/thanos/pkg/store" @@ -689,7 +690,7 @@ func testSelectResponse(t *testing.T, expected []series, res storage.SeriesSet) for i, s := range series { testutil.Equals(t, expected[i].lset, s.Labels()) - samples := expandSeries(t, s.Iterator()) + samples := expandSeries(t, s.Iterator(nil)) expectedCpy := make([]sample, 0, len(expected[i].samples)) for _, s := range expected[i].samples { v := s.v diff --git a/pkg/query/query_bench_test.go b/pkg/query/query_bench_test.go index 1f29e12f22..f72c5fa3bc 100644 --- a/pkg/query/query_bench_test.go +++ b/pkg/query/query_bench_test.go @@ -15,6 +15,7 @@ import ( "github.com/prometheus/prometheus/tsdb/chunkenc" "github.com/efficientgo/core/testutil" + "github.com/thanos-io/thanos/pkg/gate" "github.com/thanos-io/thanos/pkg/store/labelpb" "github.com/thanos-io/thanos/pkg/store/storepb" @@ -129,7 +130,7 @@ func testSelect(t testutil.TB, q *querier, expectedSeries []labels.Labels) { gotSeriesCount++ // This is when resource usage should actually start growing. - iter := s.Iterator() + iter := s.Iterator(nil) for iter.Next() != chunkenc.ValNone { testT, testV = iter.At() } @@ -145,7 +146,7 @@ func testSelect(t testutil.TB, q *querier, expectedSeries []labels.Labels) { gotSeries = append(gotSeries, s.Labels()) // This is when resource usage should actually start growing. - iter := s.Iterator() + iter := s.Iterator(nil) for iter.Next() != chunkenc.ValNone { testT, testV = iter.At() } diff --git a/pkg/receive/handler.go b/pkg/receive/handler.go index 14b4320795..d006aad2d3 100644 --- a/pkg/receive/handler.go +++ b/pkg/receive/handler.go @@ -853,8 +853,9 @@ func (h *Handler) relabel(wreq *prompb.WriteRequest) { } timeSeries := make([]prompb.TimeSeries, 0, len(wreq.Timeseries)) for _, ts := range wreq.Timeseries { - lbls := relabel.Process(labelpb.ZLabelsToPromLabels(ts.Labels), h.options.RelabelConfigs...) - if lbls == nil { + var keep bool + lbls, keep := relabel.Process(labelpb.ZLabelsToPromLabels(ts.Labels), h.options.RelabelConfigs...) + if !keep { continue } ts.Labels = labelpb.ZLabelsFromPromLabels(lbls) diff --git a/pkg/receive/handler_test.go b/pkg/receive/handler_test.go index 9a0f55925f..dd54809ec4 100644 --- a/pkg/receive/handler_test.go +++ b/pkg/receive/handler_test.go @@ -40,6 +40,7 @@ import ( "github.com/prometheus/prometheus/tsdb" "github.com/efficientgo/core/testutil" + "github.com/thanos-io/thanos/pkg/block/metadata" "github.com/thanos-io/thanos/pkg/extkingpin" "github.com/thanos-io/thanos/pkg/runutil" @@ -143,7 +144,7 @@ func (f *fakeAppender) AppendExemplar(ref storage.SeriesRef, l labels.Labels, e } // TODO(rabenhorst): Needs to be implement for native histogram support. -func (f *fakeAppender) AppendHistogram(ref storage.SeriesRef, l labels.Labels, t int64, h *histogram.Histogram) (storage.SeriesRef, error) { +func (f *fakeAppender) AppendHistogram(ref storage.SeriesRef, l labels.Labels, t int64, h *histogram.Histogram, fh *histogram.FloatHistogram) (storage.SeriesRef, error) { panic("not implemented") } diff --git a/pkg/receive/writer.go b/pkg/receive/writer.go index 56ae684245..004dfd82d4 100644 --- a/pkg/receive/writer.go +++ b/pkg/receive/writer.go @@ -135,7 +135,7 @@ func (r *Writer) Write(ctx context.Context, tenantID string, wreq *prompb.WriteR for _, hp := range t.Histograms { h := storepb.HistogramProtoToHistogram(hp) - ref, err = app.AppendHistogram(ref, lset, hp.Timestamp, h) + ref, err = app.AppendHistogram(ref, lset, hp.Timestamp, h, nil) switch err { case storage.ErrOutOfOrderSample: numSamplesOutOfOrder++ diff --git a/pkg/rules/manager_test.go b/pkg/rules/manager_test.go index 06f96a4aaa..7832016567 100644 --- a/pkg/rules/manager_test.go +++ b/pkg/rules/manager_test.go @@ -27,6 +27,7 @@ import ( "gopkg.in/yaml.v3" "github.com/efficientgo/core/testutil" + "github.com/thanos-io/thanos/pkg/extprom" "github.com/thanos-io/thanos/pkg/runutil" "github.com/thanos-io/thanos/pkg/store/storepb" @@ -45,7 +46,7 @@ func (n nopAppender) AppendExemplar(storage.SeriesRef, labels.Labels, exemplar.E return 0, nil } -func (n nopAppender) AppendHistogram(ref storage.SeriesRef, l labels.Labels, t int64, h *histogram.Histogram) (storage.SeriesRef, error) { +func (n nopAppender) AppendHistogram(ref storage.SeriesRef, l labels.Labels, t int64, h *histogram.Histogram, fh *histogram.FloatHistogram) (storage.SeriesRef, error) { return 0, nil } diff --git a/pkg/store/storepb/testutil/series.go b/pkg/store/storepb/testutil/series.go index 64baf181d5..04a33af7a6 100644 --- a/pkg/store/storepb/testutil/series.go +++ b/pkg/store/storepb/testutil/series.go @@ -25,6 +25,7 @@ import ( "github.com/prometheus/prometheus/tsdb/wlog" "github.com/efficientgo/core/testutil" + "github.com/thanos-io/thanos/pkg/store/hintspb" "github.com/thanos-io/thanos/pkg/store/labelpb" "github.com/thanos-io/thanos/pkg/store/storepb" @@ -121,9 +122,12 @@ func CreateHeadWithSeries(t testing.TB, j int, opts HeadGenOptions) (*tsdb.Head, expected = make([]*storepb.Series, 0, opts.Series) ) + var builder labels.ScratchBuilder + all := allPostings(t, ir) for all.Next() { - testutil.Ok(t, ir.Series(all.At(), &lset, &chunkMetas)) + testutil.Ok(t, ir.Series(all.At(), &builder, &chunkMetas)) + lset = builder.Labels() expected = append(expected, &storepb.Series{Labels: labelpb.ZLabelsFromPromLabels(append(opts.PrependLabels.Copy(), lset...))}) if opts.SkipChunks { diff --git a/pkg/store/tsdb.go b/pkg/store/tsdb.go index d876872e2e..134a087076 100644 --- a/pkg/store/tsdb.go +++ b/pkg/store/tsdb.go @@ -186,7 +186,7 @@ func (s *TSDBStore) Series(r *storepb.SeriesRequest, srv storepb.Store_SeriesSer frameBytesLeft := bytesLeftForChunks seriesChunks := []storepb.AggrChunk{} - chIter := series.Iterator() + chIter := series.Iterator(nil) isNext := chIter.Next() for isNext { chk := chIter.At() diff --git a/test/e2e/native_histograms_test.go b/test/e2e/native_histograms_test.go index 30ede9bfd6..a5d9453021 100644 --- a/test/e2e/native_histograms_test.go +++ b/test/e2e/native_histograms_test.go @@ -14,6 +14,7 @@ import ( "github.com/prometheus/prometheus/model/histogram" "github.com/prometheus/prometheus/prompb" "github.com/prometheus/prometheus/storage/remote" + "github.com/thanos-io/thanos/pkg/promclient" "github.com/thanos-io/thanos/pkg/receive" "github.com/thanos-io/thanos/test/e2e/e2ethanos" @@ -162,7 +163,7 @@ func bucketToSampleHistogramBucket(bucket histogram.Bucket[uint64]) *model.Histo } } -func boundaries(bucket histogram.Bucket[uint64]) int { +func boundaries(bucket histogram.Bucket[uint64]) int32 { switch { case bucket.UpperInclusive && !bucket.LowerInclusive: return 0