beats icon indicating copy to clipboard operation
beats copied to clipboard

Add an new input type to backfill gzipped logs

Open lminaudier opened this issue 10 years ago • 121 comments

Hi,

Following this discussion on filebeat forum I would like to ask if it is possible to implement a solution to easily backfill old gzipped logs with filebeat.

The proposed solution mentioned in the topic is to add a new dedicated input_type.

It is also mentioned in the topic that when filebeat reaches the end of input on stdin it does not give you the hand back and waits for new lines which makes things hard to script to perform backfilling.

What are your thoughts on this ?

Thanks for your hard work.

lminaudier avatar Jan 06 '16 08:01 lminaudier

I would see the implementation as following:

  • Prospector: A gzip prospector would be added. Harvesters would only be opened based on filenames (no inode etc.). It is assume, that the files are not renamed and don't have to be tracked. A file has a completion state and if it is once completed, it is never read again. This simplifies the implementation. If a .gz file with a new filename is found, a harvester is started.
  • Harvester: A gzip harvester is added. It unzips and reads the full file only once. After finishing reading the file, the harvester stops and is never started again. The offset is only stored, if it is interrupted in the middle of reading. In a first implementation, this could even be removed for simplicity.

This would be nice to have but I think it is not on the top of our priority list. A community contribution here would be more then welcome.

For your second issue about running filebeat only until first completion, lets refer to this issue: https://github.com/elastic/filebeat/issues/219

ruflin avatar Jan 06 '16 09:01 ruflin

Thanks for the fast reply and the pointer to the issue.

I will try to look at your implementation proposal. I am still quite new to Golang and the project, so I can't promise anything :)

lminaudier avatar Jan 06 '16 09:01 lminaudier

@lminaudier Always here to help.

ruflin avatar Jan 06 '16 10:01 ruflin

This would be a great feature addition. Currently the splunk-forwarder does something similar and will index log rotated files that have been gziped automatically.

mryanb avatar Jan 21 '16 23:01 mryanb

+1. Is anyone working on this? If not I could possibly take it up..

Ragsboss avatar Aug 01 '16 17:08 Ragsboss

@Ragsboss I don't think anyone is working on that. Would be great to have a PR for that to discuss the details.

ruflin avatar Aug 02 '16 08:08 ruflin

@Ragsboss @ruflin I'm delighted to see there's someone looking to pick this up. Is this happening? The reason I ask is because it may be possible for me to spend some time helping out with this in lieu of building another solution for gziped logs to use internally.

cFire avatar Aug 05 '16 07:08 cFire

@cFire please feel free to take this up. I've started looking at the code familiarizing myself with Go in general and FileBeat code. But I haven't started the real work yet. I'll try to help you in anyway you want, just let me know. Few thoughts I had. From a pure functional viewpoint, defining a new input_type doesn't seem ideal as that would force users to author a new prospector in the config file. Instead I felt it may be better for the code to automatically deal with compressed files as long as they match the given filename patterns in the config file. The code can instantiate a different harvester (IIUC) based on the file extension/type. But from implementation viewpoint if this is turning out to be difficult, I think it's ok to burden/ask the users for some extra config...

Ragsboss avatar Aug 05 '16 17:08 Ragsboss

From an implementation point of view I think we should go the route of having a separate input type. Currently the way filebeat is designed is that a prospector and harvester type are tightly coupled, so a prospector only starts one type of harvesters. It is ok if gzip harvester reuses lots of code from the log harvester (which I think it will) but as log tailing and reading a file completely only once are form my perspective two quite different behaviours. The question which will also be raised is if the gzip files will change their name over time (means have to be tracked based on inode / device) or it is enough to just store the filename and a read / unread flag in the registry.

ruflin avatar Aug 08 '16 08:08 ruflin

Here is the PR related to the above discussions: https://github.com/elastic/beats/pull/2227

ruflin avatar Aug 16 '16 11:08 ruflin

We would like filebeat to be able to read gzipped files, too.

Our main use of filebeat would be to take a set of rotated, gzipped logs that represent the previous day's events, and send them to elasticsearch.

No tailing or running as a service is required, so a "batch mode" would also be good, but other workarounds solely using filebeat would also be acceptable.

willsheppard avatar Sep 05 '16 11:09 willsheppard

@willsheppard Thanks for the details. For the batch mode you will be interested in https://github.com/elastic/beats/pull/2456 (in progress)

ruflin avatar Sep 06 '16 08:09 ruflin

Now that https://github.com/elastic/beats/pull/2456 is merged this feature got even more interesting :-)

ruflin avatar Sep 16 '16 15:09 ruflin

Hello,

Has there been any update regarding the support for gzip files ? Please let know.

Thanks.

collabccie7 avatar Oct 18 '16 02:10 collabccie7

Idk about the others, but I've not gotten any time to work on this.

cFire avatar Oct 18 '16 11:10 cFire

No progress yet on this from my side.

ruflin avatar Oct 24 '16 06:10 ruflin

This gzip input filter would be the killer feature for us. We're being forced to consider writing an Elasticsearch ingest script from scratch which writes to the Bulk API, because we need to operate on logs in-place (no space to unzip them), and we would be using batch-mode (#2456) to ingest yesterday's logs from our web clusters.

willsheppard avatar Nov 22 '16 09:11 willsheppard

Has there been any movement on this as this too is the killer feature for me too

maddazzaofdudley avatar Jan 27 '17 16:01 maddazzaofdudley

Throwing in my support for this feature.

woodchalk avatar Jan 28 '17 00:01 woodchalk

Would be an awesome feature to have.

plumpNation avatar Jan 29 '17 19:01 plumpNation