Skip to content

Commit

Permalink
Cherry-pick #8177 to 6.x: Fix docker json message.Bytes when partial …
Browse files Browse the repository at this point in the history
…docker logs are joined (#8179)

* Fix docker json message.Bytes when partial docker logs are joined (#8177)

(cherry picked from commit aefc948)
  • Loading branch information
exekias committed Sep 3, 2018
1 parent e01adba commit 3154262
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 @@ -48,6 +48,7 @@ https://github.com/elastic/beats/compare/v6.4.0...6.x[Check the HEAD diff]
*Filebeat*

- Fix date format in Mongodb Ingest pipeline. {pull}7974[7974]
- 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/docker_json/docker_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ func (p *Reader) 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/docker_json/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 3154262

Please sign in to comment.