Skip to content

Commit bbf1fb4

Browse files
committed
Experimental TSDB: Add support for local filesystem object store
Signed-off-by: Edward Welch <[email protected]>
1 parent 829109c commit bbf1fb4

File tree

10 files changed

+275
-4
lines changed

10 files changed

+275
-4
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* `-flusher.wal-dir` for the WAL directory to recover from.
88
* `-flusher.concurrent-flushes` for number of concurrent flushes.
99
* `-flusher.flush-op-timeout` is duration after which a flush should timeout.
10+
* [ENHANCEMENT] Experimental TSDB: Add support for local filesystem backend #2245
1011

1112
## 0.7.0-rc.0 / 2020-03-09
1213

docs/configuration/config-file-reference.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2295,6 +2295,11 @@ azure:
22952295
# Number of retries for recoverable errors
22962296
# CLI flag: -experimental.tsdb.azure.max-retries
22972297
[max_retries: <int> | default = 20]
2298+
2299+
filesystem:
2300+
# Local filesystem storage directory
2301+
# CLI flag: -experimental.tsdb.filesystem.directory
2302+
[directory: <string> | default = ""]
22982303
```
22992304

23002305
### `compactor_config`

docs/operations/blocks-storage.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ The supported backends for the blocks storage are:
1212
* [Amazon S3](https://aws.amazon.com/s3)
1313
* [Google Cloud Storage](https://cloud.google.com/storage/)
1414
* [Microsoft Azure Storage](https://azure.microsoft.com/en-us/services/storage/)
15+
* [Local Filesystem](https://thanos.io/storage.md/#filesystem)
1516

1617
_Internally, this storage engine is based on [Thanos](https://thanos.io), but no Thanos knowledge is required in order to run it._
1718

@@ -252,6 +253,11 @@ tsdb:
252253
# Number of retries for recoverable errors
253254
# CLI flag: -experimental.tsdb.azure.max-retries
254255
[max_retries: <int> | default = 20]
256+
257+
filesystem:
258+
# Local filesystem storage directory
259+
# CLI flag: -experimental.tsdb.filesystem.directory
260+
[directory: <string> | default = ""]
255261
```
256262
### `compactor_config`
257263

docs/operations/blocks-storage.template

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ The supported backends for the blocks storage are:
1212
* [Amazon S3](https://aws.amazon.com/s3)
1313
* [Google Cloud Storage](https://cloud.google.com/storage/)
1414
* [Microsoft Azure Storage](https://azure.microsoft.com/en-us/services/storage/)
15+
* [Local Filesystem](https://thanos.io/storage.md/#filesystem)
1516

1617
_Internally, this storage engine is based on [Thanos](https://thanos.io), but no Thanos knowledge is required in order to run it._
1718

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package filesystem
2+
3+
import (
4+
"github.com/go-kit/kit/log"
5+
"github.com/thanos-io/thanos/pkg/objstore"
6+
"github.com/thanos-io/thanos/pkg/objstore/filesystem"
7+
)
8+
9+
// NewBucketClient creates a new filesystem bucket client
10+
func NewBucketClient(cfg Config, name string, logger log.Logger) (objstore.Bucket, error) {
11+
return filesystem.NewBucket(cfg.Directory)
12+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package filesystem
2+
3+
import "flag"
4+
5+
// Config stores the configuration for storing and accessing objects in the local filesystem.
6+
type Config struct {
7+
Directory string `yaml:"directory"`
8+
}
9+
10+
// RegisterFlags registers the flags for TSDB filesystem storage
11+
func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
12+
f.StringVar(&cfg.Directory, "experimental.tsdb.filesystem.directory", "", "Local filesystem storage directory")
13+
}

pkg/storage/tsdb/bucket_client.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"github.com/thanos-io/thanos/pkg/objstore"
88

99
"github.com/cortexproject/cortex/pkg/storage/tsdb/backend/azure"
10+
"github.com/cortexproject/cortex/pkg/storage/tsdb/backend/filesystem"
1011
"github.com/cortexproject/cortex/pkg/storage/tsdb/backend/gcs"
1112
"github.com/cortexproject/cortex/pkg/storage/tsdb/backend/s3"
1213
)
@@ -20,6 +21,8 @@ func NewBucketClient(ctx context.Context, cfg Config, name string, logger log.Lo
2021
return gcs.NewBucketClient(ctx, cfg.GCS, name, logger)
2122
case BackendAzure:
2223
return azure.NewBucketClient(cfg.Azure, name, logger)
24+
case BackendFilesystem:
25+
return filesystem.NewBucketClient(cfg.Filesystem, name, logger)
2326
default:
2427
return nil, errUnsupportedBackend
2528
}

pkg/storage/tsdb/config.go

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"github.com/alecthomas/units"
1111

1212
"github.com/cortexproject/cortex/pkg/storage/tsdb/backend/azure"
13+
"github.com/cortexproject/cortex/pkg/storage/tsdb/backend/filesystem"
1314
"github.com/cortexproject/cortex/pkg/storage/tsdb/backend/gcs"
1415
"github.com/cortexproject/cortex/pkg/storage/tsdb/backend/s3"
1516
)
@@ -24,6 +25,9 @@ const (
2425
// BackendAzure is the value for the Azure storage backend
2526
BackendAzure = "azure"
2627

28+
// BackendFilesystem is the value for the filesystem storge backend
29+
BackendFilesystem = "filesystem"
30+
2731
// TenantIDExternalLabel is the external label set when shipping blocks to the storage
2832
TenantIDExternalLabel = "__org_id__"
2933
)
@@ -54,9 +58,10 @@ type Config struct {
5458
MaxTSDBOpeningConcurrencyOnStartup int `yaml:"max_tsdb_opening_concurrency_on_startup"`
5559

5660
// Backends
57-
S3 s3.Config `yaml:"s3"`
58-
GCS gcs.Config `yaml:"gcs"`
59-
Azure azure.Config `yaml:"azure"`
61+
S3 s3.Config `yaml:"s3"`
62+
GCS gcs.Config `yaml:"gcs"`
63+
Azure azure.Config `yaml:"azure"`
64+
Filesystem filesystem.Config `yaml:"filesystem"`
6065
}
6166

6267
// DurationList is the block ranges for a tsdb
@@ -102,6 +107,7 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
102107
cfg.GCS.RegisterFlags(f)
103108
cfg.Azure.RegisterFlags(f)
104109
cfg.BucketStore.RegisterFlags(f)
110+
cfg.Filesystem.RegisterFlags(f)
105111

106112
if len(cfg.BlockRanges) == 0 {
107113
cfg.BlockRanges = []time.Duration{2 * time.Hour} // Default 2h block
@@ -121,7 +127,7 @@ func (cfg *Config) RegisterFlags(f *flag.FlagSet) {
121127

122128
// Validate the config
123129
func (cfg *Config) Validate() error {
124-
if cfg.Backend != BackendS3 && cfg.Backend != BackendGCS && cfg.Backend != BackendAzure {
130+
if cfg.Backend != BackendS3 && cfg.Backend != BackendGCS && cfg.Backend != BackendAzure && cfg.Backend != BackendFilesystem {
125131
return errUnsupportedBackend
126132
}
127133

vendor/github.com/thanos-io/thanos/pkg/objstore/filesystem/filesystem.go

Lines changed: 223 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modules.txt

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)