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

block-builder: Add cortex_blockbuilder_blocks_produced_total metric #10538

Merged
merged 5 commits into from
Feb 6, 2025

Conversation

codesome
Copy link
Member

What this PR does

Adds a metric to determine how many blocks were produced for previous, current, and next block period w.r.t. the cycle end time.

Checklist

  • Tests updated.
  • Documentation added.
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX].
  • about-versioning.md updated with experimental features.

@codesome codesome requested a review from a team as a code owner January 29, 2025 21:09
Comment on lines -77 to -80
if cfg.NoPartiallyConsumedRegion {
// We should not have a large buffer if we are putting all the records into a block.
cfg.ConsumeIntervalBuffer = 5 * time.Minute
}
Copy link
Member Author

Choose a reason for hiding this comment

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

By removing this override, we can now try different buffer times when we have set NoPartiallyConsumedRegion to true

Signed-off-by: Ganesh Vernekar <[email protected]>
pkg/blockbuilder/blockbuilder.go Outdated Show resolved Hide resolved
Comment on lines +615 to +618
prev, curr, next := getBlockCategoryCount(sectionEndTime, blockMetas)
b.blockBuilderMetrics.blockCounts.WithLabelValues("previous").Add(float64(prev))
b.blockBuilderMetrics.blockCounts.WithLabelValues("current").Add(float64(curr))
b.blockBuilderMetrics.blockCounts.WithLabelValues("next").Add(float64(next))
Copy link
Contributor

Choose a reason for hiding this comment

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

Have you considered putting these metrics inside TSDBBuilder.CompactAndUpload (ie. make them a part of tsdbMetrics collection). It feels this would require fewer changes in the overall code, and make "magic knowledge", like 2h block ranges, scoped closer together.

Copy link
Member Author

Choose a reason for hiding this comment

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

That was my first try, but giving the information about current block end to TSDB did not look right. I am not too worried about the number of lines of change here because it's mostly replacing old stuff and only a minor addition of this function.

Signed-off-by: Ganesh Vernekar <[email protected]>
Signed-off-by: Ganesh Vernekar <[email protected]>
Copy link
Contributor

@narqo narqo left a comment

Choose a reason for hiding this comment

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

🔥 Works for me

@codesome codesome merged commit b45851c into main Feb 6, 2025
28 checks passed
@codesome codesome deleted the codesome/bbmetrics branch February 6, 2025 23:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants