mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
Merge pull request #9312 from fpetkovski/promtool-analyze-compaction
promtool: add extended flag for tsdb analysis
This commit is contained in:
commit
0111aa987e
|
@ -137,6 +137,7 @@ func main() {
|
||||||
analyzePath := tsdbAnalyzeCmd.Arg("db path", "Database path (default is "+defaultDBPath+").").Default(defaultDBPath).String()
|
analyzePath := tsdbAnalyzeCmd.Arg("db path", "Database path (default is "+defaultDBPath+").").Default(defaultDBPath).String()
|
||||||
analyzeBlockID := tsdbAnalyzeCmd.Arg("block id", "Block to analyze (default is the last block).").String()
|
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()
|
analyzeLimit := tsdbAnalyzeCmd.Flag("limit", "How many items to show in each list.").Default("20").Int()
|
||||||
|
analyzeRunExtended := tsdbAnalyzeCmd.Flag("extended", "Run extended analysis.").Bool()
|
||||||
|
|
||||||
tsdbListCmd := tsdbCmd.Command("list", "List tsdb blocks.")
|
tsdbListCmd := tsdbCmd.Command("list", "List tsdb blocks.")
|
||||||
listHumanReadable := tsdbListCmd.Flag("human-readable", "Print human readable values.").Short('r').Bool()
|
listHumanReadable := tsdbListCmd.Flag("human-readable", "Print human readable values.").Short('r').Bool()
|
||||||
|
@ -237,7 +238,7 @@ func main() {
|
||||||
os.Exit(checkErr(benchmarkWrite(*benchWriteOutPath, *benchSamplesFile, *benchWriteNumMetrics, *benchWriteNumScrapes)))
|
os.Exit(checkErr(benchmarkWrite(*benchWriteOutPath, *benchSamplesFile, *benchWriteNumMetrics, *benchWriteNumScrapes)))
|
||||||
|
|
||||||
case tsdbAnalyzeCmd.FullCommand():
|
case tsdbAnalyzeCmd.FullCommand():
|
||||||
os.Exit(checkErr(analyzeBlock(*analyzePath, *analyzeBlockID, *analyzeLimit)))
|
os.Exit(checkErr(analyzeBlock(*analyzePath, *analyzeBlockID, *analyzeLimit, *analyzeRunExtended)))
|
||||||
|
|
||||||
case tsdbListCmd.FullCommand():
|
case tsdbListCmd.FullCommand():
|
||||||
os.Exit(checkErr(listBlocks(*listPath, *listHumanReadable)))
|
os.Exit(checkErr(listBlocks(*listPath, *listHumanReadable)))
|
||||||
|
|
|
@ -418,7 +418,7 @@ func openBlock(path, blockID string) (*tsdb.DBReadOnly, tsdb.BlockReader, error)
|
||||||
return db, block, nil
|
return db, block, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func analyzeBlock(path, blockID string, limit int) error {
|
func analyzeBlock(path, blockID string, limit int, runExtended bool) error {
|
||||||
db, block, err := openBlock(path, blockID)
|
db, block, err := openBlock(path, blockID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
@ -564,9 +564,13 @@ func analyzeBlock(path, blockID string, limit int) error {
|
||||||
fmt.Printf("\nHighest cardinality metric names:\n")
|
fmt.Printf("\nHighest cardinality metric names:\n")
|
||||||
printInfo(postingInfos)
|
printInfo(postingInfos)
|
||||||
|
|
||||||
|
if runExtended {
|
||||||
return analyzeCompaction(block, ir)
|
return analyzeCompaction(block, ir)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func analyzeCompaction(block tsdb.BlockReader, indexr tsdb.IndexReader) (err error) {
|
func analyzeCompaction(block tsdb.BlockReader, indexr tsdb.IndexReader) (err error) {
|
||||||
postingsr, err := indexr.Postings(index.AllPostingsKey())
|
postingsr, err := indexr.Postings(index.AllPostingsKey())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue