Просмотр исходного кода

feat(stats_usage): add stats about alerts

bergquist 9 лет назад
Родитель
Сommit
ad97db937c
3 измененных файлов с 7 добавлено и 1 удалено
  1. 1 0
      pkg/metrics/publish.go
  2. 1 0
      pkg/models/stats.go
  3. 5 1
      pkg/services/sqlstore/stats.go

+ 1 - 0
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 {

+ 1 - 0
pkg/models/stats.go

@@ -5,6 +5,7 @@ type SystemStats struct {
 	UserCount      int64
 	OrgCount       int64
 	PlaylistCount  int64
+	AlertCount     int64
 }
 
 type DataSourceStats struct {

+ 5 - 1
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