Instantly share code, notes, and snippets.

What would you like to do?
json_file_gz codec for Logstash, to handle gzipped json files handled to it as file names in the input stream. Details:
# encoding: utf-8
require 'logstash/codecs/base'
class LogStash::Codecs::JsonFileGz < LogStash::Codecs::Base
config_name 'json_file_gz'
milestone 1
def register
require 'zlib'
def decode(path)
json_data = { |f| }
rescue Zlib::GzipFile::Error => e'Gzip failure, skipped', :error => e, :data => json_data)
yield if json_data
rescue JSON::ParserError => e'JSON parse failure. Falling back to plain-text', :error => e, :data => json_data)
yield'message' => json_data)
end # def decode
def encode(data)
raise NotImplementedError
end # def encode
end # class LogStash::Codecs::JsonFileGz

This comment has been minimized.

shurane commented Jul 21, 2014

Man this would be a really cool pull request against Logstash... especially if they ended up merging it in.


This comment has been minimized.

federicoaaguirre commented Aug 25, 2014

Hi there.! It doesn't work for me :( it says: "Couldn't find any codec plugin named 'json_file_gz'. Are you sure this is correct? Trying to load the json_file_gz codec plugin resulted in this error: no such file to load -- logstash/codecs/json_file_gz". I've my logstash installed @ /opt/logstash.!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment