-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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: Expose bucket index operation duration histogram #2725
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
ed23bd7
Expose bucket fetch operation duration histograms
kakkoyun fc3b35e
Apply suggestions from code review
kakkoyun 2412be2
Merge histograms
kakkoyun 8a46f33
Use another approach to track index operations
kakkoyun eb19e64
Split lookup duration histograms
kakkoyun 7c0ad19
Use timer API
kakkoyun d603da7
Rename and clarify description
kakkoyun File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -111,6 +111,9 @@ type bucketStoreMetrics struct { | |||||
cachedPostingsCompressionTimeSeconds *prometheus.CounterVec | ||||||
cachedPostingsOriginalSizeBytes prometheus.Counter | ||||||
cachedPostingsCompressedSizeBytes prometheus.Counter | ||||||
|
||||||
seriesLookupDuration prometheus.Histogram | ||||||
postingsLookupDuration prometheus.Histogram | ||||||
} | ||||||
|
||||||
func newBucketStoreMetrics(reg prometheus.Registerer) *bucketStoreMetrics { | ||||||
|
@@ -221,6 +224,18 @@ func newBucketStoreMetrics(reg prometheus.Registerer) *bucketStoreMetrics { | |||||
Help: "Compressed size of postings stored into cache.", | ||||||
}) | ||||||
|
||||||
m.seriesLookupDuration = promauto.With(reg).NewHistogram(prometheus.HistogramOpts{ | ||||||
Name: "thanos_bucket_store_index_series_lookup_duration_seconds", | ||||||
Help: "Time it takes to lookup series from a bucket to respond a query. It also includes the cache fetch and store operations.", | ||||||
Buckets: []float64{0.001, 0.01, 0.1, 0.3, 0.6, 1, 3, 6, 9, 20, 30, 60, 90, 120}, | ||||||
}) | ||||||
|
||||||
m.postingsLookupDuration = promauto.With(reg).NewHistogram(prometheus.HistogramOpts{ | ||||||
Name: "thanos_bucket_store_index_postings_lookup_duration_seconds", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I would add |
||||||
Help: "Time it takes to lookup postings from a bucket to respond a query. It also includes the cache fetch and store operations.", | ||||||
Buckets: []float64{0.001, 0.01, 0.1, 0.3, 0.6, 1, 3, 6, 9, 20, 30, 60, 90, 120}, | ||||||
}) | ||||||
|
||||||
return &m | ||||||
} | ||||||
|
||||||
|
@@ -473,7 +488,14 @@ func (s *BucketStore) addBlock(ctx context.Context, meta *metadata.Meta) (err er | |||||
lset := labels.FromMap(meta.Thanos.Labels) | ||||||
h := lset.Hash() | ||||||
|
||||||
indexHeaderReader, err := indexheader.NewBinaryReader(ctx, s.logger, s.bkt, s.dir, meta.ULID, s.postingOffsetsInMemSampling) | ||||||
indexHeaderReader, err := indexheader.NewBinaryReader( | ||||||
ctx, | ||||||
s.logger, | ||||||
s.bkt, | ||||||
s.dir, | ||||||
meta.ULID, | ||||||
s.postingOffsetsInMemSampling, | ||||||
) | ||||||
if err != nil { | ||||||
return errors.Wrap(err, "create index header reader") | ||||||
} | ||||||
|
@@ -486,14 +508,14 @@ func (s *BucketStore) addBlock(ctx context.Context, meta *metadata.Meta) (err er | |||||
b, err := newBucketBlock( | ||||||
ctx, | ||||||
log.With(s.logger, "block", meta.ULID), | ||||||
s.metrics, | ||||||
meta, | ||||||
s.bkt, | ||||||
dir, | ||||||
s.indexCache, | ||||||
s.chunkPool, | ||||||
indexHeaderReader, | ||||||
s.partitioner, | ||||||
s.metrics.seriesRefetches, | ||||||
s.enablePostingsCompression, | ||||||
) | ||||||
if err != nil { | ||||||
|
@@ -1258,6 +1280,7 @@ func (s *bucketBlockSet) labelMatchers(matchers ...*labels.Matcher) ([]*labels.M | |||||
// state for the block on local disk. | ||||||
type bucketBlock struct { | ||||||
logger log.Logger | ||||||
metrics *bucketStoreMetrics | ||||||
bkt objstore.BucketReader | ||||||
meta *metadata.Meta | ||||||
dir string | ||||||
|
@@ -1272,8 +1295,6 @@ type bucketBlock struct { | |||||
|
||||||
partitioner partitioner | ||||||
|
||||||
seriesRefetches prometheus.Counter | ||||||
|
||||||
enablePostingsCompression bool | ||||||
|
||||||
// Block's labels used by block-level matchers to filter blocks to query. These are used to select blocks using | ||||||
|
@@ -1284,26 +1305,26 @@ type bucketBlock struct { | |||||
func newBucketBlock( | ||||||
ctx context.Context, | ||||||
logger log.Logger, | ||||||
metrics *bucketStoreMetrics, | ||||||
meta *metadata.Meta, | ||||||
bkt objstore.BucketReader, | ||||||
dir string, | ||||||
indexCache storecache.IndexCache, | ||||||
chunkPool pool.BytesPool, | ||||||
indexHeadReader indexheader.Reader, | ||||||
p partitioner, | ||||||
seriesRefetches prometheus.Counter, | ||||||
enablePostingsCompression bool, | ||||||
) (b *bucketBlock, err error) { | ||||||
b = &bucketBlock{ | ||||||
logger: logger, | ||||||
metrics: metrics, | ||||||
bkt: bkt, | ||||||
indexCache: indexCache, | ||||||
chunkPool: chunkPool, | ||||||
dir: dir, | ||||||
partitioner: p, | ||||||
meta: meta, | ||||||
indexHeaderReader: indexHeadReader, | ||||||
seriesRefetches: seriesRefetches, | ||||||
enablePostingsCompression: enablePostingsCompression, | ||||||
} | ||||||
|
||||||
|
@@ -1610,6 +1631,9 @@ type postingPtr struct { | |||||
// It returns one postings for each key, in the same order. | ||||||
// If postings for given key is not fetched, entry at given index will be nil. | ||||||
func (r *bucketIndexReader) fetchPostings(keys []labels.Label) ([]index.Postings, error) { | ||||||
start := time.Now() | ||||||
defer r.block.metrics.postingsLookupDuration.Observe(time.Since(start).Seconds()) | ||||||
kakkoyun marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
||||||
var ptrs []postingPtr | ||||||
|
||||||
output := make([]index.Postings, len(keys)) | ||||||
|
@@ -1827,6 +1851,9 @@ func (it *bigEndianPostings) length() int { | |||||
} | ||||||
|
||||||
func (r *bucketIndexReader) PreloadSeries(ids []uint64) error { | ||||||
start := time.Now() | ||||||
defer r.block.metrics.seriesLookupDuration.Observe(float64(time.Since(start))) | ||||||
|
||||||
// Load series from cache, overwriting the list of ids to preload | ||||||
// with the missing ones. | ||||||
fromCache, ids := r.block.indexCache.FetchMultiSeries(r.ctx, r.block.meta.ULID, ids) | ||||||
|
@@ -1877,7 +1904,7 @@ func (r *bucketIndexReader) loadSeries(ctx context.Context, ids []uint64, refetc | |||||
} | ||||||
|
||||||
// Inefficient, but should be rare. | ||||||
r.block.seriesRefetches.Inc() | ||||||
r.block.metrics.seriesRefetches.Inc() | ||||||
level.Warn(r.block.logger).Log("msg", "series size exceeded expected size; refetching", "id", id, "series length", n+int(l), "maxSeriesSize", maxSeriesSize) | ||||||
|
||||||
// Fetch plus to get the size of next one if exists. | ||||||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we have just label? It will much easier to aggregate, plus we already do that for other statistics, WDYT?
I think also bucket can be adjusted for timeout. BTW What lookup means is quite vague by this help 🤔 Maybe we can be explicit more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bwplotka The first version was using a single histogram with labels 8a46f33. Then I decided to change it, just to be consistent with what we already have in here.
I'm gonna change the name as you suggested and try to clarify the description.
I've put the boundary at the query timeout. Which timeout value is used for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bwplotka friendly ping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok for now 👍