logstash-output-fluentd 0.1.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: 3d69f4d74b09b7e98569821ba699b1be85f8cb16
4
+ data.tar.gz: f61c8d67511575cc38093650328aea9cfae78720
5
+ SHA512:
6
+ metadata.gz: 4bc80bc0817edb3dd8732286e3f83563f5a53999e9a4ba5eec5c2251eb97a0d9ec00c4f802d9b7e3f890d0b6d7183e6bc754a9df78c5c49af45e0c4117d399e7
7
+ data.tar.gz: cf209ee9d5008f4bf467c5d66165de01301fd8680b3fb497890701e8586a8d58a69e4ac0ed6bfb8510d235957715472b8a9e010f3d8d3ce91131b0e7d5fb74f0
@@ -0,0 +1,3 @@
1
+ ## 0.0.1
2
+ - Initial version
3
+
@@ -0,0 +1,10 @@
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
+ * Satoshi Tagomori (tagomoris)
6
+
7
+ Note: If you've sent us patches, bug reports, or otherwise contributed to
8
+ Logstash, and you aren't on the list above and want to be, please let us know
9
+ and we'll make sure you're here. Contributions from folks like you are what make
10
+ open source awesome.
@@ -0,0 +1,2 @@
1
+ # logstash-output-treasure_data
2
+ Treasure Data output plugin.
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright (c) 2015- Treasure Data, Inc. <https://www.treasuredata.com/>
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
+ Treasure Data, Inc.
2
+ Copyright 2015- Treasure Data, Inc.
3
+
4
+ This product includes software developed by The Apache Software
5
+ Foundation (http://www.apache.org/).
@@ -0,0 +1,89 @@
1
+ # Logstash Plugin for Tresure Data service
2
+
3
+ [![Build
4
+ Status](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Outputs/job/logstash-plugin-output-example-unit/badge/icon)](http://build-eu-00.elastic.co/view/LS%20Plugins/view/LS%20Outputs/job/logstash-plugin-output-example-unit/)
5
+
6
+ This is a plugin for [Logstash](https://github.com/elastic/logstash).
7
+
8
+ 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.
9
+
10
+ ## Documentation
11
+
12
+ 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/).
13
+
14
+ - For formatting code or config example, you can use the asciidoc `[source,ruby]` directive
15
+ - For more asciidoc formatting tips, see the excellent reference here https://github.com/elastic/docs#asciidoc-guide
16
+
17
+ ## Need Help?
18
+
19
+ Need help? Try #logstash on freenode IRC or the https://discuss.elastic.co/c/logstash discussion forum.
20
+
21
+ ## Developing
22
+
23
+ ### 1. Plugin Developement and Testing
24
+
25
+ #### Code
26
+ - To get started, you'll need JRuby with the Bundler gem installed.
27
+
28
+ - 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).
29
+
30
+ - Install dependencies
31
+ ```sh
32
+ bundle install
33
+ ```
34
+
35
+ #### Test
36
+
37
+ - Update your dependencies
38
+
39
+ ```sh
40
+ bundle install
41
+ ```
42
+
43
+ - Run tests
44
+
45
+ ```sh
46
+ bundle exec rspec
47
+ ```
48
+
49
+ ### 2. Running your unpublished Plugin in Logstash
50
+
51
+ #### 2.1 Run in a local Logstash clone
52
+
53
+ - Edit Logstash `Gemfile` and add the local plugin path, for example:
54
+ ```ruby
55
+ gem "logstash-filter-awesome", :path => "/your/local/logstash-filter-awesome"
56
+ ```
57
+ - Install plugin
58
+ ```sh
59
+ bin/plugin install --no-verify
60
+ ```
61
+ - Run Logstash with your plugin
62
+ ```sh
63
+ bin/logstash -e 'filter {awesome {}}'
64
+ ```
65
+ At this point any modifications to the plugin code will be applied to this local Logstash setup. After modifying the plugin, simply rerun Logstash.
66
+
67
+ #### 2.2 Run in an installed Logstash
68
+
69
+ 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:
70
+
71
+ - Build your plugin gem
72
+ ```sh
73
+ gem build logstash-filter-awesome.gemspec
74
+ ```
75
+ - Install the plugin from the Logstash home
76
+ ```sh
77
+ bin/plugin install /your/local/plugin/logstash-filter-awesome.gem
78
+ ```
79
+ - Start Logstash and proceed to test the plugin
80
+
81
+ ## Contributing
82
+
83
+ All contributions are welcome: ideas, patches, documentation, bug reports, complaints, and even something you drew up on a napkin.
84
+
85
+ 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.
86
+
87
+ It is more important to the community that you are able to contribute.
88
+
89
+ For more information about contributing, see the [CONTRIBUTING](https://github.com/elastic/logstash/blob/master/CONTRIBUTING.md) file.
@@ -0,0 +1,107 @@
1
+ # encoding: utf-8
2
+ require "logstash/outputs/base"
3
+ require "logstash/namespace"
4
+ require "logstash/json"
5
+
6
+ require "stud/buffer"
7
+ require "stud/try"
8
+ require "socket"
9
+
10
+ require "msgpack"
11
+
12
+ require_relative "./fluentd/version"
13
+
14
+ # Logstash output plugin to send data to Treasure Data service.
15
+
16
+ class LogStash::Event
17
+ def to_msgpack(packer=nil)
18
+ # LogStash objects (ex: LogStash::Timestamp) are impossible to serialize by msgpack
19
+ begin
20
+ @data.reject{|a,b| a == TIMESTAMP }.to_msgpack
21
+ rescue ArgumentError => e
22
+ LogStash::Json.load(@data.to_json).to_msgpack
23
+ end
24
+ end
25
+ end
26
+
27
+ class LogStash::Outputs::Fluentd < LogStash::Outputs::Base
28
+ include Stud::Buffer
29
+
30
+ config_name "fluentd"
31
+
32
+ config :host, validate: :string, required: true
33
+ config :port, validate: :number, default: 24224
34
+ # config :policy, validate: :string, default: 'at-most-once' # TODO: at-least-once
35
+
36
+ config :tag, validate: :string, default: 'logstash'
37
+ # config :use_ssl, validate: :boolean, default: false # TODO: true
38
+
39
+ config :connect_timeout, validate: :number, default: nil
40
+ config :read_timeout, validate: :number, default: nil
41
+ config :send_timeout, validate: :number, default: nil
42
+
43
+ config :flush_size, validate: :number, default: 50 # 50 records
44
+ config :flush_interval, validate: :number, default: 5 # 5 seconds
45
+
46
+ public
47
+ def register
48
+ client_opts = {
49
+ ssl: @use_ssl,
50
+ connect_timeout: @connect_timeout,
51
+ read_timeout: @read_timeout,
52
+ send_timeout: @send_timeout
53
+ }
54
+ # @client = TreasureData::Client.new(@apikey.value, client_opts)
55
+
56
+ buffer_initialize(
57
+ max_items: @flush_size,
58
+ max_interval: @flush_interval,
59
+ logger: @logger
60
+ )
61
+ end # def register
62
+
63
+ public
64
+ def receive(event)
65
+ @logger.debug "receive a event"
66
+
67
+ entry = [(event.timestamp.to_i || Time.now.to_i), event]
68
+ buffer_receive(entry.to_msgpack)
69
+
70
+ @logger.debug "buffered a event"
71
+ end
72
+
73
+ public
74
+ def flush(events, teardown = false)
75
+ @logger.debug "flushing #{events} events"
76
+ return if events.size < 1
77
+
78
+ data = [@tag, events.join].to_msgpack
79
+
80
+ @logger.debug "sending chunk #{data.bytesize} bytes"
81
+ connect.write data
82
+
83
+ @logger.debug "done"
84
+ end # def flush
85
+
86
+ public
87
+ def on_flush_error(e)
88
+ @logger.warn "flush error #{e.class}: #{e.message}"
89
+ end
90
+
91
+ public
92
+ def on_full_buffer_error(opts={})
93
+ @logger.warn "buffer exceeds limits: pending:#{opts[:pending_count]}, outgoing:#{opts[:outgoing_count]}"
94
+ end
95
+
96
+ public
97
+ def close
98
+ buffer_flush(final: true)
99
+ end
100
+
101
+ private
102
+ def connect
103
+ Stud::try do
104
+ return TCPSocket.new(@host, @port)
105
+ end
106
+ end # def connect
107
+ end # class LogStash::Outputs::Example
@@ -0,0 +1,6 @@
1
+ # encoding: utf-8
2
+ require "logstash/outputs/base"
3
+
4
+ class LogStash::Outputs::Fluentd < LogStash::Outputs::Base
5
+ VERSION = "0.1.0"
6
+ end
@@ -0,0 +1,27 @@
1
+ Gem::Specification.new do |s|
2
+ s.name = 'logstash-output-fluentd'
3
+ s.version = "0.1.0"
4
+ s.licenses = ["Apache License (2.0)"]
5
+ s.summary = "Logstash plugin to forward data to fluentd nodes"
6
+ s.description = "This gem is a logstash plugin to forward data from logstash to fluentd. This gem is not a stand-alone program."
7
+ s.authors = ["Satoshi Tagomori"]
8
+ s.email = "tagomoris@gmail.com"
9
+ s.homepage = "https://github.com/tagomoris/logstash-output-fluentd"
10
+ s.require_paths = ["lib"]
11
+
12
+ # Files
13
+ s.files = Dir['lib/**/*','spec/**/*','vendor/**/*','*.gemspec','*.md','CONTRIBUTORS','Gemfile','LICENSE','NOTICE.TXT']
14
+ # Tests
15
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
16
+
17
+ # Special flag to let us know this is actually a logstash plugin
18
+ s.metadata = { "logstash_plugin" => "true", "logstash_group" => "output" }
19
+
20
+ # Gem dependencies
21
+ s.add_runtime_dependency "logstash-core", ">= 2.0.0", "< 3.0.0"
22
+ s.add_runtime_dependency "logstash-codec-plain"
23
+ s.add_runtime_dependency "stud", "~> 0.0.19"
24
+ s.add_runtime_dependency "msgpack", "~> 0.7.1"
25
+ # s.add_runtime_dependency "jruby-openssl", ">= 0.9.11" # Required to support TLSv1.2 # TODO: for secure-forward support
26
+ s.add_development_dependency "logstash-devutils"
27
+ end
@@ -0,0 +1,28 @@
1
+ # encoding: utf-8
2
+ require "logstash/devutils/rspec/spec_helper"
3
+ require "logstash/codecs/plain"
4
+ require "logstash/event"
5
+
6
+ require "logstash/outputs/fluentd"
7
+
8
+ describe LogStash::Outputs::Fluentd do
9
+ let(:sample_event) { LogStash::Event.new }
10
+ let(:output) { LogStash::Outputs::Fluentd.new(config) }
11
+ let(:config) do
12
+ {
13
+ "host" => "127.0.0.1"
14
+ }
15
+ end
16
+
17
+ before do
18
+ output.register
19
+ end
20
+
21
+ describe "receive message" do
22
+ subject { output.receive(sample_event) }
23
+
24
+ it "returns a nil" do
25
+ expect(subject).to be_nil
26
+ end
27
+ end
28
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: logstash-output-fluentd
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Satoshi Tagomori
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-12-29 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: 2.0.0
19
+ - - "<"
20
+ - !ruby/object:Gem::Version
21
+ version: 3.0.0
22
+ name: logstash-core
23
+ prerelease: false
24
+ type: :runtime
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ version: 2.0.0
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: 3.0.0
33
+ - !ruby/object:Gem::Dependency
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ name: logstash-codec-plain
40
+ prerelease: false
41
+ type: :runtime
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: 0.0.19
53
+ name: stud
54
+ prerelease: false
55
+ type: :runtime
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: 0.0.19
61
+ - !ruby/object:Gem::Dependency
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - "~>"
65
+ - !ruby/object:Gem::Version
66
+ version: 0.7.1
67
+ name: msgpack
68
+ prerelease: false
69
+ type: :runtime
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: 0.7.1
75
+ - !ruby/object:Gem::Dependency
76
+ requirement: !ruby/object:Gem::Requirement
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: '0'
81
+ name: logstash-devutils
82
+ prerelease: false
83
+ type: :development
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ description: This gem is a logstash plugin to forward data from logstash to fluentd. This gem is not a stand-alone program.
90
+ email: tagomoris@gmail.com
91
+ executables: []
92
+ extensions: []
93
+ extra_rdoc_files: []
94
+ files:
95
+ - CHANGELOG.md
96
+ - CONTRIBUTORS
97
+ - DEVELOPER.md
98
+ - Gemfile
99
+ - LICENSE
100
+ - NOTICE.TXT
101
+ - README.md
102
+ - lib/logstash/outputs/fluentd.rb
103
+ - lib/logstash/outputs/fluentd/version.rb
104
+ - logstash-output-fluentd.gemspec
105
+ - spec/outputs/fluentd_spec.rb
106
+ homepage: https://github.com/tagomoris/logstash-output-fluentd
107
+ licenses:
108
+ - Apache License (2.0)
109
+ metadata:
110
+ logstash_plugin: 'true'
111
+ logstash_group: output
112
+ post_install_message:
113
+ rdoc_options: []
114
+ require_paths:
115
+ - lib
116
+ required_ruby_version: !ruby/object:Gem::Requirement
117
+ requirements:
118
+ - - ">="
119
+ - !ruby/object:Gem::Version
120
+ version: '0'
121
+ required_rubygems_version: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - ">="
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ requirements: []
127
+ rubyforge_project:
128
+ rubygems_version: 2.4.8
129
+ signing_key:
130
+ specification_version: 4
131
+ summary: Logstash plugin to forward data to fluentd nodes
132
+ test_files:
133
+ - spec/outputs/fluentd_spec.rb
134
+ has_rdoc: