Skip to content

Commit

Permalink
Adjust config structure according to feedback from code review
Browse files Browse the repository at this point in the history
Signed-off-by: Christian Haudum <[email protected]>
  • Loading branch information
chaudum committed Dec 18, 2024
1 parent 01d71ce commit 43ed574
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion docs/sources/shared/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -3391,7 +3391,8 @@ The `limits_config` block configures global and per-tenant limits in Loki. The v
# Experimental: Detect fields from stream labels, structured metadata, or
# json/logfmt formatted log line and put them into structured metadata of the
# log entry.
[discover_generic_fields: <map of string to list of strings>]
discover_generic_fields:
[fields: <map of string to list of strings>]

# 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,
Expand Down
8 changes: 6 additions & 2 deletions pkg/validation/limits.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ type Limits struct {
IncrementDuplicateTimestamp bool `yaml:"increment_duplicate_timestamp" json:"increment_duplicate_timestamp"`

// Metadata field extraction
DiscoverGenericFields map[string][]string `yaml:"discover_generic_fields" json:"discover_generic_fields" doc:"description=Experimental: Detect fields from stream labels, structured metadata, or json/logfmt formatted log line and put them into structured metadata of the log entry."`
DiscoverGenericFields FieldDetectorConfig `yaml:"discover_generic_fields" json:"discover_generic_fields" doc:"description=Experimental: Detect fields from stream labels, structured metadata, or json/logfmt formatted log line and put them into structured metadata of the log entry."`
DiscoverServiceName []string `yaml:"discover_service_name" json:"discover_service_name"`
DiscoverLogLevels bool `yaml:"discover_log_levels" json:"discover_log_levels"`
LogLevelFields []string `yaml:"log_level_fields" json:"log_level_fields"`
Expand Down Expand Up @@ -247,6 +247,10 @@ type Limits struct {
S3SSEKMSEncryptionContext string `yaml:"s3_sse_kms_encryption_context" json:"s3_sse_kms_encryption_context" doc:"nocli|description=S3 server-side encryption KMS encryption context. If unset and the key ID override is set, the encryption context will not be provided to S3. Ignored if the SSE type override is not set."`
}

type FieldDetectorConfig struct {
Fields map[string][]string `yaml:"fields" json:"fields"`
}

type StreamRetention struct {
Period model.Duration `yaml:"period" json:"period" doc:"description:Retention period applied to the log lines matching the selector."`
Priority int `yaml:"priority" json:"priority" doc:"description:The larger the value, the higher the priority."`
Expand Down Expand Up @@ -999,7 +1003,7 @@ func (o *Overrides) IncrementDuplicateTimestamps(userID string) bool {
}

func (o *Overrides) DiscoverGenericFields(userID string) map[string][]string {
return o.getOverridesForUser(userID).DiscoverGenericFields
return o.getOverridesForUser(userID).DiscoverGenericFields.Fields
}

func (o *Overrides) DiscoverServiceName(userID string) []string {
Expand Down

0 comments on commit 43ed574

Please sign in to comment.