docs/proposals-done/201909-thanos-sharding.md
This document describes the motivation and design of the sharding of Thanos components in terms of operations against object storage. Additionally we touch possibility for smarter pre-filtering of shards on the Querier.
Currently all components that read from object store assume that all the operations and functionality should be done based on all the available blocks that are present in the certain bucket's root directory.
This is in most cases totally fine, however with time and allowance of storing blocks from multiple Sources into the same bucket, the number of objects in a bucket can grow drastically.
This means that with time you might want to scale out certain components e.g:
Source is a any component that creates new metrics in a form of Thanos TSDB blocks uploaded to the object storage. We differentiate Sources by external labels. Having unique sources has several benefits:
cluster, env, replica). Those all the same for all metrics produced by source, we can assume that whole block has those.Example Sources are: Sidecar, Rule, Thanos Receive.
We can then define couple of use cases (some of them where already reported by users):
Our goals for this design it to find and implement solution for:
On each component that works on the object storage (e.g Store GW and Compactor), add --selector.relabel-config (and corresponding --selector.relabel-config-file) that will be used to filter out what blocks should be selected for operations. Examples:
external_labels being cluster=A. We will run second Compactor for blocks with cluster=B external labels.external_labels being cluster=A from object storage. We will run StoreGateway with selector of cluster=A from external labels of blocks.Similar to promtail this config will follow native Prometheus relabel-config syntax.
The relabel config will define filtering process done on every synchronization with object storage.
We will allow potentially manipulating with several of inputs:
__block_id<name>__block_objstore_bucket_endpoint__block_objstore_bucket_name__block_objstore_bucket_pathOutput:
By default, on empty relabel-config, all external labels are assumed. Intuitively blocks without any external labels will be ignored.
All blocks should compose as set of labels to advertise. The input should be based from original meta files. NOT from relabelling. The reasoning is covered in Next Steps section
Example usages would be:
- action: drop
regex: "A"
source_labels:
- cluster
- action: keep
regex: "A"
source_labels:
- cluster
For example:
- action: labeldrop
regex: "^cluster$"
datacenter=ABC external label to the result.- target_label: custom_label
replacement: ABC
Note that current relabel implementation assumes there is always single value for each label. This would need to be adjusted for.