Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Filebeat] offset points to end of line #6514

Closed
andrewkroh opened this issue Mar 8, 2018 · 5 comments
Closed

[Filebeat] offset points to end of line #6514

andrewkroh opened this issue Mar 8, 2018 · 5 comments
Labels

Comments

@andrewkroh
Copy link
Member

andrewkroh commented Mar 8, 2018

The Filebeat documentation defines the offset field as

The file offset the reported line starts at.

But it appears that the offset is actually pointing to the end of the line. For example, when reading the first line of the file you would expect offset: 0, but this is not the case (tested with 6.2.2).

Should the docs or the code be changed?

@andrewkroh andrewkroh changed the title Filebeat offset points to end of line [Filebeat] offset points to end of line Mar 8, 2018
@ruflin
Copy link
Contributor

ruflin commented Mar 12, 2018

It seems we accidentially introduced this change in the 5.x releases. I tried 1.x where it's still as documented, but in 5.6 and 6.x it is as you reported. It probably happened because the offset in the registry needs to be at the end of the line and we move the calculation.

I'm thinking having the offset reported as the beginning of the line feels more natural from a user perspective. But as so far nobody complained I wonder if it matters?

@andrewkroh
Copy link
Member Author

I'm thinking having the offset reported as the beginning of the line feels more natural from a user perspective.

I totally agree. I find having the offset point to the end of the line misleading.

This came up while I was helper a user debug a json decoding issue, and we used the offset to determine where the line began in the log file and the offset became a point of confusion.

Additionally, seeing offset: 0 would be a clear indicator that rotation occurred.

@ruflin
Copy link
Contributor

ruflin commented Mar 12, 2018

The problem lies here:

state.Offset += int64(message.Bytes)

In filebeat 1.x this happened after creating the event / fields data. Now it happens afterwards:

"offset": state.Offset, // Offset here is the offset before the starting char.

Even the code comments are incorrect :-( A fix should be pretty simple by temporarely copy the previous offset and then use it for the event creation.

@dedemorton
Copy link
Contributor

@ruflin So it sounds like a code (not doc) fix is required here? if so, maybe remove the doc label?

@ruflin ruflin removed the docs label Mar 26, 2018
@ruflin
Copy link
Contributor

ruflin commented Mar 26, 2018

@dedemorton Yes, removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants