Skip to content

Commit

Permalink
receive: Add retention flag for local tsdb storage (#1046)
Browse files Browse the repository at this point in the history
  • Loading branch information
brancz authored Apr 18, 2019
1 parent 3b13aeb commit f847bfe
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cmd/thanos/receive.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ func registerReceive(m map[string]setupFunc, app *kingpin.Application, name stri

objStoreConfig := regCommonObjStoreFlags(cmd, "", false)

retention := modelDuration(cmd.Flag("tsdb.retention", "How long to retain raw samples on local storage. 0d - disables this retention").Default("15d"))

m[name] = func(g *run.Group, logger log.Logger, reg *prometheus.Registry, tracer opentracing.Tracer, _ bool) error {
lset, err := parseFlagLabels(*labelStrs)
if err != nil {
Expand All @@ -64,6 +66,7 @@ func registerReceive(m map[string]setupFunc, app *kingpin.Application, name stri
*dataDir,
objStoreConfig,
lset,
*retention,
)
}
}
Expand All @@ -82,12 +85,13 @@ func runReceive(
dataDir string,
objStoreConfig *pathOrContent,
lset labels.Labels,
retention 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")

tsdbCfg := &tsdb.Options{
RetentionDuration: model.Duration(time.Hour * 24 * 15),
RetentionDuration: retention,
NoLockfile: true,
MinBlockDuration: model.Duration(time.Hour * 2),
MaxBlockDuration: model.Duration(time.Hour * 2),
Expand Down

0 comments on commit f847bfe

Please sign in to comment.