diff --git a/cmd/loki/loki-local-config.yaml b/cmd/loki/loki-local-config.yaml index a3092d89ad04..24d7a8344a52 100644 --- a/cmd/loki/loki-local-config.yaml +++ b/cmd/loki/loki-local-config.yaml @@ -27,3 +27,6 @@ storage_config: filesystem: directory: /tmp/loki/chunks + +limits_config: + enforce_metric_name: false diff --git a/cmd/loki/main.go b/cmd/loki/main.go index 0769a3ec36de..da010c9b34f4 100644 --- a/cmd/loki/main.go +++ b/cmd/loki/main.go @@ -14,6 +14,7 @@ import ( "github.com/cortexproject/cortex/pkg/util" "github.com/cortexproject/cortex/pkg/util/flagext" + "github.com/cortexproject/cortex/pkg/util/validation" ) func init() { @@ -29,8 +30,14 @@ func main() { flagext.RegisterFlags(&cfg) flag.Parse() - // The flags set the EnforceMetricName to be true, but in loki it _should_ be false. - cfg.LimitsConfig.EnforceMetricName = false + // LimitsConfig has a customer UnmarshalYAML that will set the defaults to a global. + // This global is set to the config passed into the last call to `NewOverrides`. If we don't + // call it atleast once, the defaults are set to an empty struct. + // We call it with the flag values so that the config file unmarshalling only overrides the values set in the config. + if _, err := validation.NewOverrides(cfg.LimitsConfig); err != nil { + level.Error(util.Logger).Log("msg", "error loading limits", "err", err) + os.Exit(1) + } util.InitLogger(&cfg.Server) diff --git a/production/helm/loki/values.yaml b/production/helm/loki/values.yaml index a03ca21f51c2..560a374062f7 100644 --- a/production/helm/loki/values.yaml +++ b/production/helm/loki/values.yaml @@ -37,6 +37,8 @@ config: # prefix: "" # httpclienttimeout: "20s" # consistentreads: true + limits_config: + enforce_metric_name: false schema_config: configs: - from: 0 diff --git a/production/ksonnet/loki/config.libsonnet b/production/ksonnet/loki/config.libsonnet index f81b0e72d355..80eb6328009d 100644 --- a/production/ksonnet/loki/config.libsonnet +++ b/production/ksonnet/loki/config.libsonnet @@ -29,6 +29,10 @@ grpc_server_max_recv_msg_size: 1024 * 1024 * 64, }, + limits_config: { + enforce_metric_name: false, + }, + ingester: { chunk_idle_period: '15m',