mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-30 15:12:27 -08:00
Merge pull request #3354 from pgier/tsdb-block-duration-check
storage/tsdb: check that max block duration is larger than min
This commit is contained in:
commit
3055b55830
|
@ -126,6 +126,10 @@ type Options struct {
|
||||||
|
|
||||||
// Open returns a new storage backed by a TSDB database that is configured for Prometheus.
|
// Open returns a new storage backed by a TSDB database that is configured for Prometheus.
|
||||||
func Open(path string, l log.Logger, r prometheus.Registerer, opts *Options) (*tsdb.DB, error) {
|
func Open(path string, l log.Logger, r prometheus.Registerer, opts *Options) (*tsdb.DB, error) {
|
||||||
|
if opts.MinBlockDuration > opts.MaxBlockDuration {
|
||||||
|
return nil, errors.Errorf("tsdb max block duration (%v) must be larger than min block duration (%v)",
|
||||||
|
opts.MaxBlockDuration, opts.MinBlockDuration)
|
||||||
|
}
|
||||||
// Start with smallest block duration and create exponential buckets until the exceed the
|
// Start with smallest block duration and create exponential buckets until the exceed the
|
||||||
// configured maximum block duration.
|
// configured maximum block duration.
|
||||||
rngs := tsdb.ExponentialBlockRanges(int64(time.Duration(opts.MinBlockDuration).Seconds()*1000), 10, 3)
|
rngs := tsdb.ExponentialBlockRanges(int64(time.Duration(opts.MinBlockDuration).Seconds()*1000), 10, 3)
|
||||||
|
|
Loading…
Reference in a new issue