Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Store: Make queryStats log with human-readable format. #4885

Merged
merged 2 commits into from
Nov 29, 2021

Conversation

hanjm
Copy link
Member

@hanjm hanjm commented Nov 20, 2021

The queryStats log is very useful to debug query in thanos-store.
But currently the duration field is unexported so that fmt.Printf("%+v", stats) print a number for time.Duration.

Before:

level=debug msg="stats query processed" stats="&{blocksQueried:1 postingsTouched:102 postingsTouchedSizeSum:1122 postingsToFetch:0 postingsFetched:1 postingsFetchedSizeSum:404 postingsFetchCount:1 postingsFetchDurationSum:162905 cachedPostingsCompressions:1 cachedPostingsCompressionErrors:0 cachedPostingsOriginalSizeSum:404 cachedPostingsCompressedSizeSum:18 cachedPostingsCompressionTimeSum:29569 cachedPostingsDecompressions:101 cachedPostingsDecompressionErrors:0 cachedPostingsDecompressionTimeSum:65901 seriesTouched:100 seriesTouchedSizeSum:1229 seriesFetched:54 seriesFetchedSizeSum:67120 seriesFetchCount:1 seriesFetchDurationSum:247635 chunksTouched:100 chunksTouchedSizeSum:1236 chunksFetched:100 chunksFetchedSizeSum:17817 chunksFetchCount:1 chunksFetchDurationSum:135030 getAllDuration:1744138 mergedSeriesCount:100 mergedChunksCount:100 mergeDuration:106200}" err=null

After:

Logs

level=debug msg="stats query processed" request="max_time:99 matchers: matchers: matchers: " stats="&{blocksQueried:2 postingsTouched:203 postingsTouchedSizeSum:2812 postingsToFetch:0 postingsFetched:203 postingsFetchedSizeSum:4478 postingsFetchCount:2 PostingsFetchDurationSum:576.127µs cachedPostingsCompressions:203 cachedPostingsCompressionErrors:0 cachedPostingsOriginalSizeSum:2812 cachedPostingsCompressedSizeSum:1454 CachedPostingsCompressionTimeSum:358.132µs cachedPostingsDecompressions:0 cachedPostingsDecompressionErrors:0 CachedPostingsDecompressionTimeSum:0s seriesTouched:100 seriesTouchedSizeSum:1229 seriesFetched:100 seriesFetchedSizeSum:68592 seriesFetchCount:1 SeriesFetchDurationSum:353.677µs chunksTouched:100 chunksTouchedSizeSum:1236 chunksFetched:100 chunksFetchedSizeSum:17817 chunksFetchCount:1 ChunksFetchDurationSum:221.653µs GetAllDuration:4.764037ms mergedSeriesCount:100 mergedChunksCount:100 MergeDuration:127.72µs}" err=null

Signed-off-by: Jimmie Han hanjinming@outlook.com

  • I added CHANGELOG entry for this change.
  • Change is not relevant to the end user.

Changes

  1. Exporte time.Duration type field.
  2. add request field to log.
  3. change the xxsizeSum field type to units.Base2bytes

Verification

Unit test

@hanjm
Copy link
Member Author

hanjm commented Nov 20, 2021

A bit more idea,Could i add a flag to only log duration logger than specific value? like thanos-query does.

@hanjm
Copy link
Member Author

hanjm commented Nov 21, 2021

The second commit change the xxsizeSum field type to units.Base2bytes, which log human-readable format.

level=debug msg="stats query processed" request="max_time:99 matchers:<name:"foo" value:"bar" > matchers:<name:"b" value:"1" > matchers:<type:NEQ name:"i" > " stats="&{blocksQueried:1 postingsTouched:102 PostingsTouchedSizeSum:1KiB98B postingsToFetch:0 postingsFetched:1 PostingsFetchedSizeSum:404B postingsFetchCount:1 PostingsFetchDurationSum:81.635µs cachedPostingsCompressions:1 cachedPostingsCompressionErrors:0 CachedPostingsOriginalSizeSum:404B CachedPostingsCompressedSizeSum:18B CachedPostingsCompressionTimeSum:15.529µs cachedPostingsDecompressions:101 cachedPostingsDecompressionErrors:0 CachedPostingsDecompressionTimeSum:20.957µs seriesTouched:100 SeriesTouchedSizeSum:1KiB205B seriesFetched:54 SeriesFetchedSizeSum:65KiB560B seriesFetchCount:1 SeriesFetchDurationSum:115.953µs chunksTouched:100 ChunksTouchedSizeSum:1KiB212B chunksFetched:100 ChunksFetchedSizeSum:17KiB409B chunksFetchCount:1 ChunksFetchDurationSum:64.246µs GetAllDuration:823.856µs mergedSeriesCount:100 mergedChunksCount:100 MergeDuration:51.937µs}" err=null

@hanjm hanjm changed the title Store: export queryStats time.Duration field to log with human-readable format. Store: Make queryStats log with human-readable format. Nov 21, 2021
GiedriusS
GiedriusS previously approved these changes Nov 25, 2021
Copy link
Member

@GiedriusS GiedriusS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One nit - could you please see if it makes sense? This is a nice improvement. Please also rebase 💪

@hanjm
Copy link
Member Author

hanjm commented Nov 25, 2021

Thank you. Let me rebase it.

…le format.

Signed-off-by: Jimmie Han <hanjinming@outlook.com>
matej-g
matej-g previously approved these changes Nov 25, 2021
Copy link
Collaborator

@matej-g matej-g left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 🤘

@hanjm hanjm dismissed stale reviews from matej-g and GiedriusS via bf1f37e November 25, 2021 14:54
@hanjm hanjm force-pushed the feature/optimize-query-stats branch 3 times, most recently from d863d2f to 2b1a818 Compare November 25, 2021 15:07
…n-readable format.

Signed-off-by: Jimmie Han <hanjinming@outlook.com>
@hanjm hanjm force-pushed the feature/optimize-query-stats branch from 2b1a818 to 4973be8 Compare November 25, 2021 15:10
@hanjm
Copy link
Member Author

hanjm commented Nov 25, 2021

Rebase Done~ @GiedriusS

@hanjm hanjm requested a review from GiedriusS November 25, 2021 15:16
@GiedriusS GiedriusS merged commit 8f278cd into thanos-io:main Nov 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants