diff --git a/conf/defaults.ini b/conf/defaults.ini index ff0901874f7..d09dfe3c428 100644 --- a/conf/defaults.ini +++ b/conf/defaults.ini @@ -162,6 +162,9 @@ send_user_header = false # Change this option to false to disable reporting. 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 # for new versions (grafana itself and plugins), check is used # in some UI views to notify that grafana or plugin update exists diff --git a/conf/sample.ini b/conf/sample.ini index b0a182d03c6..80bae2091de 100644 --- a/conf/sample.ini +++ b/conf/sample.ini @@ -168,6 +168,9 @@ # Change this option to false to disable reporting. ;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 # for new versions (grafana itself and plugins), check is used # in some UI views to notify that grafana or plugin update exists diff --git a/pkg/infra/usagestats/usage_stats.go b/pkg/infra/usagestats/usage_stats.go index 2fcf58f9b44..e114eef9f05 100644 --- a/pkg/infra/usagestats/usage_stats.go +++ b/pkg/infra/usagestats/usage_stats.go @@ -103,6 +103,7 @@ func (uss *UsageStatsService) GetUsageReport(ctx context.Context) (UsageReport, metrics["stats.ds.other.count"] = dsOtherCount metrics["stats.packaging."+setting.Packaging+".count"] = 1 + metrics["stats.distributor."+setting.ReportingDistributor+".count"] = 1 // Alerting stats alertingUsageStats, err := uss.AlertingUsageStats.QueryUsageStats() diff --git a/pkg/infra/usagestats/usage_stats_test.go b/pkg/infra/usagestats/usage_stats_test.go index 8a0acefbd55..6d96b6df57a 100644 --- a/pkg/infra/usagestats/usage_stats_test.go +++ b/pkg/infra/usagestats/usage_stats_test.go @@ -212,6 +212,7 @@ func TestMetrics(t *testing.T) { setting.LDAPEnabled = true setting.AuthProxyEnabled = true setting.Packaging = "deb" + setting.ReportingDistributor = "hosted-grafana" wg.Add(1) err := uss.sendUsageStats(context.Background()) @@ -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.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, 2, metrics.Get("stats.auth_token_per_user_le_6").MustInt()) diff --git a/pkg/setting/setting.go b/pkg/setting/setting.go index 59f9e84dc25..0e01807b035 100644 --- a/pkg/setting/setting.go +++ b/pkg/setting/setting.go @@ -141,10 +141,12 @@ var ( appliedCommandLineProperties []string appliedEnvOverrides []string - ReportingEnabled bool - CheckForUpdates bool - GoogleAnalyticsId string - GoogleTagManagerId string + // analytics + ReportingEnabled bool + ReportingDistributor string + CheckForUpdates bool + GoogleAnalyticsId string + GoogleTagManagerId string // LDAP LDAPEnabled bool @@ -815,10 +817,14 @@ func (cfg *Cfg) Load(args *CommandLineArgs) error { cfg.MetricsEndpointDisableTotalStats = iniFile.Section("metrics").Key("disable_total_stats").MustBool(false) analytics := iniFile.Section("analytics") - ReportingEnabled = analytics.Key("reporting_enabled").MustBool(true) CheckForUpdates = analytics.Key("check_for_updates").MustBool(true) GoogleAnalyticsId = analytics.Key("google_analytics_ua_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 { return err