mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Auth: Fix disable/remove duplicate user entries metrics for performance reasons (#61675)
* fix: remove metrics from duplicate user entries * fix: disable metrics collection for authinfo * fix: initifine goroutine loop that happened * removed: metrics
This commit is contained in:
parent
fa36591380
commit
bedd2304d1
@ -29,7 +29,9 @@ func ProvideAuthInfoStore(sqlStore db.DB, secretsService secrets.Service, userSe
|
|||||||
logger: log.New("login.authinfo.store"),
|
logger: log.New("login.authinfo.store"),
|
||||||
userService: userService,
|
userService: userService,
|
||||||
}
|
}
|
||||||
InitMetrics()
|
// FIXME: disabled the metric collection for duplicate user entries
|
||||||
|
// due to query performance issues that is clogging the users Grafana instance
|
||||||
|
// InitDuplicateUserMetrics()
|
||||||
return store
|
return store
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,7 +10,10 @@ import (
|
|||||||
"github.com/grafana/grafana/pkg/services/login"
|
"github.com/grafana/grafana/pkg/services/login"
|
||||||
)
|
)
|
||||||
|
|
||||||
func InitMetrics() {
|
// Should be in use in ProvideAuthInfoStore
|
||||||
|
// due to query performance for big user tables
|
||||||
|
// we have disabled these metrics from Grafana for now
|
||||||
|
func InitDuplicateUserMetrics() {
|
||||||
login.Once.Do(func() {
|
login.Once.Do(func() {
|
||||||
login.MStatDuplicateUserEntries = prometheus.NewGauge(prometheus.GaugeOpts{
|
login.MStatDuplicateUserEntries = prometheus.NewGauge(prometheus.GaugeOpts{
|
||||||
Name: "stat_users_total_duplicate_user_entries",
|
Name: "stat_users_total_duplicate_user_entries",
|
||||||
@ -39,18 +42,18 @@ func InitMetrics() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *AuthInfoStore) RunMetricsCollection(ctx context.Context) error {
|
func (s *AuthInfoStore) RunMetricsCollection(ctx context.Context) error {
|
||||||
if _, err := s.GetLoginStats(ctx); err != nil {
|
// if _, err := s.GetLoginStats(ctx); err != nil {
|
||||||
s.logger.Warn("Failed to get authinfo metrics", "error", err.Error())
|
// s.logger.Warn("Failed to get authinfo metrics", "error", err.Error())
|
||||||
}
|
// }
|
||||||
updateStatsTicker := time.NewTicker(login.MetricsCollectionInterval)
|
updateStatsTicker := time.NewTicker(login.MetricsCollectionInterval)
|
||||||
defer updateStatsTicker.Stop()
|
defer updateStatsTicker.Stop()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-updateStatsTicker.C:
|
case <-updateStatsTicker.C:
|
||||||
if _, err := s.GetLoginStats(ctx); err != nil {
|
// if _, err := s.GetLoginStats(ctx); err != nil {
|
||||||
s.logger.Warn("Failed to get authinfo metrics", "error", err.Error())
|
// s.logger.Warn("Failed to get authinfo metrics", "error", nil)
|
||||||
}
|
// }
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return ctx.Err()
|
return ctx.Err()
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,9 @@ func ProvideAuthInfoService(userProtectionService login.UserProtectionService, a
|
|||||||
authInfoStore: authInfoStore,
|
authInfoStore: authInfoStore,
|
||||||
logger: log.New("login.authinfo"),
|
logger: log.New("login.authinfo"),
|
||||||
}
|
}
|
||||||
usageStats.RegisterMetricsFunc(authInfoStore.CollectLoginStats)
|
// FIXME: disabled metrics until further notice
|
||||||
|
// query performance is slow for more than 20000 users
|
||||||
|
// usageStats.RegisterMetricsFunc(authInfoStore.CollectLoginStats)
|
||||||
return s
|
return s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user