First commit of gzip codec
Diff
.gitignore | 3 ++-
CHANGELOG.md | 16 ++++++++-
CONTRIBUTORS | 17 +++++++++-
Gemfile | 2 +-
LICENSE | 13 +++++++-
NOTICE.TXT | 5 +++-
README.md | 91 ++++++++++++++++++++++++++++++++++++++++++++--
Rakefile | 7 ++++-
lib/logstash/codecs/gzip.rb | 42 +++++++++++++++++++++-
logstash-codec-gzip.gemspec | 27 ++++++++++++++-
10 files changed, 221 insertions(+), 2 deletions(-)
@@ -0,0 +1,3 @@
*.gem
Gemfile.lock
.bundle
@@ -0,0 +1,16 @@
## 2.0.4
- Reduce the size of the gem by removing the vendor files
## 2.0.3
- fixed a spec, no change in functionality
## 2.0.0
- Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
- Dependency on logstash-core update to 2.0
## 1.1.0
- Handle scalar types (string/number) and be more defensive about crashable errors
## 1.0.1
- Handle JSON arrays at source root by emitting multiple events
@@ -0,0 +1,17 @@
The following is a list of people who have contributed ideas, code, bug
reports, or in general have helped logstash along its way.
Contributors:
* Colin Surprenant (colinsurprenant)
* Jordan Sissel (jordansissel)
* João Duarte (jsvd)
* Kurt Hurtado (kurtado)
* Nick Ethier (nickethier)
* Pier-Hugues Pellerin (ph)
* Richard Pijnenburg (electrical)
* Tal Levy (talevy)
Note: If you've sent us patches, bug reports, or otherwise contributed to
Logstash, and you aren't on the list above and want to be, please let us know
and we'll make sure you're here. Contributions from folks like you are what make
open source awesome.
@@ -0,0 +1,2 @@
source 'https://rubygems.org'
gemspec
\ No newline at end of file
@@ -0,0 +1,13 @@
Copyright (c) 2012–2015 Elasticsearch <http://www.elastic.co>
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
@@ -0,0 +1,5 @@
Elasticsearch
Copyright 2012-2015 Elasticsearch
This product includes software developed by The Apache Software
Foundation (http://www.apache.org/).
\ No newline at end of file
@@ -1,2 +1,89 @@
# logstash-codec-gzip
This codec may be used to decode and encode gzip encoded data
# Logstash Plugin
[![Build
Status](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Codecs/job/logstash-plugin-codec-json-unit/badge/icon)](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Codecs/job/logstash-plugin-codec-json-unit/)
This is a plugin for [Logstash](https://github.com/elastic/logstash).
It is fully free and fully open source. The license is Apache 2.0, meaning you are pretty much free to use it however you want in whatever way.
## Documentation
Logstash provides infrastructure to automatically generate documentation for this plugin. We use the asciidoc format to write documentation so any comments in the source code will be first converted into asciidoc and then into html. All plugin documentation are placed under one [central location](http://www.elastic.co/guide/en/logstash/current/).
- For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
- For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
## Need Help?
Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
## Developing
### 1. Plugin Developement and Testing
#### Code
- To get started, you'll need JRuby with the Bundler gem installed.
- Create a new plugin or clone and existing from the GitHub [logstash-plugins](https://github.com/logstash-plugins) organization. We also provide [example plugins](https://github.com/logstash-plugins?query=example).
- Install dependencies
```sh
bundle install
```
#### Test
- Update your dependencies
```sh
bundle install
```
- Run tests
```sh
bundle exec rspec
```
### 2. Running your unpublished Plugin in Logstash
#### 2.1 Run in a local Logstash clone
- Edit Logstash `Gemfile` and add the local plugin path, for example:
```ruby
gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
```
- Install plugin
```sh
bin/plugin install --no-verify
```
- Run Logstash with your plugin
```sh
bin/logstash -e 'filter {awesome {}}'
```
At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
#### 2.2 Run in an installed Logstash
You can use the same **2.1** method to run your plugin in an installed Logstash by editing its `Gemfile` and pointing the `:path` to your local plugin development directory or you can build the gem and install it using:
- Build your plugin gem
```sh
gem build logstash-filter-awesome.gemspec
```
- Install the plugin from the Logstash home
```sh
bin/plugin install /your/local/plugin/logstash-filter-awesome.gem
```
- Start Logstash and proceed to test the plugin
## Contributing
All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
Programming is not a required skill. Whatever you've seen about open source and maintainers or community members saying "send patches or die" - you will not see that here.
It is more important to the community that you are able to contribute.
For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
\ No newline at end of file
@@ -0,0 +1,7 @@
@files=[]
task :default do
system("rake -T")
end
require "logstash/devutils/rake"
@@ -0,0 +1,42 @@
require "logstash/codecs/base"
require "logstash/util/charset"
require "zlib"
require "stringio"
class LogStash::Codecs::GZIP < LogStash::Codecs::Base
config_name "gzip"
config :charset, :validate => ::Encoding.name_list, :default => "UTF-8"
public
def register
@converter = LogStash::Util::Charset.new(@charset)
@converter.logger = @logger
end
public
def decode(data)
begin
decoded = Zlib::GzipReader.new(StringIO.new(data)).read
yield LogStash::Event.new("message" => @converter.convert(decoded))
rescue Zlib::Error, Zlib::GzipFile::Error=> e
@logger.info? && @logger.info("GZIP parse failure. Falling back to plain-text", :error => e, :data => data)
yield LogStash::Event.new("message" => data, "tags" => ["_gzipparsefailure"])
end
end end @@ -0,0 +1,27 @@
Gem::Specification.new do |s|
s.name = 'logstash-codec-gzip'
s.version = '2.0.4'
s.licenses = ['Apache License (2.0)']
s.summary = "This codec may be used to decode (via inputs) and encode (via outputs) full gzip messages"
s.description = "This gem is a logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/plugin install gemname. This gem is not a stand-alone program"
s.authors = ["Elastic"]
s.email = 'info@elastic.co'
s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
s.require_paths = ["lib"]
s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
s.test_files = s.files.grep(%r{^(test|spec|features)/})
s.metadata = { "logstash_plugin" => "true", "logstash_group" => "codec" }
s.add_runtime_dependency "logstash-core", "< 2.0.0"
s.add_development_dependency 'logstash-devutils'
end