diff --git a/cmd/thanos/receive.go b/cmd/thanos/receive.go index 5b699d264d..b9cb22741b 100644 --- a/cmd/thanos/receive.go +++ b/cmd/thanos/receive.go @@ -202,17 +202,21 @@ func runReceive( return errors.Wrap(err, "parse relabel configuration") } - dbs := receive.NewMultiTSDB( + dbs, err := receive.NewMultiTSDB( conf.dataDir, logger, reg, tsdbOpts, lset, conf.tenantLabelName, + conf.defaultTenantID, bkt, conf.allowOutOfOrderUpload, hashFunc, ) + if err != nil { + return errors.Wrap(err, "creating multi tsdb") + } writer := receive.NewWriter(log.With(logger, "component", "receive-writer"), dbs, &receive.WriterOptions{ Intern: conf.writerInterning, TooFarInFutureTimeWindow: int64(time.Duration(*conf.tsdbTooFarInFutureTimeWindow)), diff --git a/pkg/receive/multitsdb.go b/pkg/receive/multitsdb.go index 509e9f3535..203b836c83 100644 --- a/pkg/receive/multitsdb.go +++ b/pkg/receive/multitsdb.go @@ -72,15 +72,16 @@ func NewMultiTSDB( tsdbOpts *tsdb.Options, labels labels.Labels, tenantLabelName string, + defaultTenantId string, bucket objstore.Bucket, allowOutOfOrderUpload bool, hashFunc metadata.HashFunc, -) *MultiTSDB { +) (*MultiTSDB, error) { if l == nil { l = log.NewNopLogger() } - return &MultiTSDB{ + res := &MultiTSDB{ dataDir: dataDir, logger: log.With(l, "component", "multi-tsdb"), reg: reg, @@ -93,6 +94,10 @@ func NewMultiTSDB( allowOutOfOrderUpload: allowOutOfOrderUpload, hashFunc: hashFunc, } + // initialize default tenant for warmer startups + _, err := res.getOrLoadTenant(defaultTenantId, true) + + return res, err } type localClient struct {