Add an new input type to backfill gzipped logs
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.
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
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 Always here to help.
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.
+1. Is anyone working on this? If not I could possibly take it up..
@Ragsboss I don't think anyone is working on that. Would be great to have a PR for that to discuss the details.
@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 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...
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.
Here is the PR related to the above discussions: https://github.com/elastic/beats/pull/2227
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 Thanks for the details. For the batch mode you will be interested in https://github.com/elastic/beats/pull/2456 (in progress)
Now that https://github.com/elastic/beats/pull/2456 is merged this feature got even more interesting :-)
Hello,
Has there been any update regarding the support for gzip files ? Please let know.
Thanks.
Idk about the others, but I've not gotten any time to work on this.
No progress yet on this from my side.
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.
Has there been any movement on this as this too is the killer feature for me too
Throwing in my support for this feature.
Would be an awesome feature to have.