Skip to content

Commit 34327cb

Browse files
authored
TSDB: chunks caching (#2572)
* Updated Thanos to master Signed-off-by: Peter Štibraný <[email protected]> * Integrate caching bucket to bucket stores. Signed-off-by: Peter Štibraný <[email protected]> * Docs Signed-off-by: Peter Štibraný <[email protected]> * CHANGELOG.md Signed-off-by: Peter Štibraný <[email protected]> * Renamed CLI options to match YAML fields. Signed-off-by: Peter Štibraný <[email protected]> * Removed 'caching' prefix from CLI options. Regenerated docs. Signed-off-by: Peter Štibraný <[email protected]> * go mod tidy Signed-off-by: Peter Štibraný <[email protected]> * Rename MemcachedIndexCacheConfig to MemcachedClientConfig and move it to separate file. Signed-off-by: Peter Štibraný <[email protected]> * Use custom object for chunks cache configuration. Signed-off-by: Peter Štibraný <[email protected]> * Added short section on chunks cache. Signed-off-by: Peter Štibraný <[email protected]> * Update docs. Signed-off-by: Peter Štibraný <[email protected]> * Address review feedback. Signed-off-by: Peter Štibraný <[email protected]>
1 parent 6d4e8db commit 34327cb

File tree

19 files changed

+962
-122
lines changed

19 files changed

+962
-122
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
* `cortex_querier_blocks_last_successful_scan_timestamp_seconds` (when store-gateway is enabled)
7575
* `cortex_storegateway_blocks_last_successful_sync_timestamp_seconds`
7676
* [ENHANCEMENT] Experimental TSDB: added the flag `-experimental.tsdb.wal-compression-enabled` to allow to enable TSDB WAL compression. #2585
77+
* [ENHANCEMENT] Experimental TSDB: Querier and store-gateway components can now use so-called "caching bucket", which can currently cache fetched chunks into shared memcached server. #2572
7778
* [BUGFIX] Ruler: Ensure temporary rule files with special characters are properly mapped and cleaned up. #2506
7879
* [BUGFIX] Fixes #2411, Ensure requests are properly routed to the prometheus api embedded in the query if `-server.path-prefix` is set. #2372
7980
* [BUGFIX] Experimental TSDB: fixed chunk data corruption when querying back series using the experimental blocks storage. #2400

docs/configuration/config-file-reference.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2670,6 +2670,71 @@ bucket_store:
26702670
# CLI flag: -experimental.tsdb.bucket-store.index-cache.postings-compression-enabled
26712671
[postings_compression_enabled: <boolean> | default = false]
26722672
2673+
chunks_cache:
2674+
# Backend for chunks cache, if not empty. Supported values: memcached.
2675+
# CLI flag: -experimental.tsdb.bucket-store.chunks-cache.backend
2676+
[backend: <string> | default = ""]
2677+
2678+
memcached:
2679+
# Comma separated list of memcached addresses. Supported prefixes are:
2680+
# dns+ (looked up as an A/AAAA query), dnssrv+ (looked up as a SRV query,
2681+
# dnssrvnoa+ (looked up as a SRV query, with no A/AAAA lookup made after
2682+
# that).
2683+
# CLI flag: -experimental.tsdb.bucket-store.chunks-cache.memcached.addresses
2684+
[addresses: <string> | default = ""]
2685+
2686+
# The socket read/write timeout.
2687+
# CLI flag: -experimental.tsdb.bucket-store.chunks-cache.memcached.timeout
2688+
[timeout: <duration> | default = 100ms]
2689+
2690+
# The maximum number of idle connections that will be maintained per
2691+
# address.
2692+
# CLI flag: -experimental.tsdb.bucket-store.chunks-cache.memcached.max-idle-connections
2693+
[max_idle_connections: <int> | default = 16]
2694+
2695+
# The maximum number of concurrent asynchronous operations can occur.
2696+
# CLI flag: -experimental.tsdb.bucket-store.chunks-cache.memcached.max-async-concurrency
2697+
[max_async_concurrency: <int> | default = 50]
2698+
2699+
# The maximum number of enqueued asynchronous operations allowed.
2700+
# CLI flag: -experimental.tsdb.bucket-store.chunks-cache.memcached.max-async-buffer-size
2701+
[max_async_buffer_size: <int> | default = 10000]
2702+
2703+
# The maximum number of concurrent connections running get operations. If
2704+
# set to 0, concurrency is unlimited.
2705+
# CLI flag: -experimental.tsdb.bucket-store.chunks-cache.memcached.max-get-multi-concurrency
2706+
[max_get_multi_concurrency: <int> | default = 100]
2707+
2708+
# The maximum number of keys a single underlying get operation should run.
2709+
# If more keys are specified, internally keys are splitted into multiple
2710+
# batches and fetched concurrently, honoring the max concurrency. If set
2711+
# to 0, the max batch size is unlimited.
2712+
# CLI flag: -experimental.tsdb.bucket-store.chunks-cache.memcached.max-get-multi-batch-size
2713+
[max_get_multi_batch_size: <int> | default = 0]
2714+
2715+
# The maximum size of an item stored in memcached. Bigger items are not
2716+
# stored. If set to 0, no maximum size is enforced.
2717+
# CLI flag: -experimental.tsdb.bucket-store.chunks-cache.memcached.max-item-size
2718+
[max_item_size: <int> | default = 1048576]
2719+
2720+
# Size of each subrange that bucket object is split into for better caching.
2721+
# CLI flag: -experimental.tsdb.bucket-store.chunks-cache.subrange-size
2722+
[subrange_size: <int> | default = 16000]
2723+
2724+
# Maximum number of sub-GetRange requests that a single GetRange request can
2725+
# be split into when fetching chunks. Zero or negative value = unlimited
2726+
# number of sub-requests.
2727+
# CLI flag: -experimental.tsdb.bucket-store.chunks-cache.max-get-range-requests
2728+
[max_get_range_requests: <int> | default = 3]
2729+
2730+
# TTL for caching object size for chunks.
2731+
# CLI flag: -experimental.tsdb.bucket-store.chunks-cache.object-size-ttl
2732+
[object_size_ttl: <duration> | default = 24h]
2733+
2734+
# TTL for caching individual chunks subranges.
2735+
# CLI flag: -experimental.tsdb.bucket-store.chunks-cache.subrange-ttl
2736+
[subrange_ttl: <duration> | default = 24h]
2737+
26732738
# Duration after which the blocks marked for deletion will be filtered out
26742739
# while fetching blocks. The idea of ignore-deletion-marks-delay is to ignore
26752740
# blocks that are marked for deletion with some delay. This ensures store can

docs/operations/blocks-storage.md

Lines changed: 75 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Whenever the pool of compactors increase or decrease (ie. following up a scale u
7474

7575
## Index cache
7676

77-
The querier supports a cache to speed up postings and series lookups from TSDB blocks indexes. Two backends are supported:
77+
The querier and store-gateway support a cache to speed up postings and series lookups from TSDB blocks indexes. Two backends are supported:
7878

7979
- `inmemory`
8080
- `memcached`
@@ -103,6 +103,14 @@ For example, if you're running Memcached in Kubernetes, you may:
103103
2. Create an [headless service](https://kubernetes.io/docs/concepts/services-networking/service/#headless-services) for Memcached StatefulSet
104104
3. Configure the Cortex's Memcached client address using the `dnssrvnoa+` [service discovery](../configuration/arguments.md#dns-service-discovery)
105105

106+
## Chunks cache
107+
108+
Store-gateway and querier also support cache for storing chunks fetched from storage. Chunks contain actual samples, and can be reused if user query hits the same series for the same time range.
109+
110+
To enable chunks cache, please set `-experimental.tsdb.bucket-store.chunks-cache.backend`. Chunks can currently only be stored into Memcached cache. Memcached client can be configured via flags with `-experimental.tsdb.bucket-store.chunks-cache.memcached` prefix.
111+
112+
There are additional low-level options for configuring chunks cache. Please refer to other flags with `experimental.tsdb.bucket-store.chunks-cache` prefix.
113+
106114
## Configuration
107115

108116
The general [configuration documentation](../configuration/_index.md) also applied to a Cortex cluster running the blocks storage, with few differences:
@@ -262,6 +270,72 @@ tsdb:
262270
# CLI flag: -experimental.tsdb.bucket-store.index-cache.postings-compression-enabled
263271
[postings_compression_enabled: <boolean> | default = false]
264272
273+
chunks_cache:
274+
# Backend for chunks cache, if not empty. Supported values: memcached.
275+
# CLI flag: -experimental.tsdb.bucket-store.chunks-cache.backend
276+
[backend: <string> | default = ""]
277+
278+
memcached:
279+
# Comma separated list of memcached addresses. Supported prefixes are:
280+
# dns+ (looked up as an A/AAAA query), dnssrv+ (looked up as a SRV
281+
# query, dnssrvnoa+ (looked up as a SRV query, with no A/AAAA lookup
282+
# made after that).
283+
# CLI flag: -experimental.tsdb.bucket-store.chunks-cache.memcached.addresses
284+
[addresses: <string> | default = ""]
285+
286+
# The socket read/write timeout.
287+
# CLI flag: -experimental.tsdb.bucket-store.chunks-cache.memcached.timeout
288+
[timeout: <duration> | default = 100ms]
289+
290+
# The maximum number of idle connections that will be maintained per
291+
# address.
292+
# CLI flag: -experimental.tsdb.bucket-store.chunks-cache.memcached.max-idle-connections
293+
[max_idle_connections: <int> | default = 16]
294+
295+
# The maximum number of concurrent asynchronous operations can occur.
296+
# CLI flag: -experimental.tsdb.bucket-store.chunks-cache.memcached.max-async-concurrency
297+
[max_async_concurrency: <int> | default = 50]
298+
299+
# The maximum number of enqueued asynchronous operations allowed.
300+
# CLI flag: -experimental.tsdb.bucket-store.chunks-cache.memcached.max-async-buffer-size
301+
[max_async_buffer_size: <int> | default = 10000]
302+
303+
# The maximum number of concurrent connections running get operations.
304+
# If set to 0, concurrency is unlimited.
305+
# CLI flag: -experimental.tsdb.bucket-store.chunks-cache.memcached.max-get-multi-concurrency
306+
[max_get_multi_concurrency: <int> | default = 100]
307+
308+
# The maximum number of keys a single underlying get operation should
309+
# run. If more keys are specified, internally keys are splitted into
310+
# multiple batches and fetched concurrently, honoring the max
311+
# concurrency. If set to 0, the max batch size is unlimited.
312+
# CLI flag: -experimental.tsdb.bucket-store.chunks-cache.memcached.max-get-multi-batch-size
313+
[max_get_multi_batch_size: <int> | default = 0]
314+
315+
# The maximum size of an item stored in memcached. Bigger items are not
316+
# stored. If set to 0, no maximum size is enforced.
317+
# CLI flag: -experimental.tsdb.bucket-store.chunks-cache.memcached.max-item-size
318+
[max_item_size: <int> | default = 1048576]
319+
320+
# Size of each subrange that bucket object is split into for better
321+
# caching.
322+
# CLI flag: -experimental.tsdb.bucket-store.chunks-cache.subrange-size
323+
[subrange_size: <int> | default = 16000]
324+
325+
# Maximum number of sub-GetRange requests that a single GetRange request
326+
# can be split into when fetching chunks. Zero or negative value =
327+
# unlimited number of sub-requests.
328+
# CLI flag: -experimental.tsdb.bucket-store.chunks-cache.max-get-range-requests
329+
[max_get_range_requests: <int> | default = 3]
330+
331+
# TTL for caching object size for chunks.
332+
# CLI flag: -experimental.tsdb.bucket-store.chunks-cache.object-size-ttl
333+
[object_size_ttl: <duration> | default = 24h]
334+
335+
# TTL for caching individual chunks subranges.
336+
# CLI flag: -experimental.tsdb.bucket-store.chunks-cache.subrange-ttl
337+
[subrange_ttl: <duration> | default = 24h]
338+
265339
# Duration after which the blocks marked for deletion will be filtered out
266340
# while fetching blocks. The idea of ignore-deletion-marks-delay is to
267341
# ignore blocks that are marked for deletion with some delay. This ensures

docs/operations/blocks-storage.template

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ Whenever the pool of compactors increase or decrease (ie. following up a scale u
7474

7575
## Index cache
7676

77-
The querier supports a cache to speed up postings and series lookups from TSDB blocks indexes. Two backends are supported:
77+
The querier and store-gateway support a cache to speed up postings and series lookups from TSDB blocks indexes. Two backends are supported:
7878

7979
- `inmemory`
8080
- `memcached`
@@ -103,6 +103,14 @@ For example, if you're running Memcached in Kubernetes, you may:
103103
2. Create an [headless service](https://kubernetes.io/docs/concepts/services-networking/service/#headless-services) for Memcached StatefulSet
104104
3. Configure the Cortex's Memcached client address using the `dnssrvnoa+` [service discovery](../configuration/arguments.md#dns-service-discovery)
105105

106+
## Chunks cache
107+
108+
Store-gateway and querier also support cache for storing chunks fetched from storage. Chunks contain actual samples, and can be reused if user query hits the same series for the same time range.
109+
110+
To enable chunks cache, please set `-experimental.tsdb.bucket-store.chunks-cache.backend`. Chunks can currently only be stored into Memcached cache. Memcached client can be configured via flags with `-experimental.tsdb.bucket-store.chunks-cache.memcached` prefix.
111+
112+
There are additional low-level options for configuring chunks cache. Please refer to other flags with `experimental.tsdb.bucket-store.chunks-cache` prefix.
113+
106114
## Configuration
107115

108116
The general [configuration documentation](../configuration/_index.md) also applied to a Cortex cluster running the blocks storage, with few differences:

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ require (
5050
github.com/segmentio/fasthash v0.0.0-20180216231524-a72b379d632e
5151
github.com/spf13/afero v1.2.2
5252
github.com/stretchr/testify v1.4.0
53-
github.com/thanos-io/thanos v0.12.3-0.20200505050643-5a777da8dfd2
53+
github.com/thanos-io/thanos v0.12.3-0.20200507181659-b9ff23c5c31d
5454
github.com/uber/jaeger-client-go v2.20.1+incompatible
5555
github.com/weaveworks/common v0.0.0-20200429090833-ac38719f57dd
5656
go.etcd.io/bbolt v1.3.3

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -869,8 +869,8 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV
869869
github.com/stretchr/testify v1.4.0 h1:2E4SXV/wtOkTonXsotYi4li6zVWxYlZuYNCXe9XRJyk=
870870
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
871871
github.com/thanos-io/thanos v0.8.1-0.20200109203923-552ffa4c1a0d/go.mod h1:usT/TxtJQ7DzinTt+G9kinDQmRS5sxwu0unVKZ9vdcw=
872-
github.com/thanos-io/thanos v0.12.3-0.20200505050643-5a777da8dfd2 h1:boR0K2zEuB9Q+w0RqNUcrT6UpPpQwr7MFQ2nfCgJp6c=
873-
github.com/thanos-io/thanos v0.12.3-0.20200505050643-5a777da8dfd2/go.mod h1:N3stAuvPDLaWMQym7uDXAoAanu4ujieMjK7zzxJzky4=
872+
github.com/thanos-io/thanos v0.12.3-0.20200507181659-b9ff23c5c31d h1:rNFFyjaZmsyB0EItY6EM+QN2PdDoxIeCNy8CbIbIxNo=
873+
github.com/thanos-io/thanos v0.12.3-0.20200507181659-b9ff23c5c31d/go.mod h1:N3stAuvPDLaWMQym7uDXAoAanu4ujieMjK7zzxJzky4=
874874
github.com/tidwall/pretty v0.0.0-20180105212114-65a9db5fad51/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=
875875
github.com/tidwall/pretty v1.0.0 h1:HsD+QiTn7sK6flMKIvNmpqz1qrpP3Ps6jOKIKMooyg4=
876876
github.com/tidwall/pretty v1.0.0/go.mod h1:XNkn88O1ChpSDQmQeStsy+sBenx6DDtFZJxhVysOjyk=

pkg/storage/tsdb/caching_bucket.go

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package tsdb
2+
3+
import (
4+
"flag"
5+
"fmt"
6+
"time"
7+
8+
"github.com/go-kit/kit/log"
9+
"github.com/pkg/errors"
10+
"github.com/prometheus/client_golang/prometheus"
11+
"github.com/thanos-io/thanos/pkg/cache"
12+
"github.com/thanos-io/thanos/pkg/cacheutil"
13+
"github.com/thanos-io/thanos/pkg/objstore"
14+
storecache "github.com/thanos-io/thanos/pkg/store/cache"
15+
)
16+
17+
type ChunksCacheConfig struct {
18+
Backend string `yaml:"backend"`
19+
Memcached MemcachedClientConfig `yaml:"memcached"`
20+
21+
SubrangeSize int64 `yaml:"subrange_size"`
22+
MaxGetRangeRequests int `yaml:"max_get_range_requests"`
23+
ObjectSizeTTL time.Duration `yaml:"object_size_ttl"`
24+
SubrangeTTL time.Duration `yaml:"subrange_ttl"`
25+
}
26+
27+
func (cfg *ChunksCacheConfig) RegisterFlagsWithPrefix(f *flag.FlagSet, prefix string) {
28+
f.StringVar(&cfg.Backend, prefix+"backend", "", fmt.Sprintf("Backend for chunks cache, if not empty. Supported values: %s.", storecache.MemcachedBucketCacheProvider))
29+
30+
cfg.Memcached.RegisterFlagsWithPrefix(f, prefix+"memcached.")
31+
32+
f.Int64Var(&cfg.SubrangeSize, prefix+"subrange-size", 16000, "Size of each subrange that bucket object is split into for better caching.")
33+
f.IntVar(&cfg.MaxGetRangeRequests, prefix+"max-get-range-requests", 3, "Maximum number of sub-GetRange requests that a single GetRange request can be split into when fetching chunks. Zero or negative value = unlimited number of sub-requests.")
34+
f.DurationVar(&cfg.ObjectSizeTTL, prefix+"object-size-ttl", 24*time.Hour, "TTL for caching object size for chunks.")
35+
f.DurationVar(&cfg.SubrangeTTL, prefix+"subrange-ttl", 24*time.Hour, "TTL for caching individual chunks subranges.")
36+
}
37+
38+
// Validate the config.
39+
func (cfg *ChunksCacheConfig) Validate() error {
40+
if cfg.Backend != "" && cfg.Backend != string(storecache.MemcachedBucketCacheProvider) {
41+
return fmt.Errorf("unsupported cache backend: %s", cfg.Backend)
42+
}
43+
44+
if cfg.Backend == string(storecache.MemcachedBucketCacheProvider) {
45+
if err := cfg.Memcached.Validate(); err != nil {
46+
return err
47+
}
48+
}
49+
50+
return nil
51+
}
52+
53+
func CreateCachingBucket(chunksConfig ChunksCacheConfig, bkt objstore.Bucket, logger log.Logger, reg prometheus.Registerer) (objstore.Bucket, error) {
54+
var chunksCache cache.Cache
55+
56+
switch chunksConfig.Backend {
57+
case "":
58+
// No caching.
59+
return bkt, nil
60+
61+
case string(storecache.MemcachedBucketCacheProvider):
62+
var memcached cacheutil.MemcachedClient
63+
memcached, err := cacheutil.NewMemcachedClientWithConfig(logger, "chunks-cache", chunksConfig.Memcached.ToMemcachedClientConfig(), reg)
64+
if err != nil {
65+
return nil, errors.Wrapf(err, "failed to create memcached client for chunks-cache")
66+
}
67+
chunksCache = cache.NewMemcachedCache("chunks-cache", logger, memcached, reg)
68+
69+
default:
70+
return nil, errors.Errorf("unsupported cache type: %s", chunksConfig.Backend)
71+
}
72+
73+
cc := storecache.CachingBucketConfig{
74+
ChunkSubrangeSize: chunksConfig.SubrangeSize,
75+
MaxChunksGetRangeRequests: chunksConfig.MaxGetRangeRequests,
76+
ChunkObjectSizeTTL: chunksConfig.ObjectSizeTTL,
77+
ChunkSubrangeTTL: chunksConfig.SubrangeTTL,
78+
}
79+
return storecache.NewCachingBucket(bkt, chunksCache, cc, logger, reg)
80+
}

pkg/storage/tsdb/config.go

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package tsdb
22

33
import (
4-
"errors"
54
"flag"
65
"fmt"
76
"path/filepath"
87
"strings"
98
"time"
109

1110
"github.com/alecthomas/units"
11+
"github.com/pkg/errors"
1212
"github.com/thanos-io/thanos/pkg/store"
1313

1414
"github.com/cortexproject/cortex/pkg/storage/backend/azure"
@@ -161,18 +161,19 @@ func (cfg *Config) Validate() error {
161161

162162
// BucketStoreConfig holds the config information for Bucket Stores used by the querier
163163
type BucketStoreConfig struct {
164-
SyncDir string `yaml:"sync_dir"`
165-
SyncInterval time.Duration `yaml:"sync_interval"`
166-
MaxChunkPoolBytes uint64 `yaml:"max_chunk_pool_bytes"`
167-
MaxSampleCount uint64 `yaml:"max_sample_count"`
168-
MaxConcurrent int `yaml:"max_concurrent"`
169-
TenantSyncConcurrency int `yaml:"tenant_sync_concurrency"`
170-
BlockSyncConcurrency int `yaml:"block_sync_concurrency"`
171-
MetaSyncConcurrency int `yaml:"meta_sync_concurrency"`
172-
BinaryIndexHeader bool `yaml:"binary_index_header_enabled"`
173-
ConsistencyDelay time.Duration `yaml:"consistency_delay"`
174-
IndexCache IndexCacheConfig `yaml:"index_cache"`
175-
IgnoreDeletionMarksDelay time.Duration `yaml:"ignore_deletion_mark_delay"`
164+
SyncDir string `yaml:"sync_dir"`
165+
SyncInterval time.Duration `yaml:"sync_interval"`
166+
MaxChunkPoolBytes uint64 `yaml:"max_chunk_pool_bytes"`
167+
MaxSampleCount uint64 `yaml:"max_sample_count"`
168+
MaxConcurrent int `yaml:"max_concurrent"`
169+
TenantSyncConcurrency int `yaml:"tenant_sync_concurrency"`
170+
BlockSyncConcurrency int `yaml:"block_sync_concurrency"`
171+
MetaSyncConcurrency int `yaml:"meta_sync_concurrency"`
172+
BinaryIndexHeader bool `yaml:"binary_index_header_enabled"`
173+
ConsistencyDelay time.Duration `yaml:"consistency_delay"`
174+
IndexCache IndexCacheConfig `yaml:"index_cache"`
175+
ChunksCache ChunksCacheConfig `yaml:"chunks_cache"`
176+
IgnoreDeletionMarksDelay time.Duration `yaml:"ignore_deletion_mark_delay"`
176177

177178
// Controls what is the ratio of postings offsets store will hold in memory.
178179
// Larger value will keep less offsets, which will increase CPU cycles needed for query touching those postings.
@@ -185,6 +186,7 @@ type BucketStoreConfig struct {
185186
// RegisterFlags registers the BucketStore flags
186187
func (cfg *BucketStoreConfig) RegisterFlags(f *flag.FlagSet) {
187188
cfg.IndexCache.RegisterFlagsWithPrefix(f, "experimental.tsdb.bucket-store.index-cache.")
189+
cfg.ChunksCache.RegisterFlagsWithPrefix(f, "experimental.tsdb.bucket-store.chunks-cache.")
188190

189191
f.StringVar(&cfg.SyncDir, "experimental.tsdb.bucket-store.sync-dir", "tsdb-sync", "Directory to store synchronized TSDB index headers.")
190192
f.DurationVar(&cfg.SyncInterval, "experimental.tsdb.bucket-store.sync-interval", 5*time.Minute, "How frequently scan the bucket to look for changes (new blocks shipped by ingesters and blocks removed by retention or compaction). 0 disables it.")
@@ -204,7 +206,15 @@ func (cfg *BucketStoreConfig) RegisterFlags(f *flag.FlagSet) {
204206

205207
// Validate the config.
206208
func (cfg *BucketStoreConfig) Validate() error {
207-
return cfg.IndexCache.Validate()
209+
err := cfg.IndexCache.Validate()
210+
if err != nil {
211+
return errors.Wrap(err, "index-cache configuration")
212+
}
213+
err = cfg.ChunksCache.Validate()
214+
if err != nil {
215+
return errors.Wrap(err, "chunks-cache configuration")
216+
}
217+
return nil
208218
}
209219

210220
// BlocksDir returns the directory path where TSDB blocks and wal should be

0 commit comments

Comments
 (0)