Commit d1b9fddb by Carl Bergquist Committed by GitHub

Usage stats: Adds source/distributor setting (#31039)

Signed-off-by: bergquist <carl.bergquist@gmail.com>
parent d6e8e476
...@@ -162,6 +162,9 @@ send_user_header = false ...@@ -162,6 +162,9 @@ send_user_header = false
# Change this option to false to disable reporting. # Change this option to false to disable reporting.
reporting_enabled = true reporting_enabled = true
# The name of the distributor of the Grafana instance. Ex hosted-grafana, grafana-labs
reporting_distributor = grafana-labs
# Set to false to disable all checks to https://grafana.com # Set to false to disable all checks to https://grafana.com
# for new versions (grafana itself and plugins), check is used # for new versions (grafana itself and plugins), check is used
# in some UI views to notify that grafana or plugin update exists # in some UI views to notify that grafana or plugin update exists
......
...@@ -168,6 +168,9 @@ ...@@ -168,6 +168,9 @@
# Change this option to false to disable reporting. # Change this option to false to disable reporting.
;reporting_enabled = true ;reporting_enabled = true
# The name of the distributor of the Grafana instance. Ex hosted-grafana, grafana-labs
;reporting_distributor = grafana-labs
# Set to false to disable all checks to https://grafana.net # Set to false to disable all checks to https://grafana.net
# for new versions (grafana itself and plugins), check is used # for new versions (grafana itself and plugins), check is used
# in some UI views to notify that grafana or plugin update exists # in some UI views to notify that grafana or plugin update exists
......
...@@ -103,6 +103,7 @@ func (uss *UsageStatsService) GetUsageReport(ctx context.Context) (UsageReport, ...@@ -103,6 +103,7 @@ func (uss *UsageStatsService) GetUsageReport(ctx context.Context) (UsageReport,
metrics["stats.ds.other.count"] = dsOtherCount metrics["stats.ds.other.count"] = dsOtherCount
metrics["stats.packaging."+setting.Packaging+".count"] = 1 metrics["stats.packaging."+setting.Packaging+".count"] = 1
metrics["stats.distributor."+setting.ReportingDistributor+".count"] = 1
// Alerting stats // Alerting stats
alertingUsageStats, err := uss.AlertingUsageStats.QueryUsageStats() alertingUsageStats, err := uss.AlertingUsageStats.QueryUsageStats()
......
...@@ -212,6 +212,7 @@ func TestMetrics(t *testing.T) { ...@@ -212,6 +212,7 @@ func TestMetrics(t *testing.T) {
setting.LDAPEnabled = true setting.LDAPEnabled = true
setting.AuthProxyEnabled = true setting.AuthProxyEnabled = true
setting.Packaging = "deb" setting.Packaging = "deb"
setting.ReportingDistributor = "hosted-grafana"
wg.Add(1) wg.Add(1)
err := uss.sendUsageStats(context.Background()) err := uss.sendUsageStats(context.Background())
...@@ -293,6 +294,7 @@ func TestMetrics(t *testing.T) { ...@@ -293,6 +294,7 @@ func TestMetrics(t *testing.T) {
assert.Equal(t, 1, metrics.Get("stats.auth_enabled.oauth_grafana_com.count").MustInt()) assert.Equal(t, 1, metrics.Get("stats.auth_enabled.oauth_grafana_com.count").MustInt())
assert.Equal(t, 1, metrics.Get("stats.packaging.deb.count").MustInt()) assert.Equal(t, 1, metrics.Get("stats.packaging.deb.count").MustInt())
assert.Equal(t, 1, metrics.Get("stats.distributor.hosted-grafana.count").MustInt())
assert.Equal(t, 1, metrics.Get("stats.auth_token_per_user_le_3").MustInt()) assert.Equal(t, 1, metrics.Get("stats.auth_token_per_user_le_3").MustInt())
assert.Equal(t, 2, metrics.Get("stats.auth_token_per_user_le_6").MustInt()) assert.Equal(t, 2, metrics.Get("stats.auth_token_per_user_le_6").MustInt())
......
...@@ -141,7 +141,9 @@ var ( ...@@ -141,7 +141,9 @@ var (
appliedCommandLineProperties []string appliedCommandLineProperties []string
appliedEnvOverrides []string appliedEnvOverrides []string
// analytics
ReportingEnabled bool ReportingEnabled bool
ReportingDistributor string
CheckForUpdates bool CheckForUpdates bool
GoogleAnalyticsId string GoogleAnalyticsId string
GoogleTagManagerId string GoogleTagManagerId string
...@@ -815,10 +817,14 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error { ...@@ -815,10 +817,14 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error {
cfg.MetricsEndpointDisableTotalStats = iniFile.Section("metrics").Key("disable_total_stats").MustBool(false) cfg.MetricsEndpointDisableTotalStats = iniFile.Section("metrics").Key("disable_total_stats").MustBool(false)
analytics := iniFile.Section("analytics") analytics := iniFile.Section("analytics")
ReportingEnabled = analytics.Key("reporting_enabled").MustBool(true)
CheckForUpdates = analytics.Key("check_for_updates").MustBool(true) CheckForUpdates = analytics.Key("check_for_updates").MustBool(true)
GoogleAnalyticsId = analytics.Key("google_analytics_ua_id").String() GoogleAnalyticsId = analytics.Key("google_analytics_ua_id").String()
GoogleTagManagerId = analytics.Key("google_tag_manager_id").String() GoogleTagManagerId = analytics.Key("google_tag_manager_id").String()
ReportingEnabled = analytics.Key("reporting_enabled").MustBool(true)
ReportingDistributor = analytics.Key("reporting_distributor").MustString("grafana-labs")
if len(ReportingDistributor) >= 100 {
ReportingDistributor = ReportingDistributor[:100]
}
if err := readAlertingSettings(iniFile); err != nil { if err := readAlertingSettings(iniFile); err != nil {
return err return err
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment