Skip to content

Commit

Permalink
Fix docker json message.Bytes when partial docker logs are joined (#8177
Browse files Browse the repository at this point in the history
)
  • Loading branch information
wflyer authored and exekias committed Aug 31, 2018
1 parent 6da83e8 commit aefc948
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ https://github.com/elastic/beats/compare/v6.4.0...master[Check the HEAD diff]
- Fixed a memory leak when harvesters are closed. {pull}7820[7820]
- Fix date format in Mongodb Ingest pipeline. {pull}7974[7974]
- Mark the TCP and UDP input as GA. {pull}8125[8125]
- Fixed a docker input error due to the offset update bug in partial log join.{pull}8177[8177]

*Heartbeat*

Expand Down
1 change: 1 addition & 0 deletions filebeat/reader/readjson/docker_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ func (p *DockerJSONReader) Next() (reader.Message, error) {
return message, err
}
message.Content = append(message.Content, next.Content...)
message.Bytes += next.Bytes
}
} else {
message, err = parseCRILog(message, &crioLine)
Expand Down
7 changes: 7 additions & 0 deletions filebeat/reader/readjson/docker_json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ func TestDockerJSON(t *testing.T) {
Content: []byte("1:M 09 Nov 13:27:36.276 # User requested shutdown...\n"),
Fields: common.MapStr{"stream": "stdout"},
Ts: time.Date(2017, 11, 9, 13, 27, 36, 277747246, time.UTC),
Bytes: 122,
},
},
// Wrong JSON
Expand Down Expand Up @@ -77,6 +78,7 @@ func TestDockerJSON(t *testing.T) {
Content: []byte("2017-09-12 22:32:21.212 [INFO][88] table.go 710: Invalidating dataplane cache"),
Fields: common.MapStr{"stream": "stdout"},
Ts: time.Date(2017, 9, 12, 22, 32, 21, 212861448, time.UTC),
Bytes: 115,
},
},
// Filtering stream
Expand All @@ -91,6 +93,7 @@ func TestDockerJSON(t *testing.T) {
Content: []byte("unfiltered\n"),
Fields: common.MapStr{"stream": "stderr"},
Ts: time.Date(2017, 11, 9, 13, 27, 36, 277747246, time.UTC),
Bytes: 80,
},
},
// Filtering stream
Expand All @@ -105,6 +108,7 @@ func TestDockerJSON(t *testing.T) {
Content: []byte("2017-11-12 23:32:21.212 [ERROR][77] table.go 111: error"),
Fields: common.MapStr{"stream": "stderr"},
Ts: time.Date(2017, 11, 12, 23, 32, 21, 212771448, time.UTC),
Bytes: 93,
},
},
// Split lines
Expand All @@ -119,6 +123,7 @@ func TestDockerJSON(t *testing.T) {
Content: []byte("1:M 09 Nov 13:27:36.276 # User requested shutdown...\n"),
Fields: common.MapStr{"stream": "stdout"},
Ts: time.Date(2017, 11, 9, 13, 27, 36, 277747246, time.UTC),
Bytes: 190,
},
},
// Split lines with partial disabled
Expand All @@ -133,6 +138,7 @@ func TestDockerJSON(t *testing.T) {
Content: []byte("1:M 09 Nov 13:27:36.276 # User requested "),
Fields: common.MapStr{"stream": "stdout"},
Ts: time.Date(2017, 11, 9, 13, 27, 36, 277747246, time.UTC),
Bytes: 109,
},
},
}
Expand All @@ -159,5 +165,6 @@ func (m *mockReader) Next() (reader.Message, error) {
m.messages = m.messages[1:]
return reader.Message{
Content: message,
Bytes: len(message),
}, nil
}

0 comments on commit aefc948

Please sign in to comment.