Rename usagestats to analytics (#9212)

**What this PR does / why we need it**:

Rename usagestats to analytics. The config section in the yaml is
already called analytics, this makes things more consistent.

**Checklist**
- [x] Reviewed the
[`CONTRIBUTING.md`](https://github.com/grafana/loki/blob/main/CONTRIBUTING.md)
guide (**required**)
- [x] Documentation added
- [ ] Tests updated
- [x] `CHANGELOG.md` updated
- [x] Changes that require user attention or interaction to upgrade are
documented in `docs/sources/upgrading/_index.md`
pull/9332/head
Trevor Whitney 3 years ago committed by GitHub
parent 2cec818a79
commit 50bc1cee71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      CHANGELOG.md
  2. 4
      docs/sources/configuration/_index.md
  3. 2
      pkg/analytics/reporter.go
  4. 2
      pkg/analytics/reporter_test.go
  5. 2
      pkg/analytics/seed.go
  6. 2
      pkg/analytics/seed_test.go
  7. 2
      pkg/analytics/stats.go
  8. 2
      pkg/analytics/stats_test.go
  9. 4
      pkg/distributor/distributor.go
  10. 10
      pkg/ingester/ingester.go
  11. 4
      pkg/ingester/instance.go
  12. 30
      pkg/ingester/metrics.go
  13. 6
      pkg/loghttp/push/push.go
  14. 10
      pkg/logql/metrics.go
  15. 36
      pkg/loki/loki.go
  16. 18
      pkg/loki/modules.go
  17. 8
      pkg/storage/store.go
  18. 6
      pkg/storage/stores/indexshipper/compactor/compactor.go
  19. 6
      tools/doc-generator/parse/root_blocks.go

@ -36,6 +36,10 @@
* [9252](https://github.com/grafana/loki/pull/9252) **jeschkies**: Use un-escaped regex literal for string matching. * [9252](https://github.com/grafana/loki/pull/9252) **jeschkies**: Use un-escaped regex literal for string matching.
* [9176](https://github.com/grafana/loki/pull/9176) **DylanGuedes**: Fix incorrect association of per-stream rate limit when sharding is enabled. * [9176](https://github.com/grafana/loki/pull/9176) **DylanGuedes**: Fix incorrect association of per-stream rate limit when sharding is enabled.
##### Changes
* [9212](https://github.com/grafana/loki/pull/9212) **trevorwhitney**: Rename UsageReport to Analytics. The only external impact of this change is a change in the `-list-targets` output.
#### Promtail #### Promtail
##### Enhancements ##### Enhancements

@ -192,7 +192,7 @@ Pass the `-config.expand-env` flag at the command line to enable this way of set
# Configuration for tracing. # Configuration for tracing.
[tracing: <tracing>] [tracing: <tracing>]
# Configuration for usage report. # Configuration for analytics.
[analytics: <analytics>] [analytics: <analytics>]
# Common configuration to be shared between multiple modules. If a more specific # Common configuration to be shared between multiple modules. If a more specific
@ -2962,7 +2962,7 @@ Configuration for `tracing`.
### analytics ### analytics
Configuration for usage report. Configuration for `analytics`.
```yaml ```yaml
# Enable anonymous usage reporting. # Enable anonymous usage reporting.

@ -1,4 +1,4 @@
package usagestats package analytics
import ( import (
"bytes" "bytes"

@ -1,4 +1,4 @@
package usagestats package analytics
import ( import (
"context" "context"

@ -1,4 +1,4 @@
package usagestats package analytics
import ( import (
"fmt" "fmt"

@ -1,4 +1,4 @@
package usagestats package analytics
import ( import (
"context" "context"

@ -1,4 +1,4 @@
package usagestats package analytics
import ( import (
"bytes" "bytes"

@ -1,4 +1,4 @@
package usagestats package analytics
import ( import (
"runtime" "runtime"

@ -31,6 +31,7 @@ import (
"github.com/weaveworks/common/user" "github.com/weaveworks/common/user"
"go.uber.org/atomic" "go.uber.org/atomic"
"github.com/grafana/loki/pkg/analytics"
"github.com/grafana/loki/pkg/distributor/clientpool" "github.com/grafana/loki/pkg/distributor/clientpool"
"github.com/grafana/loki/pkg/distributor/shardstreams" "github.com/grafana/loki/pkg/distributor/shardstreams"
"github.com/grafana/loki/pkg/ingester/client" "github.com/grafana/loki/pkg/ingester/client"
@ -38,7 +39,6 @@ import (
"github.com/grafana/loki/pkg/logql/syntax" "github.com/grafana/loki/pkg/logql/syntax"
"github.com/grafana/loki/pkg/runtime" "github.com/grafana/loki/pkg/runtime"
"github.com/grafana/loki/pkg/storage/stores/indexshipper/compactor/retention" "github.com/grafana/loki/pkg/storage/stores/indexshipper/compactor/retention"
"github.com/grafana/loki/pkg/usagestats"
"github.com/grafana/loki/pkg/util" "github.com/grafana/loki/pkg/util"
util_log "github.com/grafana/loki/pkg/util/log" util_log "github.com/grafana/loki/pkg/util/log"
"github.com/grafana/loki/pkg/validation" "github.com/grafana/loki/pkg/validation"
@ -52,7 +52,7 @@ const (
var ( var (
maxLabelCacheSize = 100000 maxLabelCacheSize = 100000
rfStats = usagestats.NewInt("distributor_replication_factor") rfStats = analytics.NewInt("distributor_replication_factor")
) )
// Config for a Distributor. // Config for a Distributor.

@ -26,6 +26,7 @@ import (
"github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/model/labels"
"google.golang.org/grpc/health/grpc_health_v1" "google.golang.org/grpc/health/grpc_health_v1"
"github.com/grafana/loki/pkg/analytics"
"github.com/grafana/loki/pkg/chunkenc" "github.com/grafana/loki/pkg/chunkenc"
"github.com/grafana/loki/pkg/ingester/client" "github.com/grafana/loki/pkg/ingester/client"
"github.com/grafana/loki/pkg/ingester/index" "github.com/grafana/loki/pkg/ingester/index"
@ -40,7 +41,6 @@ import (
"github.com/grafana/loki/pkg/storage/chunk/fetcher" "github.com/grafana/loki/pkg/storage/chunk/fetcher"
"github.com/grafana/loki/pkg/storage/config" "github.com/grafana/loki/pkg/storage/config"
index_stats "github.com/grafana/loki/pkg/storage/stores/index/stats" index_stats "github.com/grafana/loki/pkg/storage/stores/index/stats"
"github.com/grafana/loki/pkg/usagestats"
"github.com/grafana/loki/pkg/util" "github.com/grafana/loki/pkg/util"
util_log "github.com/grafana/loki/pkg/util/log" util_log "github.com/grafana/loki/pkg/util/log"
"github.com/grafana/loki/pkg/util/wal" "github.com/grafana/loki/pkg/util/wal"
@ -62,10 +62,10 @@ var (
Name: "cortex_ingester_flush_queue_length", Name: "cortex_ingester_flush_queue_length",
Help: "The total number of series pending in the flush queue.", Help: "The total number of series pending in the flush queue.",
}) })
compressionStats = usagestats.NewString("ingester_compression") compressionStats = analytics.NewString("ingester_compression")
targetSizeStats = usagestats.NewInt("ingester_target_size_bytes") targetSizeStats = analytics.NewInt("ingester_target_size_bytes")
walStats = usagestats.NewString("ingester_wal") walStats = analytics.NewString("ingester_wal")
activeTenantsStats = usagestats.NewInt("ingester_active_tenants") activeTenantsStats = analytics.NewInt("ingester_active_tenants")
) )
// Config for an ingester. // Config for an ingester.

@ -19,6 +19,7 @@ import (
"github.com/weaveworks/common/httpgrpc" "github.com/weaveworks/common/httpgrpc"
"go.uber.org/atomic" "go.uber.org/atomic"
"github.com/grafana/loki/pkg/analytics"
"github.com/grafana/loki/pkg/ingester/index" "github.com/grafana/loki/pkg/ingester/index"
"github.com/grafana/loki/pkg/ingester/wal" "github.com/grafana/loki/pkg/ingester/wal"
"github.com/grafana/loki/pkg/iter" "github.com/grafana/loki/pkg/iter"
@ -30,7 +31,6 @@ import (
"github.com/grafana/loki/pkg/runtime" "github.com/grafana/loki/pkg/runtime"
"github.com/grafana/loki/pkg/storage/chunk" "github.com/grafana/loki/pkg/storage/chunk"
"github.com/grafana/loki/pkg/storage/config" "github.com/grafana/loki/pkg/storage/config"
"github.com/grafana/loki/pkg/usagestats"
"github.com/grafana/loki/pkg/util" "github.com/grafana/loki/pkg/util"
"github.com/grafana/loki/pkg/util/deletion" "github.com/grafana/loki/pkg/util/deletion"
util_log "github.com/grafana/loki/pkg/util/log" util_log "github.com/grafana/loki/pkg/util/log"
@ -70,7 +70,7 @@ var (
Help: "The total number of streams removed per tenant.", Help: "The total number of streams removed per tenant.",
}, []string{"tenant"}) }, []string{"tenant"})
streamsCountStats = usagestats.NewInt("ingester_streams_count") streamsCountStats = analytics.NewInt("ingester_streams_count")
) )
type instance struct { type instance struct {

@ -4,7 +4,7 @@ import (
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/promauto" "github.com/prometheus/client_golang/prometheus/promauto"
"github.com/grafana/loki/pkg/usagestats" "github.com/grafana/loki/pkg/analytics"
"github.com/grafana/loki/pkg/validation" "github.com/grafana/loki/pkg/validation"
) )
@ -48,17 +48,17 @@ type ingesterMetrics struct {
chunkEncodeTime prometheus.Histogram chunkEncodeTime prometheus.Histogram
chunksFlushedPerReason *prometheus.CounterVec chunksFlushedPerReason *prometheus.CounterVec
chunkLifespan prometheus.Histogram chunkLifespan prometheus.Histogram
flushedChunksStats *usagestats.Counter flushedChunksStats *analytics.Counter
flushedChunksBytesStats *usagestats.Statistics flushedChunksBytesStats *analytics.Statistics
flushedChunksLinesStats *usagestats.Statistics flushedChunksLinesStats *analytics.Statistics
flushedChunksAgeStats *usagestats.Statistics flushedChunksAgeStats *analytics.Statistics
flushedChunksLifespanStats *usagestats.Statistics flushedChunksLifespanStats *analytics.Statistics
flushedChunksUtilizationStats *usagestats.Statistics flushedChunksUtilizationStats *analytics.Statistics
chunksCreatedTotal prometheus.Counter chunksCreatedTotal prometheus.Counter
samplesPerChunk prometheus.Histogram samplesPerChunk prometheus.Histogram
blocksPerChunk prometheus.Histogram blocksPerChunk prometheus.Histogram
chunkCreatedStats *usagestats.Counter chunkCreatedStats *analytics.Counter
// Shutdown marker for ingester scale down // Shutdown marker for ingester scale down
shutdownMarker prometheus.Gauge shutdownMarker prometheus.Gauge
@ -241,12 +241,12 @@ func newIngesterMetrics(r prometheus.Registerer) *ingesterMetrics {
// 1h -> 8hr // 1h -> 8hr
Buckets: prometheus.LinearBuckets(1, 1, 8), Buckets: prometheus.LinearBuckets(1, 1, 8),
}), }),
flushedChunksStats: usagestats.NewCounter("ingester_flushed_chunks"), flushedChunksStats: analytics.NewCounter("ingester_flushed_chunks"),
flushedChunksBytesStats: usagestats.NewStatistics("ingester_flushed_chunks_bytes"), flushedChunksBytesStats: analytics.NewStatistics("ingester_flushed_chunks_bytes"),
flushedChunksLinesStats: usagestats.NewStatistics("ingester_flushed_chunks_lines"), flushedChunksLinesStats: analytics.NewStatistics("ingester_flushed_chunks_lines"),
flushedChunksAgeStats: usagestats.NewStatistics("ingester_flushed_chunks_age_seconds"), flushedChunksAgeStats: analytics.NewStatistics("ingester_flushed_chunks_age_seconds"),
flushedChunksLifespanStats: usagestats.NewStatistics("ingester_flushed_chunks_lifespan_seconds"), flushedChunksLifespanStats: analytics.NewStatistics("ingester_flushed_chunks_lifespan_seconds"),
flushedChunksUtilizationStats: usagestats.NewStatistics("ingester_flushed_chunks_utilization"), flushedChunksUtilizationStats: analytics.NewStatistics("ingester_flushed_chunks_utilization"),
chunksCreatedTotal: promauto.With(r).NewCounter(prometheus.CounterOpts{ chunksCreatedTotal: promauto.With(r).NewCounter(prometheus.CounterOpts{
Namespace: "loki", Namespace: "loki",
Name: "ingester_chunks_created_total", Name: "ingester_chunks_created_total",
@ -269,7 +269,7 @@ func newIngesterMetrics(r prometheus.Registerer) *ingesterMetrics {
Buckets: prometheus.ExponentialBuckets(5, 2, 6), Buckets: prometheus.ExponentialBuckets(5, 2, 6),
}), }),
chunkCreatedStats: usagestats.NewCounter("ingester_chunk_created"), chunkCreatedStats: analytics.NewCounter("ingester_chunk_created"),
shutdownMarker: promauto.With(r).NewGauge(prometheus.GaugeOpts{ shutdownMarker: promauto.With(r).NewGauge(prometheus.GaugeOpts{
Namespace: "loki", Namespace: "loki",

@ -17,10 +17,10 @@ import (
"github.com/prometheus/client_golang/prometheus/promauto" "github.com/prometheus/client_golang/prometheus/promauto"
"github.com/prometheus/prometheus/model/labels" "github.com/prometheus/prometheus/model/labels"
"github.com/grafana/loki/pkg/analytics"
"github.com/grafana/loki/pkg/loghttp" "github.com/grafana/loki/pkg/loghttp"
"github.com/grafana/loki/pkg/logproto" "github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql/syntax" "github.com/grafana/loki/pkg/logql/syntax"
"github.com/grafana/loki/pkg/usagestats"
"github.com/grafana/loki/pkg/util" "github.com/grafana/loki/pkg/util"
loki_util "github.com/grafana/loki/pkg/util" loki_util "github.com/grafana/loki/pkg/util"
"github.com/grafana/loki/pkg/util/unmarshal" "github.com/grafana/loki/pkg/util/unmarshal"
@ -41,8 +41,8 @@ var (
Help: "The total number of lines received per tenant", Help: "The total number of lines received per tenant",
}, []string{"tenant"}) }, []string{"tenant"})
bytesReceivedStats = usagestats.NewCounter("distributor_bytes_received") bytesReceivedStats = analytics.NewCounter("distributor_bytes_received")
linesReceivedStats = usagestats.NewCounter("distributor_lines_received") linesReceivedStats = analytics.NewCounter("distributor_lines_received")
) )
const applicationJSON = "application/json" const applicationJSON = "application/json"

@ -13,10 +13,10 @@ import (
"github.com/prometheus/client_golang/prometheus/promauto" "github.com/prometheus/client_golang/prometheus/promauto"
promql_parser "github.com/prometheus/prometheus/promql/parser" promql_parser "github.com/prometheus/prometheus/promql/parser"
"github.com/grafana/loki/pkg/analytics"
"github.com/grafana/loki/pkg/logql/syntax" "github.com/grafana/loki/pkg/logql/syntax"
"github.com/grafana/loki/pkg/logqlmodel" "github.com/grafana/loki/pkg/logqlmodel"
logql_stats "github.com/grafana/loki/pkg/logqlmodel/stats" logql_stats "github.com/grafana/loki/pkg/logqlmodel/stats"
"github.com/grafana/loki/pkg/usagestats"
"github.com/grafana/loki/pkg/util/httpreq" "github.com/grafana/loki/pkg/util/httpreq"
util_log "github.com/grafana/loki/pkg/util/log" util_log "github.com/grafana/loki/pkg/util/log"
) )
@ -72,10 +72,10 @@ var (
Help: "Total count of lines sent from ingesters while executing LogQL queries.", Help: "Total count of lines sent from ingesters while executing LogQL queries.",
}) })
bytePerSecondMetricUsage = usagestats.NewStatistics("query_metric_bytes_per_second") bytePerSecondMetricUsage = analytics.NewStatistics("query_metric_bytes_per_second")
bytePerSecondLogUsage = usagestats.NewStatistics("query_log_bytes_per_second") bytePerSecondLogUsage = analytics.NewStatistics("query_log_bytes_per_second")
linePerSecondMetricUsage = usagestats.NewStatistics("query_metric_lines_per_second") linePerSecondMetricUsage = analytics.NewStatistics("query_metric_lines_per_second")
linePerSecondLogUsage = usagestats.NewStatistics("query_log_lines_per_second") linePerSecondLogUsage = analytics.NewStatistics("query_log_lines_per_second")
) )
func RecordRangeAndInstantQueryMetrics( func RecordRangeAndInstantQueryMetrics(

@ -29,6 +29,7 @@ import (
"github.com/weaveworks/common/signals" "github.com/weaveworks/common/signals"
"google.golang.org/grpc/health/grpc_health_v1" "google.golang.org/grpc/health/grpc_health_v1"
"github.com/grafana/loki/pkg/analytics"
"github.com/grafana/loki/pkg/distributor" "github.com/grafana/loki/pkg/distributor"
"github.com/grafana/loki/pkg/ingester" "github.com/grafana/loki/pkg/ingester"
ingester_client "github.com/grafana/loki/pkg/ingester/client" ingester_client "github.com/grafana/loki/pkg/ingester/client"
@ -54,7 +55,6 @@ import (
"github.com/grafana/loki/pkg/storage/stores/series/index" "github.com/grafana/loki/pkg/storage/stores/series/index"
"github.com/grafana/loki/pkg/storage/stores/shipper/indexgateway" "github.com/grafana/loki/pkg/storage/stores/shipper/indexgateway"
"github.com/grafana/loki/pkg/tracing" "github.com/grafana/loki/pkg/tracing"
"github.com/grafana/loki/pkg/usagestats"
"github.com/grafana/loki/pkg/util" "github.com/grafana/loki/pkg/util"
"github.com/grafana/loki/pkg/util/fakeauth" "github.com/grafana/loki/pkg/util/fakeauth"
"github.com/grafana/loki/pkg/util/limiter" "github.com/grafana/loki/pkg/util/limiter"
@ -99,7 +99,7 @@ type Config struct {
RuntimeConfig runtimeconfig.Config `yaml:"runtime_config,omitempty"` RuntimeConfig runtimeconfig.Config `yaml:"runtime_config,omitempty"`
Tracing tracing.Config `yaml:"tracing"` Tracing tracing.Config `yaml:"tracing"`
UsageReport usagestats.Config `yaml:"analytics"` Analytics analytics.Config `yaml:"analytics"`
LegacyReadTarget bool `yaml:"legacy_read_target,omitempty" doc:"hidden"` LegacyReadTarget bool `yaml:"legacy_read_target,omitempty" doc:"hidden"`
@ -165,7 +165,7 @@ func (c *Config) RegisterFlags(f *flag.FlagSet) {
c.Tracing.RegisterFlags(f) c.Tracing.RegisterFlags(f)
c.CompactorConfig.RegisterFlags(f) c.CompactorConfig.RegisterFlags(f)
c.QueryScheduler.RegisterFlags(f) c.QueryScheduler.RegisterFlags(f)
c.UsageReport.RegisterFlags(f) c.Analytics.RegisterFlags(f)
} }
func (c *Config) registerServerFlagsWithChangedDefaultValues(fs *flag.FlagSet) { func (c *Config) registerServerFlagsWithChangedDefaultValues(fs *flag.FlagSet) {
@ -365,7 +365,7 @@ type Loki struct {
compactor *compactor.Compactor compactor *compactor.Compactor
QueryFrontEndTripperware basetripper.Tripperware QueryFrontEndTripperware basetripper.Tripperware
queryScheduler *scheduler.Scheduler queryScheduler *scheduler.Scheduler
usageReport *usagestats.Reporter usageReport *analytics.Reporter
indexGatewayRingManager *indexgateway.RingManager indexGatewayRingManager *indexgateway.RingManager
clientMetrics storage.ClientMetrics clientMetrics storage.ClientMetrics
@ -381,7 +381,7 @@ func New(cfg Config) (*Loki, error) {
clientMetrics: storage.NewClientMetrics(), clientMetrics: storage.NewClientMetrics(),
deleteClientMetrics: deletion.NewDeleteRequestClientMetrics(prometheus.DefaultRegisterer), deleteClientMetrics: deletion.NewDeleteRequestClientMetrics(prometheus.DefaultRegisterer),
} }
usagestats.Edition("oss") analytics.Edition("oss")
loki.setupAuthMiddleware() loki.setupAuthMiddleware()
loki.setupGRPCRecoveryMiddleware() loki.setupGRPCRecoveryMiddleware()
if err := loki.setupModuleManager(); err != nil { if err := loki.setupModuleManager(); err != nil {
@ -632,7 +632,7 @@ func (t *Loki) setupModuleManager() error {
mm.RegisterModule(IndexGateway, t.initIndexGateway) mm.RegisterModule(IndexGateway, t.initIndexGateway)
mm.RegisterModule(QueryScheduler, t.initQueryScheduler) mm.RegisterModule(QueryScheduler, t.initQueryScheduler)
mm.RegisterModule(IndexGatewayRing, t.initIndexGatewayRing, modules.UserInvisibleModule) mm.RegisterModule(IndexGatewayRing, t.initIndexGatewayRing, modules.UserInvisibleModule)
mm.RegisterModule(UsageReport, t.initUsageReport) mm.RegisterModule(Analytics, t.initAnalytics)
mm.RegisterModule(CacheGenerationLoader, t.initCacheGenerationLoader) mm.RegisterModule(CacheGenerationLoader, t.initCacheGenerationLoader)
mm.RegisterModule(All, nil) mm.RegisterModule(All, nil)
@ -643,22 +643,22 @@ func (t *Loki) setupModuleManager() error {
// Add dependencies // Add dependencies
deps := map[string][]string{ deps := map[string][]string{
Ring: {RuntimeConfig, Server, MemberlistKV}, Ring: {RuntimeConfig, Server, MemberlistKV},
UsageReport: {}, Analytics: {},
Overrides: {RuntimeConfig}, Overrides: {RuntimeConfig},
OverridesExporter: {Overrides, Server}, OverridesExporter: {Overrides, Server},
TenantConfigs: {RuntimeConfig}, TenantConfigs: {RuntimeConfig},
Distributor: {Ring, Server, Overrides, TenantConfigs, UsageReport}, Distributor: {Ring, Server, Overrides, TenantConfigs, Analytics},
Store: {Overrides, IndexGatewayRing}, Store: {Overrides, IndexGatewayRing},
Ingester: {Store, Server, MemberlistKV, TenantConfigs, UsageReport}, Ingester: {Store, Server, MemberlistKV, TenantConfigs, Analytics},
Querier: {Store, Ring, Server, IngesterQuerier, Overrides, UsageReport, CacheGenerationLoader}, Querier: {Store, Ring, Server, IngesterQuerier, Overrides, Analytics, CacheGenerationLoader},
QueryFrontendTripperware: {Server, Overrides, TenantConfigs}, QueryFrontendTripperware: {Server, Overrides, TenantConfigs},
QueryFrontend: {QueryFrontendTripperware, UsageReport, CacheGenerationLoader}, QueryFrontend: {QueryFrontendTripperware, Analytics, CacheGenerationLoader},
QueryScheduler: {Server, Overrides, MemberlistKV, UsageReport}, QueryScheduler: {Server, Overrides, MemberlistKV, Analytics},
Ruler: {Ring, Server, RulerStorage, RuleEvaluator, Overrides, TenantConfigs, UsageReport}, Ruler: {Ring, Server, RulerStorage, RuleEvaluator, Overrides, TenantConfigs, Analytics},
RuleEvaluator: {Ring, Server, Store, IngesterQuerier, Overrides, TenantConfigs, UsageReport}, RuleEvaluator: {Ring, Server, Store, IngesterQuerier, Overrides, TenantConfigs, Analytics},
TableManager: {Server, UsageReport}, TableManager: {Server, Analytics},
Compactor: {Server, Overrides, MemberlistKV, UsageReport}, Compactor: {Server, Overrides, MemberlistKV, Analytics},
IndexGateway: {Server, Store, Overrides, UsageReport, MemberlistKV, IndexGatewayRing}, IndexGateway: {Server, Store, Overrides, Analytics, MemberlistKV, IndexGatewayRing},
IngesterQuerier: {Ring}, IngesterQuerier: {Ring},
IndexGatewayRing: {RuntimeConfig, Server, MemberlistKV}, IndexGatewayRing: {RuntimeConfig, Server, MemberlistKV},
All: {QueryScheduler, QueryFrontend, Querier, Ingester, Distributor, Ruler, Compactor}, All: {QueryScheduler, QueryFrontend, Querier, Ingester, Distributor, Ruler, Compactor},
@ -753,7 +753,7 @@ func (t *Loki) setupModuleManager() error {
t.ModuleManager = mm t.ModuleManager = mm
if t.isModuleActive(Ingester) { if t.isModuleActive(Ingester) {
if err := mm.AddDependency(UsageReport, Ring); err != nil { if err := mm.AddDependency(Analytics, Ring); err != nil {
return err return err
} }
} }

@ -33,6 +33,7 @@ import (
"github.com/weaveworks/common/server" "github.com/weaveworks/common/server"
"github.com/weaveworks/common/user" "github.com/weaveworks/common/user"
"github.com/grafana/loki/pkg/analytics"
"github.com/grafana/loki/pkg/distributor" "github.com/grafana/loki/pkg/distributor"
"github.com/grafana/loki/pkg/ingester" "github.com/grafana/loki/pkg/ingester"
"github.com/grafana/loki/pkg/logproto" "github.com/grafana/loki/pkg/logproto"
@ -65,7 +66,6 @@ import (
boltdb_shipper_compactor "github.com/grafana/loki/pkg/storage/stores/shipper/index/compactor" boltdb_shipper_compactor "github.com/grafana/loki/pkg/storage/stores/shipper/index/compactor"
"github.com/grafana/loki/pkg/storage/stores/shipper/indexgateway" "github.com/grafana/loki/pkg/storage/stores/shipper/indexgateway"
"github.com/grafana/loki/pkg/storage/stores/tsdb" "github.com/grafana/loki/pkg/storage/stores/tsdb"
"github.com/grafana/loki/pkg/usagestats"
"github.com/grafana/loki/pkg/util/httpreq" "github.com/grafana/loki/pkg/util/httpreq"
"github.com/grafana/loki/pkg/util/limiter" "github.com/grafana/loki/pkg/util/limiter"
util_log "github.com/grafana/loki/pkg/util/log" util_log "github.com/grafana/loki/pkg/util/log"
@ -109,7 +109,7 @@ const (
Read string = "read" Read string = "read"
Write string = "write" Write string = "write"
Backend string = "backend" Backend string = "backend"
UsageReport string = "usage-report" Analytics string = "analytics"
) )
func (t *Loki) initServer() (services.Service, error) { func (t *Loki) initServer() (services.Service, error) {
@ -1042,7 +1042,7 @@ func (t *Loki) initMemberlistKV() (services.Service, error) {
t.Cfg.MemberlistKV.MetricsRegisterer = reg t.Cfg.MemberlistKV.MetricsRegisterer = reg
t.Cfg.MemberlistKV.Codecs = []codec.Codec{ t.Cfg.MemberlistKV.Codecs = []codec.Codec{
ring.GetCodec(), ring.GetCodec(),
usagestats.JSONCodec, analytics.JSONCodec,
} }
dnsProviderReg := prometheus.WrapRegistererWithPrefix( dnsProviderReg := prometheus.WrapRegistererWithPrefix(
@ -1266,16 +1266,16 @@ func (t *Loki) initQueryLimitsTripperware() (services.Service, error) {
return nil, nil return nil, nil
} }
func (t *Loki) initUsageReport() (services.Service, error) { func (t *Loki) initAnalytics() (services.Service, error) {
if !t.Cfg.UsageReport.Enabled { if !t.Cfg.Analytics.Enabled {
return nil, nil return nil, nil
} }
t.Cfg.UsageReport.Leader = false t.Cfg.Analytics.Leader = false
if t.isModuleActive(Ingester) { if t.isModuleActive(Ingester) {
t.Cfg.UsageReport.Leader = true t.Cfg.Analytics.Leader = true
} }
usagestats.Target(t.Cfg.Target.String()) analytics.Target(t.Cfg.Target.String())
period, err := t.Cfg.SchemaConfig.SchemaForTime(model.Now()) period, err := t.Cfg.SchemaConfig.SchemaForTime(model.Now())
if err != nil { if err != nil {
return nil, err return nil, err
@ -1286,7 +1286,7 @@ func (t *Loki) initUsageReport() (services.Service, error) {
level.Info(util_log.Logger).Log("msg", "failed to initialize usage report", "err", err) level.Info(util_log.Logger).Log("msg", "failed to initialize usage report", "err", err)
return nil, nil return nil, nil
} }
ur, err := usagestats.NewReporter(t.Cfg.UsageReport, t.Cfg.Ingester.LifecyclerConfig.RingConfig.KVStore, objectClient, util_log.Logger, prometheus.DefaultRegisterer) ur, err := analytics.NewReporter(t.Cfg.Analytics, t.Cfg.Ingester.LifecyclerConfig.RingConfig.KVStore, objectClient, util_log.Logger, prometheus.DefaultRegisterer)
if err != nil { if err != nil {
level.Info(util_log.Logger).Log("msg", "failed to initialize usage report", "err", err) level.Info(util_log.Logger).Log("msg", "failed to initialize usage report", "err", err)
return nil, nil return nil, nil

@ -14,6 +14,7 @@ import (
"github.com/grafana/dskit/tenant" "github.com/grafana/dskit/tenant"
"github.com/grafana/loki/pkg/analytics"
"github.com/grafana/loki/pkg/iter" "github.com/grafana/loki/pkg/iter"
"github.com/grafana/loki/pkg/logproto" "github.com/grafana/loki/pkg/logproto"
"github.com/grafana/loki/pkg/logql" "github.com/grafana/loki/pkg/logql"
@ -32,15 +33,14 @@ import (
series_index "github.com/grafana/loki/pkg/storage/stores/series/index" series_index "github.com/grafana/loki/pkg/storage/stores/series/index"
"github.com/grafana/loki/pkg/storage/stores/shipper/indexgateway" "github.com/grafana/loki/pkg/storage/stores/shipper/indexgateway"
"github.com/grafana/loki/pkg/storage/stores/tsdb" "github.com/grafana/loki/pkg/storage/stores/tsdb"
"github.com/grafana/loki/pkg/usagestats"
"github.com/grafana/loki/pkg/util" "github.com/grafana/loki/pkg/util"
"github.com/grafana/loki/pkg/util/deletion" "github.com/grafana/loki/pkg/util/deletion"
) )
var ( var (
indexTypeStats = usagestats.NewString("store_index_type") indexTypeStats = analytics.NewString("store_index_type")
objectTypeStats = usagestats.NewString("store_object_type") objectTypeStats = analytics.NewString("store_object_type")
schemaStats = usagestats.NewString("store_schema") schemaStats = analytics.NewString("store_schema")
errWritingChunkUnsupported = errors.New("writing chunks is not supported while running store in read-only mode") errWritingChunkUnsupported = errors.New("writing chunks is not supported while running store in read-only mode")
) )

@ -20,6 +20,7 @@ import (
"github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model" "github.com/prometheus/common/model"
"github.com/grafana/loki/pkg/analytics"
"github.com/grafana/loki/pkg/storage/chunk/client" "github.com/grafana/loki/pkg/storage/chunk/client"
"github.com/grafana/loki/pkg/storage/chunk/client/local" "github.com/grafana/loki/pkg/storage/chunk/client/local"
chunk_util "github.com/grafana/loki/pkg/storage/chunk/client/util" chunk_util "github.com/grafana/loki/pkg/storage/chunk/client/util"
@ -27,7 +28,6 @@ import (
"github.com/grafana/loki/pkg/storage/stores/indexshipper/compactor/deletion" "github.com/grafana/loki/pkg/storage/stores/indexshipper/compactor/deletion"
"github.com/grafana/loki/pkg/storage/stores/indexshipper/compactor/retention" "github.com/grafana/loki/pkg/storage/stores/indexshipper/compactor/retention"
shipper_storage "github.com/grafana/loki/pkg/storage/stores/indexshipper/storage" shipper_storage "github.com/grafana/loki/pkg/storage/stores/indexshipper/storage"
"github.com/grafana/loki/pkg/usagestats"
"github.com/grafana/loki/pkg/util" "github.com/grafana/loki/pkg/util"
"github.com/grafana/loki/pkg/util/filter" "github.com/grafana/loki/pkg/util/filter"
util_log "github.com/grafana/loki/pkg/util/log" util_log "github.com/grafana/loki/pkg/util/log"
@ -66,8 +66,8 @@ const (
) )
var ( var (
retentionEnabledStats = usagestats.NewString("compactor_retention_enabled") retentionEnabledStats = analytics.NewString("compactor_retention_enabled")
defaultRetentionStats = usagestats.NewString("compactor_default_retention") defaultRetentionStats = analytics.NewString("compactor_default_retention")
) )
type Config struct { type Config struct {

@ -12,6 +12,7 @@ import (
"github.com/grafana/dskit/runtimeconfig" "github.com/grafana/dskit/runtimeconfig"
"github.com/weaveworks/common/server" "github.com/weaveworks/common/server"
"github.com/grafana/loki/pkg/analytics"
"github.com/grafana/loki/pkg/distributor" "github.com/grafana/loki/pkg/distributor"
"github.com/grafana/loki/pkg/ingester" "github.com/grafana/loki/pkg/ingester"
ingester_client "github.com/grafana/loki/pkg/ingester/client" ingester_client "github.com/grafana/loki/pkg/ingester/client"
@ -37,7 +38,6 @@ import (
"github.com/grafana/loki/pkg/storage/stores/series/index" "github.com/grafana/loki/pkg/storage/stores/series/index"
"github.com/grafana/loki/pkg/storage/stores/shipper/indexgateway" "github.com/grafana/loki/pkg/storage/stores/shipper/indexgateway"
"github.com/grafana/loki/pkg/tracing" "github.com/grafana/loki/pkg/tracing"
"github.com/grafana/loki/pkg/usagestats"
"github.com/grafana/loki/pkg/validation" "github.com/grafana/loki/pkg/validation"
) )
@ -144,8 +144,8 @@ var (
}, },
{ {
Name: "analytics", Name: "analytics",
StructType: reflect.TypeOf(usagestats.Config{}), StructType: reflect.TypeOf(analytics.Config{}),
Desc: "Configuration for usage report.", Desc: "Configuration for analytics.",
}, },
{ {

Loading…
Cancel
Save