diff --git a/pkg/validation/limits.go b/pkg/validation/limits.go index fa48c0b921f4e..ad84bbc0af72e 100644 --- a/pkg/validation/limits.go +++ b/pkg/validation/limits.go @@ -248,7 +248,7 @@ type Limits struct { } type FieldDetectorConfig struct { - Fields map[string][]string `yaml:"fields" json:"fields"` + Fields map[string][]string `yaml:"fields,omitempty" json:"fields,omitempty"` } type StreamRetention struct { diff --git a/pkg/validation/limits_test.go b/pkg/validation/limits_test.go index fffc653023ba9..bb955d8a87679 100644 --- a/pkg/validation/limits_test.go +++ b/pkg/validation/limits_test.go @@ -214,7 +214,7 @@ ruler_remote_write_headers: foo: "bar" `, exp: Limits{ - DiscoverGenericFields: map[string][]string{}, + DiscoverGenericFields: FieldDetectorConfig{}, RulerRemoteWriteHeaders: OverwriteMarshalingStringMap{map[string]string{"foo": "bar"}}, DiscoverServiceName: []string{}, LogLevelFields: []string{}, @@ -235,7 +235,7 @@ ruler_remote_write_headers: ruler_remote_write_headers: `, exp: Limits{ - DiscoverGenericFields: map[string][]string{}, + DiscoverGenericFields: FieldDetectorConfig{}, DiscoverServiceName: []string{}, LogLevelFields: []string{}, // Rest from new defaults @@ -256,7 +256,7 @@ retention_stream: selector: '{foo="bar"}' `, exp: Limits{ - DiscoverGenericFields: map[string][]string{}, + DiscoverGenericFields: FieldDetectorConfig{}, DiscoverServiceName: []string{}, LogLevelFields: []string{}, StreamRetention: []StreamRetention{ @@ -278,7 +278,7 @@ reject_old_samples: true `, exp: Limits{ RejectOldSamples: true, - DiscoverGenericFields: map[string][]string{}, + DiscoverGenericFields: FieldDetectorConfig{}, DiscoverServiceName: []string{}, LogLevelFields: []string{}, @@ -299,7 +299,7 @@ reject_old_samples: true query_timeout: 5m `, exp: Limits{ - DiscoverGenericFields: map[string][]string{}, + DiscoverGenericFields: FieldDetectorConfig{}, DiscoverServiceName: []string{}, LogLevelFields: []string{},