From e3faabe587079073e85f51c4e56de8143e27830c Mon Sep 17 00:00:00 2001 From: Fawad Halim Date: Thu, 5 Sep 2019 10:18:35 -0500 Subject: [PATCH] Allow setting TSDB block duration --- cmd/thanos/receive.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/cmd/thanos/receive.go b/cmd/thanos/receive.go index 85cd5a05326..abbf20b3697 100644 --- a/cmd/thanos/receive.go +++ b/cmd/thanos/receive.go @@ -60,6 +60,8 @@ func registerReceive(m map[string]setupFunc, app *kingpin.Application, name stri replicationFactor := cmd.Flag("receive.replication-factor", "How many times to replicate incoming write requests.").Default("1").Uint64() + tsdbBlockDuration := modelDuration(cmd.Flag("tsdb.blockduration", "Duration for local TSDB blocks").Default("2h")) + m[name] = func(g *run.Group, logger log.Logger, reg *prometheus.Registry, tracer opentracing.Tracer, _ bool) error { lset, err := parseFlagLabels(*labelStrs) if err != nil { @@ -106,6 +108,7 @@ func registerReceive(m map[string]setupFunc, app *kingpin.Application, name stri *tenantHeader, *replicaHeader, *replicationFactor, + *tsdbBlockDuration, ) } } @@ -130,6 +133,7 @@ func runReceive( tenantHeader string, replicaHeader string, replicationFactor uint64, + tsdbBlockDuration model.Duration, ) error { logger = log.With(logger, "component", "receive") level.Warn(logger).Log("msg", "setting up receive; the Thanos receive component is EXPERIMENTAL, it may break significantly without notice") @@ -137,8 +141,8 @@ func runReceive( tsdbCfg := &tsdb.Options{ RetentionDuration: retention, NoLockfile: true, - MinBlockDuration: model.Duration(time.Hour * 2), - MaxBlockDuration: model.Duration(time.Hour * 2), + MinBlockDuration: tsdbBlockDuration, + MaxBlockDuration: tsdbBlockDuration, } localStorage := &tsdb.ReadyStorage{}