diff --git a/app/vmagent/remotewrite/remotewrite.go b/app/vmagent/remotewrite/remotewrite.go index 36f5b7e69..17bb379b0 100644 --- a/app/vmagent/remotewrite/remotewrite.go +++ b/app/vmagent/remotewrite/remotewrite.go @@ -81,9 +81,21 @@ func Init() { } if *maxHourlySeries > 0 { hourlySeriesLimiter = bloomfilter.NewLimiter(*maxHourlySeries, time.Hour) + _ = metrics.NewGauge(`vmagent_hourly_series_limit_max_series`, func() float64 { + return float64(hourlySeriesLimiter.MaxItems()) + }) + _ = metrics.NewGauge(`vmagent_hourly_series_limit_current_series`, func() float64 { + return float64(hourlySeriesLimiter.CurrentItems()) + }) } if *maxDailySeries > 0 { dailySeriesLimiter = bloomfilter.NewLimiter(*maxDailySeries, 24*time.Hour) + _ = metrics.NewGauge(`vmagent_daily_series_limit_max_series`, func() float64 { + return float64(dailySeriesLimiter.MaxItems()) + }) + _ = metrics.NewGauge(`vmagent_daily_series_limit_current_series`, func() float64 { + return float64(dailySeriesLimiter.CurrentItems()) + }) } if *queues > maxQueues { *queues = maxQueues diff --git a/lib/bloomfilter/limiter.go b/lib/bloomfilter/limiter.go index d07788baf..152d999b0 100644 --- a/lib/bloomfilter/limiter.go +++ b/lib/bloomfilter/limiter.go @@ -33,6 +33,13 @@ func (l *Limiter) MaxItems() int { return l.maxItems } +// CurrentItems return the current number of items registered in l. +func (l *Limiter) CurrentItems() int { + lm := l.v.Load().(*limiter) + n := atomic.LoadUint64(&lm.currentItems) + return int(n) +} + // Add adds h to the limiter. // // It is safe calling Add from concurrent goroutines.