From 7b60aae18c6e8453eaf5b0f5d04f86db506b96f4 Mon Sep 17 00:00:00 2001 From: Herve Nicol <12008875+hervenicol@users.noreply.github.com> Date: Tue, 19 Sep 2023 16:00:40 +0200 Subject: [PATCH] improve agent shards calculation --- CHANGELOG.md | 4 ++++ pkg/prometheusquerier/querier.go | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 570ee5fc2..14b6c6cdf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- computation of number of shards: rely on max number of series over the last 6h. + ## [4.48.0] - 2023-09-19 ### Changed diff --git a/pkg/prometheusquerier/querier.go b/pkg/prometheusquerier/querier.go index e64250f93..9ed603d08 100644 --- a/pkg/prometheusquerier/querier.go +++ b/pkg/prometheusquerier/querier.go @@ -29,7 +29,7 @@ func QueryTSDBHeadSeries(cluster string) (float64, error) { api := v1.NewAPI(c) ctx, cancel := context.WithTimeout(context.Background(), 2*time.Minute) - val, _, err := api.Query(ctx, "prometheus_tsdb_head_series", time.Now()) // Ignoring warnings for now. + val, _, err := api.Query(ctx, "max_over_time(prometheus_tsdb_head_series[6h])", time.Now()) // Ignoring warnings for now. cancel() if err != nil { return 0, err