promtool: Fix panic on extended tsdb analyze (#13976)
Currently, running promtool tsdb analyze with the --extended flag will cause an 'index out of range' error if running it against a block that does not have any native histogram chunks. This change ensures that promtool won't try to display data that doesn't exist. Signed-off-by: Will Hegedus <whegedus@linode.com>
This commit is contained in:
parent
76b0318ed5
commit
bd1878700b
|
@ -838,6 +838,10 @@ func backfillOpenMetrics(path, outputDir string, humanReadable, quiet bool, maxB
|
|||
}
|
||||
|
||||
func displayHistogram(dataType string, datas []int, total int) {
|
||||
if len(datas) == 0 {
|
||||
fmt.Printf("%s: N/A\n\n", dataType)
|
||||
return
|
||||
}
|
||||
slices.Sort(datas)
|
||||
start, end, step := generateBucket(datas[0], datas[len(datas)-1])
|
||||
sum := 0
|
||||
|
|
Loading…
Reference in New Issue