@@ -1413,7 +1413,7 @@ func makeWriteRequestWithLabelsWithLevel(lines, size int, labels []string, level
1413
1413
1414
1414
for j := 0 ; j < lines ; j ++ {
1415
1415
// Construct the log line, honoring the input size
1416
- line := "msg=" + strconv .Itoa (j ) + strings .Repeat ("0" , size ) + " severity=" + level
1416
+ line := "msg=an error occured " + strconv .Itoa (j ) + strings .Repeat ("0" , size ) + " severity=" + level
1417
1417
1418
1418
stream .Entries = append (stream .Entries , logproto.Entry {
1419
1419
Timestamp : time .Now ().Add (time .Duration (j ) * time .Millisecond ),
@@ -1644,20 +1644,28 @@ func Test_DetectLogLevels(t *testing.T) {
1644
1644
})
1645
1645
1646
1646
t .Run ("log level detection enabled and warn logs" , func (t * testing.T ) {
1647
- limits , ingester := setup (true )
1648
- distributors , _ := prepare (t , 1 , 5 , limits , func (_ string ) (ring_client.PoolClient , error ) { return ingester , nil })
1647
+ for _ , level := range []string {"warn" , "Wrn" , "WARNING" } {
1648
+ limits , ingester := setup (true )
1649
+ distributors , _ := prepare (
1650
+ t ,
1651
+ 1 ,
1652
+ 5 ,
1653
+ limits ,
1654
+ func (_ string ) (ring_client.PoolClient , error ) { return ingester , nil },
1655
+ )
1649
1656
1650
- writeReq := makeWriteRequestWithLabelsWithLevel (1 , 10 , []string {`{foo="bar"}` }, "warn" )
1651
- _ , err := distributors [0 ].Push (ctx , writeReq )
1652
- require .NoError (t , err )
1653
- topVal := ingester .Peek ()
1654
- require .Equal (t , `{foo="bar"}` , topVal .Streams [0 ].Labels )
1655
- require .Equal (t , push.LabelsAdapter {
1656
- {
1657
- Name : constants .LevelLabel ,
1658
- Value : constants .LogLevelWarn ,
1659
- },
1660
- }, topVal .Streams [0 ].Entries [0 ].StructuredMetadata )
1657
+ writeReq := makeWriteRequestWithLabelsWithLevel (1 , 10 , []string {`{foo="bar"}` }, level )
1658
+ _ , err := distributors [0 ].Push (ctx , writeReq )
1659
+ require .NoError (t , err )
1660
+ topVal := ingester .Peek ()
1661
+ require .Equal (t , `{foo="bar"}` , topVal .Streams [0 ].Labels )
1662
+ require .Equal (t , push.LabelsAdapter {
1663
+ {
1664
+ Name : constants .LevelLabel ,
1665
+ Value : constants .LogLevelWarn ,
1666
+ },
1667
+ }, topVal .Streams [0 ].Entries [0 ].StructuredMetadata , fmt .Sprintf ("level: %s" , level ))
1668
+ }
1661
1669
})
1662
1670
1663
1671
t .Run ("log level detection enabled but log level already present in stream" , func (t * testing.T ) {
0 commit comments