mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
app/vmagent/remotewrite: expose metrics with the current number of active series per day and per hour
These numbers are exposed via the following metrics: - vmagent_hourly_series_limit_current_series - vmagent_daily_series_limit_current_series Expose also the limits via the following metrics: - vmagent_hourly_series_limit_max_series - vmagent_daily_series_limit_max_series
This commit is contained in:
parent
ad73f226ff
commit
e394ff6466
2 changed files with 19 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in a new issue