Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 68b0bf3

Browse files
authored
Merge pull request #181 from forestsword/s3-tsdb-support
Block Storage Support for S3/AWS
2 parents 36b9442 + 52443ab commit 68b0bf3

File tree

2 files changed

+37
-19
lines changed

2 files changed

+37
-19
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* [CHANGE] We now allow queries that are 32 days long. For example, rate(metric[32d]). Before it was 31d. #173
99
* [ENHANCEMENT] Enable support for HA in the Cortex Alertmanager #147
1010
* [ENHANCEMENT] Support `alertmanager.fallback_config` option in the Alertmanager. #179
11+
* [ENHANCEMENT] Add support for S3 block storage. #181
1112
* [BUGFIX] Add support the `local` ruler client type #175
1213
* [BUGFIX] Fixes `ruler.storage.s3.url` argument for the Ruler. It used an incorrect argument. #177
1314

cortex/config.libsonnet

Lines changed: 36 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
replication_factor: 3,
66
external_url: error 'must define external url for cluster',
77

8-
storage_backend: error 'must specify storage backend (cassandra, gcp)',
8+
storage_backend: error 'must specify storage backend (cassandra, gcp, aws)',
99
table_prefix: $._config.namespace,
1010
cassandra_addresses: error 'must specify cassandra addresses',
1111
bigtable_instance: error 'must specify bigtable instance',
@@ -56,10 +56,13 @@
5656

5757
// Use the Cortex chunks storage engine by default, while giving the ability
5858
// to switch to blocks storage.
59-
storage_engine: 'chunks',
59+
storage_engine: 'chunks', // Available options are 'chunks' or 'blocks'
60+
blocks_storage_backend: 'gcs',
61+
blocks_storage_bucket_name: error 'must specify blocks storage bucket name',
62+
blocks_storage_s3_endpoint: 's3.dualstack.us-east-1.amazonaws.com',
63+
6064
// Secondary storage engine is only used for querying.
6165
querier_second_storage_engine: null,
62-
blocks_storage_bucket_name: error 'must specify GCS bucket name to store TSDB blocks',
6366

6467
store_gateway_replication_factor: 3,
6568

@@ -141,25 +144,39 @@
141144
$._config.client_configs.gcp +
142145
{ 'schema-config-file': '/etc/cortex/schema/config.yaml' },
143146

147+
genericBlocksStorageConfig:: {
148+
'store.engine': $._config.storage_engine, // May still be chunks
149+
'experimental.blocks-storage.tsdb.dir': '/data/tsdb',
150+
'experimental.blocks-storage.bucket-store.sync-dir': '/data/tsdb',
151+
'experimental.blocks-storage.bucket-store.ignore-deletion-marks-delay': '1h',
152+
'experimental.blocks-storage.tsdb.block-ranges-period': '2h',
153+
'experimental.blocks-storage.tsdb.retention-period': '96h', // 4 days protection against blocks not being uploaded from ingesters.
154+
'experimental.blocks-storage.tsdb.ship-interval': '1m',
155+
156+
'experimental.store-gateway.sharding-enabled': true,
157+
'experimental.store-gateway.sharding-ring.store': 'consul',
158+
'experimental.store-gateway.sharding-ring.consul.hostname': 'consul.%s.svc.cluster.local:8500' % $._config.namespace,
159+
'experimental.store-gateway.sharding-ring.prefix': '',
160+
'experimental.store-gateway.replication-factor': $._config.store_gateway_replication_factor,
161+
162+
},
163+
gcsBlocksStorageConfig:: $._config.genericBlocksStorageConfig {
164+
'experimental.blocks-storage.backend': 'gcs',
165+
'experimental.blocks-storage.gcs.bucket-name': $._config.blocks_storage_bucket_name,
166+
},
167+
s3BlocksStorageConfig:: $._config.genericBlocksStorageConfig {
168+
'experimental.blocks-storage.backend': 's3',
169+
'experimental.blocks-storage.s3.bucket-name': $._config.blocks_storage_bucket_name,
170+
'experimental.blocks-storage.s3.endpoint': $._config.blocks_storage_s3_endpoint,
171+
},
144172
// Blocks storage configuration, used only when 'blocks' storage
145173
// engine is explicitly enabled.
146174
blocksStorageConfig: (
147-
if $._config.storage_engine == 'blocks' || $._config.querier_second_storage_engine == 'blocks' then {
148-
'store.engine': $._config.storage_engine, // May still be chunks
149-
'experimental.blocks-storage.tsdb.dir': '/data/tsdb',
150-
'experimental.blocks-storage.bucket-store.sync-dir': '/data/tsdb',
151-
'experimental.blocks-storage.bucket-store.ignore-deletion-marks-delay': '1h',
152-
'experimental.blocks-storage.tsdb.block-ranges-period': '2h',
153-
'experimental.blocks-storage.tsdb.retention-period': '96h', // 4 days protection against blocks not being uploaded from ingesters.
154-
'experimental.blocks-storage.tsdb.ship-interval': '1m',
155-
'experimental.blocks-storage.backend': 'gcs',
156-
'experimental.blocks-storage.gcs.bucket-name': $._config.blocks_storage_bucket_name,
157-
'experimental.store-gateway.sharding-enabled': true,
158-
'experimental.store-gateway.sharding-ring.store': 'consul',
159-
'experimental.store-gateway.sharding-ring.consul.hostname': 'consul.%s.svc.cluster.local:8500' % $._config.namespace,
160-
'experimental.store-gateway.sharding-ring.prefix': '',
161-
'experimental.store-gateway.replication-factor': $._config.store_gateway_replication_factor,
162-
} else {}
175+
if $._config.storage_engine == 'blocks' || $._config.querier_second_storage_engine == 'blocks' then (
176+
if $._config.blocks_storage_backend == 'gcs' then $._config.gcsBlocksStorageConfig
177+
else if $._config.blocks_storage_backend == 's3' then $._config.s3BlocksStorageConfig
178+
else $._config.genericBlocksStorageConfig
179+
) else {}
163180
),
164181

165182
// Shared between the Ruler and Querier

0 commit comments

Comments
 (0)