From ad97db937c0d8de14a8a3779154df51b5b11a36a Mon Sep 17 00:00:00 2001 From: bergquist Date: Fri, 11 Nov 2016 13:57:11 +0100 Subject: [PATCH] feat(stats_usage): add stats about alerts --- pkg/metrics/publish.go | 1 + pkg/models/stats.go | 1 + pkg/services/sqlstore/stats.go | 6 +++++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/pkg/metrics/publish.go b/pkg/metrics/publish.go index 4255481b8d1..70db3fc0f86 100644 --- a/pkg/metrics/publish.go +++ b/pkg/metrics/publish.go @@ -101,6 +101,7 @@ func sendUsageStats() { metrics["stats.plugins.apps.count"] = len(plugins.Apps) metrics["stats.plugins.panels.count"] = len(plugins.Panels) metrics["stats.plugins.datasources.count"] = len(plugins.DataSources) + metrics["stats.alerts.count"] = statsQuery.Result.AlertCount dsStats := m.GetDataSourceStatsQuery{} if err := bus.Dispatch(&dsStats); err != nil { diff --git a/pkg/models/stats.go b/pkg/models/stats.go index 067dec763e5..9db645f76ac 100644 --- a/pkg/models/stats.go +++ b/pkg/models/stats.go @@ -5,6 +5,7 @@ type SystemStats struct { UserCount int64 OrgCount int64 PlaylistCount int64 + AlertCount int64 } type DataSourceStats struct { diff --git a/pkg/services/sqlstore/stats.go b/pkg/services/sqlstore/stats.go index 7580996ad57..eaf461c4d28 100644 --- a/pkg/services/sqlstore/stats.go +++ b/pkg/services/sqlstore/stats.go @@ -39,7 +39,11 @@ func GetSystemStats(query *m.GetSystemStatsQuery) error { ( SELECT COUNT(*) FROM ` + dialect.Quote("playlist") + ` - ) AS playlist_count + ) AS playlist_count, + ( + SELECT COUNT(*) + FROM ` + dialect.Quote("alert") + ` + ) AS alert_count ` var stats m.SystemStats