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

Support specifying series matchers to analyze tsdb #12842

Merged
merged 2 commits into from Sep 20, 2023

Conversation

yeya24
Copy link
Contributor

@yeya24 yeya24 commented Sep 13, 2023

Add match flag to specify matchers to analyze specific series.
Example usage below. Only series that matched up{job="thanos"} will be queried.

promtool tsdb analyze data 01H8QNNSR7SHY0W001YB29WTBZ --match='up{job="thanos"}'

Block ID: 01H8QNNSR7SHY0W001YB29WTBZ
Duration: 1h59m59.314s
Total Series: 60
Matcher: up{job="thanos"}
Label names: 3
Matched series: 1
Postings (unique label pairs): 3
Postings entries (total label pairs): 3

Label pairs most involved in churning:
0 job=thanos
0 __name__=up
0 instance=localhost:10906

Label names most involved in churning:
0 __name__
0 instance
0 job

Most common label pairs:
1 __name__=up
1 instance=localhost:10906
1 job=thanos

Label names with highest cumulative label value length:
15 instance
6 job
2 __name__

Highest cardinality labels:
1 __name__
1 instance
1 job

Highest cardinality metric names:
1 up

@yeya24 yeya24 requested a review from dgl as a code owner September 13, 2023 22:40
@@ -218,6 +218,7 @@ func main() {
analyzeBlockID := tsdbAnalyzeCmd.Arg("block id", "Block to analyze (default is the last block).").String()
analyzeLimit := tsdbAnalyzeCmd.Flag("limit", "How many items to show in each list.").Default("20").Int()
analyzeRunExtended := tsdbAnalyzeCmd.Flag("extended", "Run extended analysis.").Bool()
analyzeMatchers := tsdbAnalyzeCmd.Flag("match", "Series selector to analyze. Only 1 set of matchers is supported now.").String()
Copy link
Member

@dgl dgl Sep 13, 2023

Choose a reason for hiding this comment

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

Fairly sure this can just be .Strings() and then multiple matchers would work?

Copy link
Member

Choose a reason for hiding this comment

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

Ah, no a bit more complex, fine to keep as it is, it's just a bit inconsistent with other --match options.

Copy link
Contributor Author

@yeya24 yeya24 Sep 13, 2023

Choose a reason for hiding this comment

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

Yeah it will be a little bit more complex overall. We only support one single matcher for tsdb dump command as well.
We can have a separate issue to track if we want to have more matchers in the future.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for this.
We're interested in having multiple matchers for tsdb dump, I can create an issue and maybe give it a try.

Copy link
Member

@dgl dgl left a comment

Choose a reason for hiding this comment

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

Need to regenerate docs.

@yeya24
Copy link
Contributor Author

yeya24 commented Sep 13, 2023

Updated the doc.

Signed-off-by: Ben Ye <benye@amazon.com>
Signed-off-by: Ben Ye <benye@amazon.com>
@yeya24
Copy link
Contributor Author

yeya24 commented Sep 14, 2023

Fixed merged conflicts. @dgl Please take another look, thanks

@yeya24
Copy link
Contributor Author

yeya24 commented Sep 17, 2023

PTAL @dgl, thanks

Copy link
Member

@bwplotka bwplotka 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, thanks!

@bwplotka bwplotka merged commit c781244 into prometheus:main Sep 20, 2023
23 checks passed
@yeya24 yeya24 deleted the analyze-block-selector branch October 27, 2023 23:50
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.

None yet

4 participants