Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

compact: Add optional flag to disable downsampling. #515

Merged
merged 1 commit into from
Sep 14, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 25 additions & 11 deletions cmd/thanos/compact.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ func registerCompact(m map[string]setupFunc, app *kingpin.Application, name stri
wait := cmd.Flag("wait", "Do not exit after all compactions have been processed and wait for new work.").
Short('w').Bool()

// TODO(bplotka): Remove this flag once https://github.com/improbable-eng/thanos/issues/297 is fixed.
disableDownsampling := cmd.Flag("debug.disable-downsampling", "Disables downsampling. This is not recommended " +
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this not compact.disable-downsampling? Seems to be the pattern elsewhere in the codebase ... see query.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because it's debug only and should be set only when you know consequences.

"as querying long time ranges without non-downsampled data is not efficient and not useful (is not possible to render all for human eye).").
Hidden().Default("false").Bool()

m[name] = func(g *run.Group, logger log.Logger, reg *prometheus.Registry, tracer opentracing.Tracer, _ bool) error {
return runCompact(g, logger, reg,
*httpAddr,
Expand All @@ -55,6 +60,7 @@ func registerCompact(m map[string]setupFunc, app *kingpin.Application, name stri
*wait,
time.Duration(*retention),
name,
*disableDownsampling,
)
}
}
Expand All @@ -72,6 +78,7 @@ func runCompact(
wait bool,
retention time.Duration,
component string,
disableDownsampling bool,
) error {
halted := prometheus.NewGauge(prometheus.GaugeOpts{
Name: "thanos_compactor_halted",
Expand Down Expand Up @@ -131,28 +138,35 @@ func runCompact(
if err := compactor.Compact(ctx); err != nil {
return errors.Wrap(err, "compaction failed")
}
level.Info(logger).Log("msg", "compaction iterations done")

// After all compactions are done, work down the downsampling backlog.
// We run two passes of this to ensure that the 1h downsampling is generated
// for 5m downsamplings created in the first run.
level.Info(logger).Log("msg", "start first pass of downsampling")
// TODO(bplotka): Remove "disableDownsampling" once https://github.com/improbable-eng/thanos/issues/297 is fixed.
if !disableDownsampling {
// After all compactions are done, work down the downsampling backlog.
// We run two passes of this to ensure that the 1h downsampling is generated
// for 5m downsamplings created in the first run.
level.Info(logger).Log("msg", "start first pass of downsampling")

if err := downsampleBucket(ctx, logger, bkt, downsamplingDir); err != nil {
return errors.Wrap(err, "first pass of downsampling failed")
}
if err := downsampleBucket(ctx, logger, bkt, downsamplingDir); err != nil {
return errors.Wrap(err, "first pass of downsampling failed")
}

level.Info(logger).Log("msg", "start second pass of downsampling")
level.Info(logger).Log("msg", "start second pass of downsampling")

if err := downsampleBucket(ctx, logger, bkt, downsamplingDir); err != nil {
return errors.Wrap(err, "second pass of downsampling failed")
if err := downsampleBucket(ctx, logger, bkt, downsamplingDir); err != nil {
return errors.Wrap(err, "second pass of downsampling failed")
}
level.Info(logger).Log("msg", "downsampling iterations done")
} else {
level.Warn(logger).Log("msg", "downsampling was explicitly disabled")
}

if retention.Seconds() != 0 {
if err := compact.ApplyDefaultRetentionPolicy(ctx, logger, bkt, retention); err != nil {
return errors.Wrap(err, "retention failed")
}
}
level.Info(logger).Log("msg", "compaction, downsampling and optional retention apply iteration done")

return nil
}

Expand Down