Skip to content

Commit a28ca8f

Browse files
fhalimwbh1
authored andcommitted
Allow setting TSDB block duration for receive service (thanos-io#1496)
* Allow setting TSDB block duration Signed-off-by: Fawad Halim <[email protected]> * PR feedback: corrected flag naming, made the flag hidden by default Signed-off-by: Fawad Halim <[email protected]> * Enable WALCompression on Receive service Signed-off-by: Fawad Halim <[email protected]>
1 parent d19d55b commit a28ca8f

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

cmd/thanos/receive.go

+7-2
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,8 @@ func registerReceive(m map[string]setupFunc, app *kingpin.Application, name stri
6060

6161
replicationFactor := cmd.Flag("receive.replication-factor", "How many times to replicate incoming write requests.").Default("1").Uint64()
6262

63+
tsdbBlockDuration := modelDuration(cmd.Flag("tsdb.block-duration", "Duration for local TSDB blocks").Default("2h").Hidden())
64+
6365
m[name] = func(g *run.Group, logger log.Logger, reg *prometheus.Registry, tracer opentracing.Tracer, _ bool) error {
6466
lset, err := parseFlagLabels(*labelStrs)
6567
if err != nil {
@@ -106,6 +108,7 @@ func registerReceive(m map[string]setupFunc, app *kingpin.Application, name stri
106108
*tenantHeader,
107109
*replicaHeader,
108110
*replicationFactor,
111+
*tsdbBlockDuration,
109112
)
110113
}
111114
}
@@ -130,15 +133,17 @@ func runReceive(
130133
tenantHeader string,
131134
replicaHeader string,
132135
replicationFactor uint64,
136+
tsdbBlockDuration model.Duration,
133137
) error {
134138
logger = log.With(logger, "component", "receive")
135139
level.Warn(logger).Log("msg", "setting up receive; the Thanos receive component is EXPERIMENTAL, it may break significantly without notice")
136140

137141
tsdbCfg := &tsdb.Options{
138142
RetentionDuration: retention,
139143
NoLockfile: true,
140-
MinBlockDuration: model.Duration(time.Hour * 2),
141-
MaxBlockDuration: model.Duration(time.Hour * 2),
144+
MinBlockDuration: tsdbBlockDuration,
145+
MaxBlockDuration: tsdbBlockDuration,
146+
WALCompression: true,
142147
}
143148

144149
localStorage := &tsdb.ReadyStorage{}

0 commit comments

Comments
 (0)