Skip to content

Commit 41c6b6c

Browse files
fix: always write detected_level when enabled, even if unknown (#14464)
Co-authored-by: shantanualshi <shantanu.alshi@grafana.com>
1 parent e2a209c commit 41c6b6c

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

‎pkg/distributor/distributor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,7 @@ func (d *Distributor) Push(ctx context.Context, req *logproto.PushRequest) (*log
502502
} else {
503503
logLevel = detectLogLevelFromLogEntry(entry, structuredMetadata)
504504
}
505-
if logLevel != constants.LogLevelUnknown && logLevel != "" {
505+
if logLevel != "" {
506506
entry.StructuredMetadata = append(entry.StructuredMetadata, logproto.LabelAdapter{
507507
Name: constants.LevelLabel,
508508
Value: logLevel,

‎pkg/distributor/distributor_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1640,7 +1640,7 @@ func Test_DetectLogLevels(t *testing.T) {
16401640
require.NoError(t, err)
16411641
topVal := ingester.Peek()
16421642
require.Equal(t, `{foo="bar"}`, topVal.Streams[0].Labels)
1643-
require.Len(t, topVal.Streams[0].Entries[0].StructuredMetadata, 0)
1643+
require.Len(t, topVal.Streams[0].Entries[0].StructuredMetadata, 1)
16441644
})
16451645

16461646
t.Run("log level detection enabled and warn logs", func(t *testing.T) {

0 commit comments

Comments
 (0)