adds usage stats for alert notifiers (#13173)
This commit is contained in:
committed by
Torkel Ödegaard
parent
44cd738dd9
commit
b070784b8a
@@ -13,11 +13,19 @@ func init() {
|
||||
bus.AddHandler("sql", GetDataSourceStats)
|
||||
bus.AddHandler("sql", GetDataSourceAccessStats)
|
||||
bus.AddHandler("sql", GetAdminStats)
|
||||
bus.AddHandlerCtx("sql", GetAlertNotifiersUsageStats)
|
||||
bus.AddHandlerCtx("sql", GetSystemUserCountStats)
|
||||
}
|
||||
|
||||
var activeUserTimeLimit = time.Hour * 24 * 30
|
||||
|
||||
func GetAlertNotifiersUsageStats(ctx context.Context, query *m.GetAlertNotifierUsageStatsQuery) error {
|
||||
var rawSql = `SELECT COUNT(*) as count, type FROM alert_notification GROUP BY type`
|
||||
query.Result = make([]*m.NotifierUsageStats, 0)
|
||||
err := x.SQL(rawSql).Find(&query.Result)
|
||||
return err
|
||||
}
|
||||
|
||||
func GetDataSourceStats(query *m.GetDataSourceStatsQuery) error {
|
||||
var rawSql = `SELECT COUNT(*) as count, type FROM data_source GROUP BY type`
|
||||
query.Result = make([]*m.DataSourceStats, 0)
|
||||
|
||||
@@ -36,5 +36,11 @@ func TestStatsDataAccess(t *testing.T) {
|
||||
err := GetDataSourceAccessStats(&query)
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
|
||||
Convey("Get alert notifier stats should not results in error", func() {
|
||||
query := m.GetAlertNotifierUsageStatsQuery{}
|
||||
err := GetAlertNotifiersUsageStats(context.Background(), &query)
|
||||
So(err, ShouldBeNil)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user