Open
Conversation
fac201a to
916a2ed
Compare
hczhu-db
suggested changes
Sep 2, 2025
Comment on lines
+1210
to
+1211
| cmd.Flag("receive.metric-name-shards", "When set and greater than 0, enables metric name sharding. In RouterOnly mode, modifies tenant header to {hashring-name}-{hash(metric_name) % shards}. In IngestorOnly/RouterIngestor mode, optimizes query fan-out by only querying TSDBs matching the metric's shard. Disables cuckoo filter when enabled."). | ||
| Default("0").IntVar(&rc.metricNameShards) |
There was a problem hiding this comment.
We should use a configmap for the sharding schema instead of a command flag. Thanos Router needs to support the schema defined in the V2 design doc. It has special metric groups besides the number of shards for each metric scope.
scopeName: "az-eastus2",
shards: 20,
// The metrics that are heavily used by alert rules or have super high cardinality
// can be in special groups to avoid skewed data partitions.
specialMetricGroups: [
{
name: "kube-metrics",
metrics: [
"container_cpu_usage_seconds_total",
"container_memory_working_set_bytes"
]
},
{
name: "rpc-metrics",
metrics: ["rpc_client_requests_total"]
}
]
}
=== shard name calculation ===
if metric_name in any special metric group then
shard_name = the speical metric group name
else
shard_name = hash(metric_name) % shards
| hash := hasher.Sum64() | ||
|
|
||
| shard := hash % uint64(h.metricNameShards) | ||
| modifiedTenant := fmt.Sprintf("%s-%d", hashringName, shard) |
There was a problem hiding this comment.
What semantics will hashringName have in our context?
Collaborator
Author
|
let's discuss in meeting. Deleted the screenshot in this public repo |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added a new flag --receive.metric-name-shards that creates tenant sharding based on metric names.
How it works:
Benefits:
Note that routing is not changed at all. It is more complicated and we will have another PR to address it.