mirror of
https://github.com/grafana/grafana.git
synced 2024-12-28 18:01:40 -06:00
Usagestats: Exclude folders from total dashboard count (#31320)
Signed-off-by: bergquist <carl.bergquist@gmail.com>
This commit is contained in:
parent
0e63dfafbe
commit
95c8766f86
@ -126,6 +126,9 @@ var (
|
||||
// MStatTotalDashboards is a metric total amount of dashboards
|
||||
MStatTotalDashboards prometheus.Gauge
|
||||
|
||||
// MStatTotalDashboards is a metric total amount of dashboards
|
||||
MStatTotalFolders prometheus.Gauge
|
||||
|
||||
// MStatTotalUsers is a metric total amount of users
|
||||
MStatTotalUsers prometheus.Gauge
|
||||
|
||||
@ -412,6 +415,12 @@ func init() {
|
||||
Namespace: ExporterName,
|
||||
})
|
||||
|
||||
MStatTotalFolders = prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
Name: "stat_totals_folder",
|
||||
Help: "total amount of folders",
|
||||
Namespace: ExporterName,
|
||||
})
|
||||
|
||||
MStatTotalUsers = prometheus.NewGauge(prometheus.GaugeOpts{
|
||||
Name: "stat_total_users",
|
||||
Help: "total amount of users",
|
||||
@ -575,6 +584,7 @@ func initMetricVars() {
|
||||
MRenderingQueue,
|
||||
MAlertingActiveAlerts,
|
||||
MStatTotalDashboards,
|
||||
MStatTotalFolders,
|
||||
MStatTotalUsers,
|
||||
MStatActiveUsers,
|
||||
MStatTotalOrgs,
|
||||
|
@ -265,6 +265,7 @@ func (uss *UsageStatsService) updateTotalStats() {
|
||||
}
|
||||
|
||||
metrics.MStatTotalDashboards.Set(float64(statsQuery.Result.Dashboards))
|
||||
metrics.MStatTotalFolders.Set(float64(statsQuery.Result.Folders))
|
||||
metrics.MStatTotalUsers.Set(float64(statsQuery.Result.Users))
|
||||
metrics.MStatActiveUsers.Set(float64(statsQuery.Result.ActiveUsers))
|
||||
metrics.MStatTotalPlaylists.Set(float64(statsQuery.Result.Playlists))
|
||||
|
@ -46,7 +46,6 @@ func GetSystemStats(query *models.GetSystemStatsQuery) error {
|
||||
sb.Write("SELECT ")
|
||||
sb.Write(`(SELECT COUNT(*) FROM ` + dialect.Quote("user") + `) AS users,`)
|
||||
sb.Write(`(SELECT COUNT(*) FROM ` + dialect.Quote("org") + `) AS orgs,`)
|
||||
sb.Write(`(SELECT COUNT(*) FROM ` + dialect.Quote("dashboard") + `) AS dashboards,`)
|
||||
sb.Write(`(SELECT COUNT(*) FROM ` + dialect.Quote("data_source") + `) AS datasources,`)
|
||||
sb.Write(`(SELECT COUNT(*) FROM ` + dialect.Quote("star") + `) AS stars,`)
|
||||
sb.Write(`(SELECT COUNT(*) FROM ` + dialect.Quote("playlist") + `) AS playlists,`)
|
||||
@ -55,6 +54,7 @@ func GetSystemStats(query *models.GetSystemStatsQuery) error {
|
||||
activeUserDeadlineDate := time.Now().Add(-activeUserTimeLimit)
|
||||
sb.Write(`(SELECT COUNT(*) FROM `+dialect.Quote("user")+` WHERE last_seen_at > ?) AS active_users,`, activeUserDeadlineDate)
|
||||
|
||||
sb.Write(`(SELECT COUNT(id) FROM `+dialect.Quote("dashboard")+` WHERE is_folder = ?) AS dashboards,`, dialect.BooleanStr(false))
|
||||
sb.Write(`(SELECT COUNT(id) FROM `+dialect.Quote("dashboard")+` WHERE is_folder = ?) AS folders,`, dialect.BooleanStr(true))
|
||||
|
||||
sb.Write(`(
|
||||
@ -119,7 +119,7 @@ func GetAdminStats(query *models.GetAdminStatsQuery) error {
|
||||
) AS orgs,
|
||||
(
|
||||
SELECT COUNT(*)
|
||||
FROM ` + dialect.Quote("dashboard") + `
|
||||
FROM ` + dialect.Quote("dashboard") + `WHERE is_folder=` + dialect.BooleanStr(false) + `
|
||||
) AS dashboards,
|
||||
(
|
||||
SELECT COUNT(*)
|
||||
|
Loading…
Reference in New Issue
Block a user