Skip to content

Commit 89493ad

Browse files
committed
add flags
1 parent d45908c commit 89493ad

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

cmd/thanos/receive.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -448,9 +448,9 @@ func runReceive(
448448
}, []string{"tenant", "metric_name"})
449449
ctx, cancel := context.WithCancel(context.Background())
450450
g.Add(func() error {
451-
return runutil.Repeat(30*time.Second, ctx.Done(), func() error {
451+
return runutil.Repeat(conf.topMetricsUpdateInterval, ctx.Done(), func() error {
452452
level.Error(logger).Log("msg", "getting top metrics")
453-
for _, ts := range dbs.TenantStats(10, labels.MetricName) {
453+
for _, ts := range dbs.TenantStats(conf.numTopMetricsPerTenant, labels.MetricName) {
454454
for _, ms := range ts.Stats.IndexPostingStats.CardinalityMetricsStats {
455455
topMetricNumSeries.WithLabelValues(ts.Tenant, ms.Name).Set(float64(ms.Count))
456456
}
@@ -875,6 +875,9 @@ type receiveConfig struct {
875875
limitsConfigReloadTimer time.Duration
876876

877877
asyncForwardWorkerCount uint
878+
879+
numTopMetricsPerTenant int
880+
topMetricsUpdateInterval time.Duration
878881
}
879882

880883
func (rc *receiveConfig) registerFlag(cmd extkingpin.FlagClause) {
@@ -1019,6 +1022,11 @@ func (rc *receiveConfig) registerFlag(cmd extkingpin.FlagClause) {
10191022
rc.writeLimitsConfig = extflag.RegisterPathOrContent(cmd, "receive.limits-config", "YAML file that contains limit configuration.", extflag.WithEnvSubstitution(), extflag.WithHidden())
10201023
cmd.Flag("receive.limits-config-reload-timer", "Minimum amount of time to pass for the limit configuration to be reloaded. Helps to avoid excessive reloads.").
10211024
Default("1s").Hidden().DurationVar(&rc.limitsConfigReloadTimer)
1025+
1026+
cmd.Flag("receive.num-top-metrics-per-tenant", "The number of top metrics to track for each tenant.").
1027+
Default("5").IntVar(&rc.numTopMetricsPerTenant)
1028+
cmd.Flag("receive.top-metrics-update-interval", "The interval at which the top metrics are updated.").
1029+
Default("5m").DurationVar(&rc.topMetricsUpdateInterval)
10221030
}
10231031

10241032
// determineMode returns the ReceiverMode that this receiver is configured to run in.

0 commit comments

Comments
 (0)