|
|
@@ -36,12 +36,6 @@ func sendUsageStats() {
|
|
|
"metrics": metrics,
|
|
|
}
|
|
|
|
|
|
- statsQuery := m.GetSystemStatsQuery{}
|
|
|
- if err := bus.Dispatch(&statsQuery); err != nil {
|
|
|
- log.Error(3, "Failed to get system stats", err)
|
|
|
- return
|
|
|
- }
|
|
|
-
|
|
|
UsageStats.Each(func(name string, i interface{}) {
|
|
|
switch metric := i.(type) {
|
|
|
case Counter:
|
|
|
@@ -52,11 +46,36 @@ func sendUsageStats() {
|
|
|
}
|
|
|
})
|
|
|
|
|
|
+ statsQuery := m.GetSystemStatsQuery{}
|
|
|
+ if err := bus.Dispatch(&statsQuery); err != nil {
|
|
|
+ log.Error(3, "Failed to get system stats", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
metrics["stats.dashboards.count"] = statsQuery.Result.DashboardCount
|
|
|
metrics["stats.users.count"] = statsQuery.Result.UserCount
|
|
|
metrics["stats.orgs.count"] = statsQuery.Result.OrgCount
|
|
|
|
|
|
- out, _ := json.Marshal(report)
|
|
|
+ dsStats := m.GetDataSourceStatsQuery{}
|
|
|
+ if err := bus.Dispatch(&dsStats); err != nil {
|
|
|
+ log.Error(3, "Failed to get datasource stats", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ // send counters for each data source
|
|
|
+ // but ignore any custom data sources
|
|
|
+ // as sending that name could be sensitive information
|
|
|
+ dsOtherCount := 0
|
|
|
+ for _, dsStat := range dsStats.Result {
|
|
|
+ if m.IsStandardDataSource(dsStat.Type) {
|
|
|
+ metrics["stats.ds."+dsStat.Type+".count"] = dsStat.Count
|
|
|
+ } else {
|
|
|
+ dsOtherCount += dsStat.Count
|
|
|
+ }
|
|
|
+ }
|
|
|
+ metrics["stats.ds.other.count"] = dsOtherCount
|
|
|
+
|
|
|
+ out, _ := json.MarshalIndent(report, "", " ")
|
|
|
data := bytes.NewBuffer(out)
|
|
|
|
|
|
client := http.Client{Timeout: time.Duration(5 * time.Second)}
|