@@ -452,7 +452,9 @@ func runReceive(
452452 level .Error (logger ).Log ("msg" , "getting top metrics" )
453453 for _ , ts := range dbs .TenantStats (conf .numTopMetricsPerTenant , labels .MetricName ) {
454454 for _ , ms := range ts .Stats .IndexPostingStats .CardinalityMetricsStats {
455- topMetricNumSeries .WithLabelValues (ts .Tenant , ms .Name ).Set (float64 (ms .Count ))
455+ if ms .Count >= conf .topMetricsMinimumCardinality {
456+ topMetricNumSeries .WithLabelValues (ts .Tenant , ms .Name ).Set (float64 (ms .Count ))
457+ }
456458 }
457459 }
458460 return nil
@@ -876,8 +878,9 @@ type receiveConfig struct {
876878
877879 asyncForwardWorkerCount uint
878880
879- numTopMetricsPerTenant int
880- topMetricsUpdateInterval time.Duration
881+ numTopMetricsPerTenant int
882+ topMetricsMinimumCardinality uint64
883+ topMetricsUpdateInterval time.Duration
881884}
882885
883886func (rc * receiveConfig ) registerFlag (cmd extkingpin.FlagClause ) {
@@ -1024,7 +1027,9 @@ func (rc *receiveConfig) registerFlag(cmd extkingpin.FlagClause) {
10241027 Default ("1s" ).Hidden ().DurationVar (& rc .limitsConfigReloadTimer )
10251028
10261029 cmd .Flag ("receive.num-top-metrics-per-tenant" , "The number of top metrics to track for each tenant." ).
1027- Default ("5" ).IntVar (& rc .numTopMetricsPerTenant )
1030+ Default ("100" ).IntVar (& rc .numTopMetricsPerTenant )
1031+ cmd .Flag ("receive.top-metrics-minimum-cardinality" , "The minimum cardinality for a metric to be considered top metric." ).
1032+ Default ("10000" ).Uint64Var (& rc .topMetricsMinimumCardinality )
10281033 cmd .Flag ("receive.top-metrics-update-interval" , "The interval at which the top metrics are updated." ).
10291034 Default ("5m" ).DurationVar (& rc .topMetricsUpdateInterval )
10301035}
0 commit comments