Skip to content

Commit

Permalink
Update filestream reader offset when line is skipped (elastic#23417)
Browse files Browse the repository at this point in the history
## What does this PR do?

This PR adds two previously missing offset updates to the `filestream` reader when a line is skipped.

## Why is it important?

The offset could be incorrect if Filebeat skips the line if the line should not be published because of user configuration in `export_line` or `import_line`

If the offset is not updated in the reader, the state information of newer published events become incorrect. This might lead to duplicated events if Filebeat is restarted.
  • Loading branch information
kvch authored Jan 21, 2021
1 parent 7bdbf28 commit e5cd64f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.next.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ https://github.com/elastic/beats/compare/v7.0.0-alpha2...master[Check the HEAD d
- Fix CredentialsJSON unpacking for `gcp-pubsub` and `httpjson` inputs. {pull}23277[23277]
- Change the `event.created` in Netflow events to be the time the event was created by Filebeat
to be consistent with ECS. {pull}23094[23094]
- Update `filestream` reader offset when a line is skipped. {pull}23417[23417]

*Filebeat*

Expand Down
4 changes: 2 additions & 2 deletions filebeat/input/filestream/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,13 +318,13 @@ func (inp *filestream) readFromSource(
return nil
}

s.Offset += int64(message.Bytes)

if message.IsEmpty() || inp.isDroppedLine(log, string(message.Content)) {
continue
}

event := inp.eventFromMessage(message, path)
s.Offset += int64(message.Bytes)

if err := p.Publish(event, s); err != nil {
return err
}
Expand Down

0 comments on commit e5cd64f

Please sign in to comment.