SupportBundle: Add count for each support bundle created (#63125)

* Export `StatsCount` function

* Add new statKV each time a bundle is created

* Export bundle count

---------

Co-authored-by: Jo <joao.guerreiro@grafana.com>
This commit is contained in:
linoman
2023-02-09 14:54:21 +01:00
committed by GitHub
co-authored by Jo
parent a33e316f40
commit 33de1926fc
2 changed files with 60 additions and 2 deletions
@@ -68,6 +68,8 @@ func ProvideService(cfg *setting.Cfg,
serverAdminOnly: section.Key("server_admin_only").MustBool(true),
}
usageStats.RegisterMetricsFunc(s.getUsageStats)
if !features.IsEnabled(featuremgmt.FlagSupportBundles) || !s.enabled {
return s, nil
}
@@ -167,3 +169,15 @@ func (s *Service) cleanup(ctx context.Context) {
}
}
}
func (s *Service) getUsageStats(ctx context.Context) (map[string]interface{}, error) {
m := map[string]interface{}{}
count, err := s.store.StatsCount(ctx)
if err != nil {
s.log.Warn("unable to get support bundle counter", "error", err)
}
m["stats.bundles.count"] = count
return m, nil
}