mirror of
https://github.com/prometheus/prometheus.git
synced 2025-08-06 22:27:17 +02:00
promtool: Display aggregated contribution of top-N metric names
Print the total disk usage and percentage contributed by the top-N metric names in the disk usage analysis output. This helps users quickly assess how much of the storage is dominated by the most significant metrics. Co-authored-by: Istvan Zoltan Ballok <istvan.zoltan.ballok@sap.com> Signed-off-by: Victor Herrero Otal <victor.herrero.otal@sap.com>
This commit is contained in:
parent
c2706d5914
commit
ea87698892
@ -937,12 +937,21 @@ func displayDiskUsage(data map[string]uint64, total uint64) {
|
||||
})
|
||||
|
||||
fmt.Printf("Top %d metric names by disk usage:\n", n)
|
||||
|
||||
var sum uint64
|
||||
for i := range sorted[:n] {
|
||||
sum += sorted[i].v
|
||||
var percent float64
|
||||
if total > 0 {
|
||||
percent = float64(sorted[i].v) / float64(total) * 100
|
||||
}
|
||||
fmt.Printf("%12d bytes (%6.2f%%) %s\n", sorted[i].v, percent, sorted[i].k)
|
||||
}
|
||||
|
||||
var topPercent float64
|
||||
if total > 0 {
|
||||
topPercent = float64(sum) / float64(total) * 100
|
||||
}
|
||||
fmt.Printf(" total (top %8d): %12d bytes (%.2f%%)\n", n, sum, topPercent)
|
||||
fmt.Printf(" total (all %8d): %12d bytes\n", len(data), total)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user