Skip to content

Commit

Permalink
enable structure metadata by default. error if Loki tries to start wi…
Browse files Browse the repository at this point in the history
…th structured metadata enabled and a schema less than v13

Signed-off-by: Edward Welch <[email protected]>
  • Loading branch information
slim-bean committed Apr 3, 2024
1 parent d39dc09 commit 56b0f9a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions docs/sources/configure/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3265,7 +3265,7 @@ shard_streams:

# Allow user to send structured metadata in push payload.
# CLI flag: -validation.allow-structured-metadata
[allow_structured_metadata: <boolean> | default = false]
[allow_structured_metadata: <boolean> | default = true]

# Maximum size accepted for structured metadata per log line.
# CLI flag: -limits.max-structured-metadata-size
Expand Down Expand Up @@ -4792,7 +4792,7 @@ The `period_config` block configures what index schemas should be used for from
# gcp-columnkey, bigtable, bigtable-hashed, cassandra, grpc.
[object_store: <string> | default = ""]
# The schema version to use, current recommended schema is v12.
# The schema version to use, current recommended schema is v13.
[schema: <string> | default = ""]
# Configures how the index is updated and stored.
Expand Down
10 changes: 10 additions & 0 deletions pkg/loki/loki.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,16 @@ func (c *Config) Validate() error {
}
}

// Schema version 13 is required to use structured metadata
p := config.ActivePeriodConfig(c.SchemaConfig.Configs)
version, err := c.SchemaConfig.Configs[p].VersionAsInt()
if err != nil {
return err
}
if c.LimitsConfig.AllowStructuredMetadata && version < 13 {
return fmt.Errorf("schema v13 is required to store Structured Metadata and use native OTLP ingestion, your schema version is %s. set `allow_structured_metadata: false` in the `limits_config` section or set the command line argument `-validation.allow-structured-metadata=false` and restart Loki. Then proceed to update to schema v13 or newer before re-enabling this config, search for 'Storage Schema' in the docs for the schema update procedure", c.SchemaConfig.Configs[p].Schema)
}

return nil
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/config/schema_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ type PeriodConfig struct {
IndexType string `yaml:"store" doc:"description=store and object_store below affect which <storage_config> key is used. Which index to use. Either tsdb or boltdb-shipper. Following stores are deprecated: aws, aws-dynamo, gcp, gcp-columnkey, bigtable, bigtable-hashed, cassandra, grpc."`
// type of object client to use.
ObjectType string `yaml:"object_store" doc:"description=Which store to use for the chunks. Either aws (alias s3), azure, gcs, alibabacloud, bos, cos, swift, filesystem, or a named_store (refer to named_stores_config). Following stores are deprecated: aws-dynamo, gcp, gcp-columnkey, bigtable, bigtable-hashed, cassandra, grpc."`
Schema string `yaml:"schema" doc:"description=The schema version to use, current recommended schema is v12."`
Schema string `yaml:"schema" doc:"description=The schema version to use, current recommended schema is v13."`
IndexTables IndexPeriodicTableConfig `yaml:"index" doc:"description=Configures how the index is updated and stored."`
ChunkTables PeriodicTableConfig `yaml:"chunks" doc:"description=Configured how the chunks are updated and stored."`
RowShards uint32 `yaml:"row_shards" doc:"default=16|description=How many shards will be created. Only used if schema is v10 or greater."`
Expand Down
2 changes: 1 addition & 1 deletion pkg/validation/limits.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ func (l *Limits) RegisterFlags(f *flag.FlagSet) {

f.IntVar(&l.VolumeMaxSeries, "limits.volume-max-series", 1000, "The default number of aggregated series or labels that can be returned from a log-volume endpoint")

f.BoolVar(&l.AllowStructuredMetadata, "validation.allow-structured-metadata", false, "Allow user to send structured metadata (non-indexed labels) in push payload.")
f.BoolVar(&l.AllowStructuredMetadata, "validation.allow-structured-metadata", true, "Allow user to send structured metadata (non-indexed labels) in push payload.")
_ = l.MaxStructuredMetadataSize.Set(defaultMaxStructuredMetadataSize)
f.Var(&l.MaxStructuredMetadataSize, "limits.max-structured-metadata-size", "Maximum size accepted for structured metadata per entry. Default: 64 kb. Any log line exceeding this limit will be discarded. There is no limit when unset or set to 0.")
f.IntVar(&l.MaxStructuredMetadataEntriesCount, "limits.max-structured-metadata-entries-count", defaultMaxStructuredMetadataCount, "Maximum number of structured metadata entries per log line. Default: 128. Any log line exceeding this limit will be discarded. There is no limit when unset or set to 0.")
Expand Down

0 comments on commit 56b0f9a

Please sign in to comment.