Analytics: Add total dashboard byte size to reporting (#66425)

Co-authored-by: Dan Cech <dcech@grafana.com>
This commit is contained in:
Ryan McKinley 2023-04-13 11:37:03 -07:00 committed by GitHub
parent 1b46d2f5bd
commit fef490e4f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 0 deletions

View File

@ -115,6 +115,8 @@ func (s *Service) collectSystemStats(ctx context.Context) (map[string]interface{
}
m["stats.dashboards.count"] = statsResult.Dashboards
m["stats.dashboard_bytes.total"] = statsResult.DashboardBytesTotal
m["stats.dashboard_bytes.max"] = statsResult.DashboardBytesMax
m["stats.users.count"] = statsResult.Users
m["stats.admins.count"] = statsResult.Admins
m["stats.editors.count"] = statsResult.Editors

View File

@ -2,6 +2,8 @@ package stats
type SystemStats struct {
Dashboards int64
DashboardBytesTotal int64
DashboardBytesMax int64
Datasources int64
Users int64
ActiveUsers int64

View File

@ -89,6 +89,8 @@ func (ss *sqlStatsService) GetSystemStats(ctx context.Context, query *stats.GetS
notServiceAccount(dialect)+` AND last_seen_at > ?) AS monthly_active_users,`, monthlyActiveUserDeadlineDate)
sb.Write(`(SELECT COUNT(id) FROM `+dialect.Quote("dashboard")+` WHERE is_folder = ?) AS dashboards,`, dialect.BooleanStr(false))
sb.Write(`(SELECT SUM(LENGTH(data)) FROM `+dialect.Quote("dashboard")+` WHERE is_folder = ?) AS dashboard_bytes_total,`, dialect.BooleanStr(false))
sb.Write(`(SELECT MAX(LENGTH(data)) FROM `+dialect.Quote("dashboard")+` WHERE is_folder = ?) AS dashboard_bytes_max,`, dialect.BooleanStr(false))
sb.Write(`(SELECT COUNT(id) FROM `+dialect.Quote("dashboard")+` WHERE is_folder = ?) AS folders,`, dialect.BooleanStr(true))
sb.Write(`(