|
|
@ -30,6 +30,7 @@ import (
|
|
|
|
"text/tabwriter"
|
|
|
|
"text/tabwriter"
|
|
|
|
"time"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/alecthomas/units"
|
|
|
|
"github.com/go-kit/kit/log"
|
|
|
|
"github.com/go-kit/kit/log"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
"github.com/pkg/errors"
|
|
|
|
"github.com/prometheus/prometheus/pkg/labels"
|
|
|
|
"github.com/prometheus/prometheus/pkg/labels"
|
|
|
@ -363,12 +364,12 @@ 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\tDURATION\tNUM SAMPLES\tNUM CHUNKS\tNUM SERIES")
|
|
|
|
fmt.Fprintln(tw, "BLOCK ULID\tMIN TIME\tMAX TIME\tDURATION\tNUM SAMPLES\tNUM CHUNKS\tNUM SERIES\tSIZE")
|
|
|
|
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\t%v\n",
|
|
|
|
"%v\t%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),
|
|
|
@ -376,6 +377,7 @@ func printBlocks(blocks []tsdb.BlockReader, humanReadable bool) {
|
|
|
|
meta.Stats.NumSamples,
|
|
|
|
meta.Stats.NumSamples,
|
|
|
|
meta.Stats.NumChunks,
|
|
|
|
meta.Stats.NumChunks,
|
|
|
|
meta.Stats.NumSeries,
|
|
|
|
meta.Stats.NumSeries,
|
|
|
|
|
|
|
|
getFormatedBytes(b.Size(), humanReadable),
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -387,6 +389,13 @@ func getFormatedTime(timestamp int64, humanReadable bool) string {
|
|
|
|
return strconv.FormatInt(timestamp, 10)
|
|
|
|
return strconv.FormatInt(timestamp, 10)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func getFormatedBytes(bytes int64, humanReadable bool) string {
|
|
|
|
|
|
|
|
if humanReadable {
|
|
|
|
|
|
|
|
return units.Base2Bytes(bytes).String()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return strconv.FormatInt(bytes, 10)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func openBlock(path, blockID string) (*tsdb.DBReadOnly, tsdb.BlockReader, error) {
|
|
|
|
func openBlock(path, blockID string) (*tsdb.DBReadOnly, tsdb.BlockReader, error) {
|
|
|
|
db, err := tsdb.OpenDBReadOnly(path, nil)
|
|
|
|
db, err := tsdb.OpenDBReadOnly(path, nil)
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|