logstash-codec-fluent 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: eb490022b0c25a8e5ed02e3e909846d09b1bbb1a
4
+ data.tar.gz: 4a5616bf0ed37d416d1273c632d833d9db7eae90
5
+ SHA512:
6
+ metadata.gz: f780bb8b61bb14451c18b289254ff1b04c7e3cc3cda9400e84bcf18609599030225df450f3a82ad612162e8c82a052d3c221b9b5f7d1773b0f4f00a8e62e2609
7
+ data.tar.gz: 87c185dbba6248fd311b420757ae2c1f118fe8dd5ed1635739f4b9142162c147f95d79271629817c088258b5aadcccbb009356069af8cd7cadbebb873da5b717
@@ -0,0 +1,11 @@
1
+ ## 3.0.0
2
+ - Update the plugin to the version 2.0 of the plugin api, this change is required for Logstash 5.0 compatibility. See https://github.com/elastic/logstash/issues/5141
3
+ # 2.0.4
4
+ - Depend on logstash-core-plugin-api instead of logstash-core, removing the need to mass update plugins on major releases of logstash
5
+ # 2.0.3
6
+ - New dependency requirements for logstash-core for the 5.0 release
7
+ ## 2.0.0
8
+ - Plugins were updated to follow the new shutdown semantic, this mainly allows Logstash to instruct input plugins to terminate gracefully,
9
+ instead of using Thread.raise on the plugins' threads. Ref: https://github.com/elastic/logstash/pull/3895
10
+ - Dependency on logstash-core update to 2.0
11
+
@@ -0,0 +1,15 @@
1
+ The following is a list of people who have contributed ideas, code, bug
2
+ reports, or in general have helped logstash along its way.
3
+
4
+ Contributors:
5
+ * Colin Surprenant (colinsurprenant)
6
+ * Jordan Sissel (jordansissel)
7
+ * João Duarte (jsvd)
8
+ * Pier-Hugues Pellerin (ph)
9
+ * Richard Pijnenburg (electrical)
10
+ * Suyog Rao (suyograo)
11
+
12
+ Note: If you've sent us patches, bug reports, or otherwise contributed to
13
+ Logstash, and you aren't on the list above and want to be, please let us know
14
+ and we'll make sure you're here. Contributions from folks like you are what make
15
+ open source awesome.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in logstash-mass_effect.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2012–2016 Elasticsearch <http://www.elastic.co>
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
@@ -0,0 +1,5 @@
1
+ Elasticsearch
2
+ Copyright 2012-2015 Elasticsearch
3
+
4
+ This product includes software developed by The Apache Software
5
+ Foundation (http://www.apache.org/).
@@ -0,0 +1,98 @@
1
+ # Logstash Plugin
2
+
3
+ [![Travis Build Status](https://travis-ci.org/logstash-plugins/logstash-codec-fluent.svg)](https://travis-ci.org/logstash-plugins/logstash-codec-fluent)
4
+
5
+ This is a plugin for [Logstash](https://github.com/elastic/logstash).
6
+
7
+ 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.
8
+
9
+ ## Documentation
10
+
11
+ 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/).
12
+
13
+ - For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
14
+ - For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
15
+
16
+ ## Need Help?
17
+
18
+ Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
19
+
20
+ ## Developing
21
+
22
+ ### 1. Plugin Developement and Testing
23
+
24
+ #### Code
25
+ - To get started, you'll need JRuby with the Bundler gem installed.
26
+
27
+ - 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).
28
+
29
+ - Install dependencies
30
+ ```sh
31
+ bundle install
32
+ ```
33
+
34
+ #### Test
35
+
36
+ - Update your dependencies
37
+
38
+ ```sh
39
+ bundle install
40
+ ```
41
+
42
+ - Run tests
43
+
44
+ ```sh
45
+ bundle exec rspec
46
+ ```
47
+
48
+ ### 2. Running your unpublished Plugin in Logstash
49
+
50
+ #### 2.1 Run in a local Logstash clone
51
+
52
+ - Edit Logstash `Gemfile` and add the local plugin path, for example:
53
+ ```ruby
54
+ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
55
+ ```
56
+ - Install plugin
57
+ ```sh
58
+ # Logstash 2.3 and higher
59
+ bin/logstash-plugin install --no-verify
60
+
61
+ # Prior to Logstash 2.3
62
+ bin/plugin install --no-verify
63
+
64
+ ```
65
+ - Run Logstash with your plugin
66
+ ```sh
67
+ bin/logstash -e 'filter {awesome {}}'
68
+ ```
69
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
70
+
71
+ #### 2.2 Run in an installed Logstash
72
+
73
+ 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:
74
+
75
+ - Build your plugin gem
76
+ ```sh
77
+ gem build logstash-filter-awesome.gemspec
78
+ ```
79
+ - Install the plugin from the Logstash home
80
+ ```sh
81
+ # Logstash 2.3 and higher
82
+ bin/logstash-plugin install --no-verify
83
+
84
+ # Prior to Logstash 2.3
85
+ bin/plugin install --no-verify
86
+
87
+ ```
88
+ - Start Logstash and proceed to test the plugin
89
+
90
+ ## Contributing
91
+
92
+ All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
93
+
94
+ 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.
95
+
96
+ It is more important to the community that you are able to contribute.
97
+
98
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
@@ -0,0 +1,62 @@
1
+ # encoding: utf-8
2
+ require "logstash/codecs/base"
3
+ require "logstash/util/charset"
4
+ require "logstash/timestamp"
5
+ require "logstash/util"
6
+
7
+ # This codec handles fluentd's msgpack schema.
8
+ #
9
+ # For example, you can receive logs from `fluent-logger-ruby` with:
10
+ # [source,ruby]
11
+ # input {
12
+ # tcp {
13
+ # codec => fluent
14
+ # port => 4000
15
+ # }
16
+ # }
17
+ #
18
+ # And from your ruby code in your own application:
19
+ # [source,ruby]
20
+ # logger = Fluent::Logger::FluentLogger.new(nil, :host => "example.log", :port => 4000)
21
+ # logger.post("some_tag", { "your" => "data", "here" => "yay!" })
22
+ #
23
+ # Notes:
24
+ #
25
+ # * the fluent uses a second-precision time for events, so you will never see
26
+ # subsecond precision on events processed by this codec.
27
+ #
28
+ class LogStash::Codecs::Fluent < LogStash::Codecs::Base
29
+ config_name "fluent"
30
+
31
+ public
32
+ def register
33
+ require "msgpack"
34
+ @decoder = MessagePack::Unpacker.new
35
+ end
36
+
37
+ public
38
+ def decode(data)
39
+ @decoder.feed(data)
40
+ @decoder.each do |tag, epochtime, map|
41
+ event = LogStash::Event.new(map.merge(
42
+ LogStash::Event::TIMESTAMP => LogStash::Timestamp.at(epochtime),
43
+ "tags" => tag
44
+ ))
45
+ yield event
46
+ end
47
+ end # def decode
48
+
49
+ public
50
+ def encode(event)
51
+ tag = event.get("tags") || "log"
52
+ epochtime = event.timestamp.to_i
53
+
54
+ # use normalize to make sure returned Hash is pure Ruby for
55
+ # MessagePack#pack which relies on pure Ruby object recognition
56
+ data = LogStash::Util.normalize(event.to_hash)
57
+ # timestamp is serialized as a iso8601 string
58
+ # merge to avoid modifying data which could have side effects if multiple outputs
59
+ @on_event.call(event, MessagePack.pack([tag, epochtime, data.merge(LogStash::Event::TIMESTAMP => event.timestamp.to_iso8601)]))
60
+ end # def encode
61
+
62
+ end # class LogStash::Codecs::Fluent
@@ -0,0 +1,34 @@
1
+ Gem::Specification.new do |s|
2
+
3
+ s.name = 'logstash-codec-fluent'
4
+ s.version = '3.0.0'
5
+ s.licenses = ['Apache License (2.0)']
6
+ s.summary = "This codec handles fluentd's msgpack schema."
7
+ s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
8
+ s.authors = ["Elastic"]
9
+ s.email = 'info@elastic.co'
10
+ s.homepage = "http://www.elastic.co/guide/en/logstash/current/index.html"
11
+ s.require_paths = ["lib"]
12
+
13
+ # Files
14
+ s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
15
+
16
+ # Tests
17
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
18
+
19
+ # Special flag to let us know this is actually a logstash plugin
20
+ s.metadata = { "logstash_plugin" => "true", "logstash_group" => "codec" }
21
+
22
+ # Gem dependencies
23
+ s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"
24
+
25
+ if RUBY_PLATFORM == 'java'
26
+ s.platform = RUBY_PLATFORM
27
+ s.add_runtime_dependency 'msgpack-jruby'
28
+ else
29
+ s.add_runtime_dependency 'msgpack'
30
+ end
31
+
32
+ s.add_development_dependency 'logstash-devutils'
33
+ end
34
+
@@ -0,0 +1,46 @@
1
+ # encoding: utf-8
2
+ require_relative "../spec_helper"
3
+ require "logstash/plugin"
4
+ require "logstash/event"
5
+
6
+ describe LogStash::Codecs::Fluent do
7
+
8
+ let(:properties) { {:name => "foo" } }
9
+ let(:event) { LogStash::Event.new(properties) }
10
+
11
+ it "should register without errors" do
12
+ plugin = LogStash::Plugin.lookup("codec", "fluent").new
13
+ expect { plugin.register }.to_not raise_error
14
+ end
15
+
16
+ describe "event encoding" do
17
+
18
+ it "should encode as message pack format" do
19
+ subject.on_event do |event, data|
20
+ fields = MessagePack.unpack(data)
21
+ expect(fields[0]).to eq("log")
22
+ expect(fields[2]["name"]).to eq("foo")
23
+ end
24
+ subject.encode(event)
25
+ end
26
+
27
+ end
28
+
29
+ describe "event decoding" do
30
+
31
+ let(:tag) { "mytag" }
32
+ let(:epochtime) { event.timestamp.to_i }
33
+ let(:data) { LogStash::Util.normalize(event.to_hash) }
34
+ let(:message) do
35
+ MessagePack.pack([tag, epochtime, data.merge(LogStash::Event::TIMESTAMP => event.timestamp.to_iso8601)])
36
+ end
37
+
38
+ it "should decode without errors" do
39
+ subject.decode(message) do |event|
40
+ expect(event.get("name")).to eq("foo")
41
+ end
42
+ end
43
+
44
+ end
45
+
46
+ end
@@ -0,0 +1,3 @@
1
+ # encoding: utf-8
2
+ require "logstash/devutils/rspec/spec_helper"
3
+ require "logstash/codecs/fluent"
metadata ADDED
@@ -0,0 +1,101 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-codec-fluent
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Elastic
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-05-06 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: logstash-core-plugin-api
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: msgpack
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: logstash-devutils
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: This gem is a Logstash plugin required to be installed on top of the
56
+ Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This
57
+ gem is not a stand-alone program
58
+ email: info@elastic.co
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - CHANGELOG.md
64
+ - CONTRIBUTORS
65
+ - Gemfile
66
+ - LICENSE
67
+ - NOTICE.TXT
68
+ - README.md
69
+ - lib/logstash/codecs/fluent.rb
70
+ - logstash-codec-fluent.gemspec
71
+ - spec/codecs/fluent_spec.rb
72
+ - spec/spec_helper.rb
73
+ homepage: http://www.elastic.co/guide/en/logstash/current/index.html
74
+ licenses:
75
+ - Apache License (2.0)
76
+ metadata:
77
+ logstash_plugin: 'true'
78
+ logstash_group: codec
79
+ post_install_message:
80
+ rdoc_options: []
81
+ require_paths:
82
+ - lib
83
+ required_ruby_version: !ruby/object:Gem::Requirement
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ required_rubygems_version: !ruby/object:Gem::Requirement
89
+ requirements:
90
+ - - ">="
91
+ - !ruby/object:Gem::Version
92
+ version: '0'
93
+ requirements: []
94
+ rubyforge_project:
95
+ rubygems_version: 2.5.1
96
+ signing_key:
97
+ specification_version: 4
98
+ summary: This codec handles fluentd's msgpack schema.
99
+ test_files:
100
+ - spec/codecs/fluent_spec.rb
101
+ - spec/spec_helper.rb