Display block duration in promtool list blocks command (#7653)

* Update tsdb.go

Added DURATION column to `tsdb list` command

Signed-off-by: soup <chicknsoupuds@gmail.com>

* Use time.Duration instead of hardcoded hour

Signed-off-by: soup <chicknsoupuds@gmail.com>
pull/7661/head
chinhnc 4 years ago committed by GitHub
parent 6b7ac2ac1b
commit e05c19da5d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -363,15 +363,16 @@ func printBlocks(blocks []tsdb.BlockReader, humanReadable bool) {
tw := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0) tw := tabwriter.NewWriter(os.Stdout, 0, 0, 2, ' ', 0)
defer tw.Flush() defer tw.Flush()
fmt.Fprintln(tw, "BLOCK ULID\tMIN TIME\tMAX TIME\tNUM SAMPLES\tNUM CHUNKS\tNUM SERIES") fmt.Fprintln(tw, "BLOCK ULID\tMIN TIME\tMAX TIME\tDURATION\tNUM SAMPLES\tNUM CHUNKS\tNUM SERIES")
for _, b := range blocks { for _, b := range blocks {
meta := b.Meta() meta := b.Meta()
fmt.Fprintf(tw, fmt.Fprintf(tw,
"%v\t%v\t%v\t%v\t%v\t%v\n", "%v\t%v\t%v\t%v\t%v\t%v\t%v\n",
meta.ULID, meta.ULID,
getFormatedTime(meta.MinTime, humanReadable), getFormatedTime(meta.MinTime, humanReadable),
getFormatedTime(meta.MaxTime, humanReadable), getFormatedTime(meta.MaxTime, humanReadable),
time.Duration(meta.MaxTime-meta.MinTime)*time.Millisecond,
meta.Stats.NumSamples, meta.Stats.NumSamples,
meta.Stats.NumChunks, meta.Stats.NumChunks,
meta.Stats.NumSeries, meta.Stats.NumSeries,

Loading…
Cancel
Save