diff --git a/docs/sources/configure/_index.md b/docs/sources/configure/_index.md index 0f9661192f873..ba9e5c723515c 100644 --- a/docs/sources/configure/_index.md +++ b/docs/sources/configure/_index.md @@ -3020,7 +3020,7 @@ The `limits_config` block configures global and per-tenant limits in Loki. The v # would be added to Structured Metadata with name 'level' and one of the values # from 'debug', 'info', 'warn', 'error', 'critical', 'fatal'. # CLI flag: -validation.discover-log-levels -[discover_log_levels: | default = false] +[discover_log_levels: | default = true] # Maximum number of active streams per user, per ingester. 0 to disable. # CLI flag: -ingester.max-streams-per-user diff --git a/integration/cluster/cluster.go b/integration/cluster/cluster.go index 446f84cfbb130..694119ca4fe21 100644 --- a/integration/cluster/cluster.go +++ b/integration/cluster/cluster.go @@ -33,8 +33,7 @@ import ( "github.com/grafana/loki/v3/pkg/validation" ) -var ( - configTemplate = template.Must(template.New("").Parse(` +var configTemplate = template.Must(template.New("").Parse(` auth_enabled: true server: @@ -63,6 +62,7 @@ limits_config: reject_old_samples: false allow_structured_metadata: true discover_service_name: + discover_log_levels: false otlp_config: resource_attributes: attributes_config: @@ -120,7 +120,6 @@ ruler: directory: {{.sharedDataPath}}/rules rule_path: {{.sharedDataPath}}/prom-rule `)) -) func resetMetricRegistry() { registry := &wrappedRegisterer{Registry: prometheus.NewRegistry()} @@ -174,7 +173,7 @@ func New(logLevel level.Value, opts ...func(*Cluster)) *Cluster { overridesFile := filepath.Join(sharedPath, "loki-overrides.yaml") - err = os.WriteFile(overridesFile, []byte(`overrides:`), 0777) + err = os.WriteFile(overridesFile, []byte(`overrides:`), 0o777) if err != nil { panic(fmt.Errorf("error creating overrides file: %w", err)) } @@ -346,7 +345,7 @@ func (c *Component) writeConfig() error { return fmt.Errorf("error getting merged config: %w", err) } - if err := os.WriteFile(configFile.Name(), mergedConfig, 0644); err != nil { + if err := os.WriteFile(configFile.Name(), mergedConfig, 0o644); err != nil { return fmt.Errorf("error writing config file: %w", err) } @@ -413,7 +412,7 @@ func (c *Component) run() error { var config loki.ConfigWrapper - var flagset = flag.NewFlagSet("test-flags", flag.ExitOnError) + flagset := flag.NewFlagSet("test-flags", flag.ExitOnError) if err := cfg.DynamicUnmarshal(&config, append( c.flags, @@ -522,7 +521,7 @@ func (c *Component) SetTenantLimits(tenant string, limits validation.Limits) err return err } - return os.WriteFile(c.overridesFile, config, 0777) + return os.WriteFile(c.overridesFile, config, 0o777) } func (c *Component) GetTenantLimits(tenant string) validation.Limits { diff --git a/pkg/distributor/distributor_test.go b/pkg/distributor/distributor_test.go index 7a3fe93fa880f..f68e5f3a701ab 100644 --- a/pkg/distributor/distributor_test.go +++ b/pkg/distributor/distributor_test.go @@ -142,16 +142,19 @@ func Test_IncrementTimestamp(t *testing.T) { flagext.DefaultValues(incrementingDisabled) incrementingDisabled.DiscoverServiceName = nil incrementingDisabled.RejectOldSamples = false + incrementingDisabled.DiscoverLogLevels = false incrementingEnabled := &validation.Limits{} flagext.DefaultValues(incrementingEnabled) incrementingEnabled.DiscoverServiceName = nil incrementingEnabled.RejectOldSamples = false incrementingEnabled.IncrementDuplicateTimestamp = true + incrementingEnabled.DiscoverLogLevels = false defaultLimits := &validation.Limits{} flagext.DefaultValues(defaultLimits) now := time.Now() + defaultLimits.DiscoverLogLevels = false tests := map[string]struct { limits *validation.Limits @@ -810,7 +813,6 @@ func BenchmarkShardStream(b *testing.B) { b.ResetTimer() for n := 0; n < b.N; n++ { d.shardStream(stream, 0, "fake") //nolint:errcheck - } }) diff --git a/pkg/validation/limits.go b/pkg/validation/limits.go index a304fcfd362f5..bb2a7c50f8442 100644 --- a/pkg/validation/limits.go +++ b/pkg/validation/limits.go @@ -255,7 +255,7 @@ func (l *Limits) RegisterFlags(f *flag.FlagSet) { "job", } f.Var((*dskit_flagext.StringSlice)(&l.DiscoverServiceName), "validation.discover-service-name", "If no service_name label exists, Loki maps a single label from the configured list to service_name. If none of the configured labels exist in the stream, label is set to unknown_service. Empty list disables setting the label.") - f.BoolVar(&l.DiscoverLogLevels, "validation.discover-log-levels", false, "Discover and add log levels during ingestion, if not present already. Levels would be added to Structured Metadata with name 'level' and one of the values from 'debug', 'info', 'warn', 'error', 'critical', 'fatal'.") + f.BoolVar(&l.DiscoverLogLevels, "validation.discover-log-levels", true, "Discover and add log levels during ingestion, if not present already. Levels would be added to Structured Metadata with name 'level' and one of the values from 'debug', 'info', 'warn', 'error', 'critical', 'fatal'.") _ = l.RejectOldSamplesMaxAge.Set("7d") f.Var(&l.RejectOldSamplesMaxAge, "validation.reject-old-samples.max-age", "Maximum accepted sample age before rejecting.")