main: add flags for new storage
This commit is contained in:
parent
87bea50b85
commit
ea3ba338dd
|
@ -31,6 +31,7 @@ import (
|
||||||
"github.com/prometheus/prometheus/config"
|
"github.com/prometheus/prometheus/config"
|
||||||
"github.com/prometheus/prometheus/notifier"
|
"github.com/prometheus/prometheus/notifier"
|
||||||
"github.com/prometheus/prometheus/promql"
|
"github.com/prometheus/prometheus/promql"
|
||||||
|
"github.com/prometheus/prometheus/storage/tsdb"
|
||||||
"github.com/prometheus/prometheus/web"
|
"github.com/prometheus/prometheus/web"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -48,6 +49,7 @@ var cfg = struct {
|
||||||
notifierTimeout time.Duration
|
notifierTimeout time.Duration
|
||||||
queryEngine promql.EngineOptions
|
queryEngine promql.EngineOptions
|
||||||
web web.Options
|
web web.Options
|
||||||
|
tsdb tsdb.Options
|
||||||
|
|
||||||
alertmanagerURLs stringset
|
alertmanagerURLs stringset
|
||||||
prometheusURL string
|
prometheusURL string
|
||||||
|
@ -116,6 +118,18 @@ func init() {
|
||||||
&cfg.localStoragePath, "storage.local.path", "data",
|
&cfg.localStoragePath, "storage.local.path", "data",
|
||||||
"Base path for metrics storage.",
|
"Base path for metrics storage.",
|
||||||
)
|
)
|
||||||
|
cfg.fs.DurationVar(
|
||||||
|
&cfg.tsdb.MinBlockDuration, "storage.tsdb.min-block-duration", 2*time.Hour,
|
||||||
|
"Minimum duration of a data block before being persisted.",
|
||||||
|
)
|
||||||
|
cfg.fs.DurationVar(
|
||||||
|
&cfg.tsdb.MaxBlockDuration, "storage.tsdb.max-block-duration", 36*time.Hour,
|
||||||
|
"Maximum duration compacted blocks may span.",
|
||||||
|
)
|
||||||
|
cfg.fs.IntVar(
|
||||||
|
&cfg.tsdb.AppendableBlocks, "storage.tsdb.AppendableBlocks", 2,
|
||||||
|
"Number of head blocks that can be appended to.",
|
||||||
|
)
|
||||||
|
|
||||||
// Alertmanager.
|
// Alertmanager.
|
||||||
cfg.fs.IntVar(
|
cfg.fs.IntVar(
|
||||||
|
|
|
@ -78,11 +78,7 @@ func Main() int {
|
||||||
reloadables []Reloadable
|
reloadables []Reloadable
|
||||||
)
|
)
|
||||||
|
|
||||||
localStorage, err := tsdb.Open(cfg.localStoragePath, &tsdb.Options{
|
localStorage, err := tsdb.Open(cfg.localStoragePath, &cfg.tsdb)
|
||||||
MinBlockDuration: 2 * 60 * 60 * 1000,
|
|
||||||
MaxBlockDuration: 24 * 60 * 60 * 1000,
|
|
||||||
AppendableBlocks: 2,
|
|
||||||
})
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Errorf("Opening storage failed: %s", err)
|
log.Errorf("Opening storage failed: %s", err)
|
||||||
return 1
|
return 1
|
||||||
|
|
|
@ -22,10 +22,10 @@ type Options struct {
|
||||||
|
|
||||||
// The timestamp range of head blocks after which they get persisted.
|
// The timestamp range of head blocks after which they get persisted.
|
||||||
// It's the minimum duration of any persisted block.
|
// It's the minimum duration of any persisted block.
|
||||||
MinBlockDuration uint64
|
MinBlockDuration time.Duration
|
||||||
|
|
||||||
// The maximum timestamp range of compacted blocks.
|
// The maximum timestamp range of compacted blocks.
|
||||||
MaxBlockDuration uint64
|
MaxBlockDuration time.Duration
|
||||||
|
|
||||||
// Number of head blocks that can be appended to.
|
// Number of head blocks that can be appended to.
|
||||||
// Should be two or higher to prevent write errors in general scenarios.
|
// Should be two or higher to prevent write errors in general scenarios.
|
||||||
|
@ -39,8 +39,8 @@ type Options struct {
|
||||||
func Open(path string, opts *Options) (storage.Storage, error) {
|
func Open(path string, opts *Options) (storage.Storage, error) {
|
||||||
db, err := tsdb.OpenPartitioned(path, 1, nil, &tsdb.Options{
|
db, err := tsdb.OpenPartitioned(path, 1, nil, &tsdb.Options{
|
||||||
WALFlushInterval: 10 * time.Second,
|
WALFlushInterval: 10 * time.Second,
|
||||||
MinBlockDuration: opts.MinBlockDuration,
|
MinBlockDuration: uint64(opts.MinBlockDuration.Seconds() * 1000),
|
||||||
MaxBlockDuration: opts.MaxBlockDuration,
|
MaxBlockDuration: uint64(opts.MaxBlockDuration.Seconds() * 1000),
|
||||||
AppendableBlocks: opts.AppendableBlocks,
|
AppendableBlocks: opts.AppendableBlocks,
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue