Class: LogStash::Codecs::GZIP
- Inherits:
-
Base
- Object
- Base
- LogStash::Codecs::GZIP
- Defined in:
- lib/logstash/codecs/gzip.rb
Overview
This codec may be used to decode gzip data from string.
If this codec recieves a payload from an input that is not valid GZIP, then it will fall back to plain text and add a tag ‘_gzipparsefailure`. Upon a GZIP failure, the payload will be stored in the `message` field.
Constant Summary collapse
- MESSAGE_FIELD =
"message".freeze
Instance Method Summary collapse
Instance Method Details
#decode(data) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/logstash/codecs/gzip.rb', line 35 def decode(data) begin decoded = Zlib::GzipReader.new(StringIO.new(data)).read yield LogStash::Event.new(MESSAGE_FIELD => @converter.convert(decoded)) rescue Zlib::Error, Zlib::GzipFile::Error=> e @logger.info? && @logger.info("Gzip codec: GZIP parse failure. Falling back to plain-text", :error => e, :data => data) yield LogStash::Event.new(MESSAGE_FIELD => @converter.convert(data), "tags" => ["_gzipparsefailure"]) end end |
#register ⇒ Object
29 30 31 32 |
# File 'lib/logstash/codecs/gzip.rb', line 29 def register @converter = LogStash::Util::Charset.new(@charset) @converter.logger = @logger end |