File input for gz files


I have seen few topics on logstash supporting reading from the gz files.

Would like to know if this feature is supported !! I am using logstash 2.1.0. If supported please share me the sample input config.

Below is my config.
input {
file {
type => "gzip"
path => "/syslog/applog/notif/delwin23/sc5/HCPTapp.log.2015_11_29*.gz"
start_position => "beginning"
sincedb_path => "gzip"
codec => "gzip_lines"

output {

stdout { codec => json }


bash-3.2$ ./logstash -f ns_off.cnf
io/console not supported; tty will not be manipulated
Settings: Default filter workers: 2
Logstash startup completed
Logstash shutdown completed

It seems the file is not read.


Attaching the debug log in 2 posts - as the max content limit is 7K Chars..and there is no file attachment option

bash-3.2$ ./logstash -f ns_off.cnf --debug
io/console not supported; tty will not be manipulated
Reading config file {:config_file=>"/sysapp/app/elk/logstash-2.1.0/bin/ns_off.cnf", :level=>:debug, :file=>"logstash/agent.rb", :line=>"325", :method=>"local_config"}
Compiled pipeline code:
@inputs = []
@filters = []
@outputs = []
@periodic_flushers = []
@shutdown_flushers = []

      @input_file_1 = plugin("input", "file", LogStash::Util.hash_merge_many({ "type" => ("gzip") }, { "path" => ("/syslog/applog/notif/delwin23/sc5/HCPTapp.log.2015_11_29*.gz") }, { "start_position" => ("beginning") }, { "sincedb_path" => ("gzip") }, { "codec" => ("gzip_lines") }))

      @inputs << @input_file_1

      @output_stdout_2 = plugin("output", "stdout", LogStash::Util.hash_merge_many({ "codec" => ("json") }))

      @outputs << @output_stdout_2

def filter_func(event)
events = [event]
@logger.debug? && @logger.debug("filter received", :event => event.to_hash)
def output_func(event)
@logger.debug? && @logger.debug("output received", :event => event.to_hash)

end {:level=>:debug, :file=>"logstash/pipeline.rb", :line=>"38", :method=>"initialize"}

I have tried in another OS (RHEL) and the file detection and reading is happening.
However the output is all the junk/special characters which would be in a typical gz files. How to get the output as same in the actual "plain" text format as if in original file. !!

Below is the config
file {
path => "/notif_logs/selfcareApps/selfcare1/HCPTapp.log*.gz"
start_position => "beginning"
codec => "gzip_lines"

Did you install the gzip_lines codec?

Hi Mark
Yes. Infact I installed the "Logstash 2.1.0 (All Plugins)" version. Pls check below.

bash-3.2$ find . -name gzip

Can anyone Pls guide me on this !!

Does logstash supporting reading from gz files and output the "plain" text as in original file.
If so, pls suggest the correct configuration.

Thanks in anticipation.

For the special chars, if the input file is not encoded in UTF-8, you have to set encoding => "YourEncoding" in input plugin.

For the output, do you try with "rubydebug" output, to check that all input/filter chain works fine ?

I mean :
output {
stdout { codec => rubydebug }

Hi Thanks for Reply.
As I mentioned in the problem statement - The input file is a gizzed file in gz format. The original file is actually a plain text file (application log4j log file). I have also mentioned my input plugin configuration above.

I don't find any configuration setting "encoding" in the file input plugin.

Pls suggest

To be clearer, if your gziped input files are written using "ISO-8859-1" charset (or any charset different from UTF-8), use this configuration :

file {
path => "/notif_logs/selfcareApps/selfcare1/HCPTapp.log*.gz"
start_position => "beginning"
codec => gzip_lines { charset => "ISO-8859-1" }

wondering why this (obvious) syntax still does not work for me.....

I was still not able to solve this problem. :frowning:


This syntax is not working. You can see this open issue. Also it is know issue for this flavor. So I suppose that currently it is not supported.

The only workaround that I found was the below:

 pipe {
        command => "gunzip --stdout /home/....../test.gz"

Which IHO is not the best.