diff --git a/pkg/distributor/distributor.go b/pkg/distributor/distributor.go index 30383bfcbbbd..f5a57d0b9dde 100644 --- a/pkg/distributor/distributor.go +++ b/pkg/distributor/distributor.go @@ -501,7 +501,7 @@ func (d *Distributor) Push(ctx context.Context, req *logproto.PushRequest) (*log } else { logLevel = detectLogLevelFromLogEntry(entry, structuredMetadata) } - if logLevel != constants.LogLevelUnknown && logLevel != "" { + if logLevel != "" { entry.StructuredMetadata = append(entry.StructuredMetadata, logproto.LabelAdapter{ Name: constants.LevelLabel, Value: logLevel, diff --git a/pkg/distributor/distributor_test.go b/pkg/distributor/distributor_test.go index 785d6ce03d0c..ea06eecd4515 100644 --- a/pkg/distributor/distributor_test.go +++ b/pkg/distributor/distributor_test.go @@ -1640,7 +1640,7 @@ func Test_DetectLogLevels(t *testing.T) { require.NoError(t, err) topVal := ingester.Peek() require.Equal(t, `{foo="bar"}`, topVal.Streams[0].Labels) - require.Len(t, topVal.Streams[0].Entries[0].StructuredMetadata, 0) + require.Len(t, topVal.Streams[0].Entries[0].StructuredMetadata, 1) }) t.Run("log level detection enabled and warn logs", func(t *testing.T) {