Skip to content

Commit 7bb2850

Browse files
authored
Add stats log when querying store gateway (#5376)
* add stats log when querying store gateway Signed-off-by: Ben Ye <[email protected]> * update changelog Signed-off-by: Ben Ye <[email protected]> * add data_downloaded_size_sum Signed-off-by: Ben Ye <[email protected]> * update vendor Signed-off-by: Ben Ye <[email protected]> --------- Signed-off-by: Ben Ye <[email protected]>
1 parent 220683a commit 7bb2850

File tree

12 files changed

+1012
-49
lines changed

12 files changed

+1012
-49
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
* [FEATURE] Store Gateway: Add `max_downloaded_bytes_per_request` to limit max bytes to download per store gateway request.
1313
* [FEATURE] Added 2 flags `-alertmanager.alertmanager-client.grpc-max-send-msg-size` and ` -alertmanager.alertmanager-client.grpc-max-recv-msg-size` to configure alert manager grpc client message size limits. #5338
1414
* [FEATURE] Query Frontend: Add `cortex_rejected_queries_total` metric for throttled queries. #5356
15+
* [FEATURE] Querier: Log query stats when querying store gateway. #5376
1516
* [ENHANCEMENT] Distributor/Ingester: Add span on push path #5319
1617
* [ENHANCEMENT] Support object storage backends for runtime configuration file. #5292
1718
* [ENHANCEMENT] Query Frontend: Reject subquery with too small step size. #5323

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ require (
5252
github.com/spf13/afero v1.9.5
5353
github.com/stretchr/testify v1.8.3
5454
github.com/thanos-io/objstore v0.0.0-20230201072718-11ffbc490204
55-
github.com/thanos-io/promql-engine v0.0.0-20230524173220-ac7dd841e96a
56-
github.com/thanos-io/thanos v0.0.0-20230524201324-c4321c5e1de2
55+
github.com/thanos-io/promql-engine v0.0.0-20230526105742-791d78b260ea
56+
github.com/thanos-io/thanos v0.31.1-0.20230602190045-fbc88857d78c
5757
github.com/uber/jaeger-client-go v2.30.0+incompatible
5858
github.com/weaveworks/common v0.0.0-20221201103051-7c2720a9024d
5959
go.etcd.io/etcd/api/v3 v3.5.8

go.sum

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ github.com/edsrzf/mmap-go v1.1.0 h1:6EUwBLQ/Mcr1EYLE4Tn1VdW1A4ckqCQWZBw8Hr0kjpQ=
849849
github.com/edsrzf/mmap-go v1.1.0/go.mod h1:19H/e8pUPLicwkyNgOykDXkJ9F0MHE+Z52B8EIth78Q=
850850
github.com/efficientgo/core v1.0.0-rc.2 h1:7j62qHLnrZqO3V3UA0AqOGd5d5aXV3AX6m/NZBHp78I=
851851
github.com/efficientgo/core v1.0.0-rc.2/go.mod h1:FfGdkzWarkuzOlY04VY+bGfb1lWrjaL6x/GLcQ4vJps=
852-
github.com/efficientgo/e2e v0.14.1-0.20230413163036-7a7e0bae9913 h1:/CcqWjW1rMnoYiiKpiVKcReOJCGnCo868z85g7TwRhg=
852+
github.com/efficientgo/e2e v0.14.1-0.20230530075226-84bb33e062c4 h1:8w29+abukpj2UWN19wZ4xmOswdrYBjfqmbot9oppp3U=
853853
github.com/efficientgo/tools/extkingpin v0.0.0-20220817170617-6c25e3b627dd h1:VaYzzXeUbC5fVheskcKVNOyJMEYD+HgrJNzIAg/mRIM=
854854
github.com/efficientgo/tools/extkingpin v0.0.0-20220817170617-6c25e3b627dd/go.mod h1:ZV0utlglOczUWv3ih2AbqPSoLoFzdplUYxwV62eZi6Q=
855855
github.com/elazarl/goproxy v0.0.0-20180725130230-947c36da3153/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc=
@@ -1867,10 +1867,10 @@ github.com/thanos-community/galaxycache v0.0.0-20211122094458-3a32041a1f1e h1:f1
18671867
github.com/thanos-community/galaxycache v0.0.0-20211122094458-3a32041a1f1e/go.mod h1:jXcofnrSln/cLI6/dhlBxPQZEEQHVPCcFaH75M+nSzM=
18681868
github.com/thanos-io/objstore v0.0.0-20230201072718-11ffbc490204 h1:W4w5Iph7j32Sf1QFWLJDCqvO0WgZS0jHGID+qnq3wV0=
18691869
github.com/thanos-io/objstore v0.0.0-20230201072718-11ffbc490204/go.mod h1:STSgpY8M6EKF2G/raUFdbIMf2U9GgYlEjAEHJxjvpAo=
1870-
github.com/thanos-io/promql-engine v0.0.0-20230524173220-ac7dd841e96a h1:B0QFv7nykRtUt6YfYtHs8k96bZt8+HnqbZRzPutil80=
1871-
github.com/thanos-io/promql-engine v0.0.0-20230524173220-ac7dd841e96a/go.mod h1:eIgPaXWgOhNAv6CPPrgu09r0AtT7byBTZy+7WkX0D18=
1872-
github.com/thanos-io/thanos v0.0.0-20230524201324-c4321c5e1de2 h1:8unrRqovq5JbPqAuYoR9gxRZnxlkE5XesXBiJ5sg800=
1873-
github.com/thanos-io/thanos v0.0.0-20230524201324-c4321c5e1de2/go.mod h1:VgKd9z92eKZnZDjqhLwEkYryWzVwNBJgUES9gA6Ky/E=
1870+
github.com/thanos-io/promql-engine v0.0.0-20230526105742-791d78b260ea h1:kzK8sBn2+mo3NAxP+XjAjAqr1hwfxxFUy5CybaBkjAI=
1871+
github.com/thanos-io/promql-engine v0.0.0-20230526105742-791d78b260ea/go.mod h1:eIgPaXWgOhNAv6CPPrgu09r0AtT7byBTZy+7WkX0D18=
1872+
github.com/thanos-io/thanos v0.31.1-0.20230602190045-fbc88857d78c h1:XlhPcKRo4eQ5He/2+8Vfmfkxz+1skwEBuYVgMFBqePE=
1873+
github.com/thanos-io/thanos v0.31.1-0.20230602190045-fbc88857d78c/go.mod h1:lHSiSsXIQuAv5u+6yu0LLw6cS/MC8vUQswQ6rkdxB7c=
18741874
github.com/themihai/gomemcache v0.0.0-20180902122335-24332e2d58ab h1:7ZR3hmisBWw77ZpO1/o86g+JV3VKlk3d48jopJxzTjU=
18751875
github.com/themihai/gomemcache v0.0.0-20180902122335-24332e2d58ab/go.mod h1:eheTFp954zcWZXCU8d0AT76ftsQOTo4DTqkN/h3k1MY=
18761876
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=

pkg/querier/blocks_store_queryable.go

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -583,7 +583,6 @@ func (q *blocksStoreQuerier) fetchSeriesFromStores(
583583

584584
if err != nil {
585585
return nil, nil, nil, 0, err
586-
587586
}
588587
convertedMatchers := convertMatchersToLabelMatcher(matchers)
589588

@@ -601,6 +600,7 @@ func (q *blocksStoreQuerier) fetchSeriesFromStores(
601600

602601
// Only fail the function if we have validation error. We should return blocks that were successfully
603602
// retrieved.
603+
seriesQueryStats := &hintspb.QueryStats{}
604604
skipChunks := sp != nil && sp.Func == "series"
605605

606606
req, err := createSeriesRequest(minT, maxT, convertedMatchers, shardingInfo, skipChunks, blockIDs)
@@ -698,6 +698,9 @@ func (q *blocksStoreQuerier) fetchSeriesFromStores(
698698
}
699699

700700
myQueriedBlocks = append(myQueriedBlocks, ids...)
701+
if hints.QueryStats != nil {
702+
seriesQueryStats.Merge(hints.QueryStats)
703+
}
701704
}
702705
}
703706

@@ -714,14 +717,35 @@ func (q *blocksStoreQuerier) fetchSeriesFromStores(
714717

715718
level.Debug(spanLog).Log("msg", "received series from store-gateway",
716719
"instance", c.RemoteAddress(),
717-
"fetched series", numSeries,
718-
"fetched chunks", chunksCount,
719-
"fetched samples", numSamples,
720-
"fetched chunk bytes", chunkBytes,
721-
"fetched data bytes", dataBytes,
722720
"requested blocks", strings.Join(convertULIDsToString(blockIDs), " "),
723721
"queried blocks", strings.Join(convertULIDsToString(myQueriedBlocks), " "))
724722

723+
level.Info(spanLog).Log("msg", "store gateway series request stats",
724+
"instance", c.RemoteAddress(),
725+
"queryable_chunk_bytes_fetched", chunkBytes,
726+
"queryable_data_bytes_fetched", dataBytes,
727+
"blocks_queried", seriesQueryStats.BlocksQueried,
728+
"series_merged_count", seriesQueryStats.MergedSeriesCount,
729+
"chunks_merged_count", seriesQueryStats.MergedChunksCount,
730+
"postings_touched", seriesQueryStats.PostingsTouched,
731+
"postings_touched_size_sum", seriesQueryStats.PostingsTouchedSizeSum,
732+
"postings_to_fetch", seriesQueryStats.PostingsToFetch,
733+
"postings_fetched", seriesQueryStats.PostingsFetched,
734+
"postings_fetch_count", seriesQueryStats.PostingsFetchCount,
735+
"postings_fetched_size_sum", seriesQueryStats.PostingsFetchedSizeSum,
736+
"series_touched", seriesQueryStats.SeriesTouched,
737+
"series_touched_size_sum", seriesQueryStats.SeriesTouchedSizeSum,
738+
"series_fetched", seriesQueryStats.SeriesFetched,
739+
"series_fetch_count", seriesQueryStats.SeriesFetchCount,
740+
"series_fetched_size_sum", seriesQueryStats.SeriesFetchedSizeSum,
741+
"chunks_touched", seriesQueryStats.ChunksTouched,
742+
"chunks_touched_size_sum", seriesQueryStats.ChunksTouchedSizeSum,
743+
"chunks_fetched", seriesQueryStats.ChunksFetched,
744+
"chunks_fetch_count", seriesQueryStats.ChunksFetchCount,
745+
"chunks_fetched_size_sum", seriesQueryStats.ChunksFetchedSizeSum,
746+
"data_downloaded_size_sum", seriesQueryStats.DataDownloadedSizeSum,
747+
)
748+
725749
// Store the result.
726750
mtx.Lock()
727751
seriesSets = append(seriesSets, &blockQuerierSeriesSet{series: mySeries})
@@ -937,6 +961,7 @@ func createSeriesRequest(minT, maxT int64, matchers []storepb.LabelMatcher, shar
937961
Value: strings.Join(convertULIDsToString(blockIDs), "|"),
938962
},
939963
},
964+
EnableQueryStats: true,
940965
}
941966

942967
anyHints, err := types.MarshalAny(hints)

vendor/github.com/thanos-io/thanos/pkg/extprom/http/instrument_server.go

Lines changed: 4 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/thanos-io/thanos/pkg/shipper/shipper.go

Lines changed: 20 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/thanos-io/thanos/pkg/store/bucket.go

Lines changed: 44 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/thanos-io/thanos/pkg/store/hintspb/custom.go

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)