fluent-plugin-sumologic-mattk42 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 58c29f7248c3f5ca50aa7f799debf52944dec1a4
4
+ data.tar.gz: ce7e2fcfa9aaec1aeb62c7907eaf652b919cf1c9
5
+ SHA512:
6
+ metadata.gz: 6c35a2200ec010d493dfd5a3762b8aecbbbf73de9ef878eb0d1180c48d3dde3797876969087b98ed39a6ea7af1cf4dec21b17646719595d707b4a5efa1a2b4a3
7
+ data.tar.gz: b22408c4b1a86770fab184f4dd1223d7b7019081fa9ec08e72d96928325726913e56458d671b8a4697f50fc54d58385f08baaada9a859fea600bbdb9d44ed3fa
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ Gemfile.lock
3
+ doc/
4
+ *.swp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in fluent-plugin-sumologic.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 memorycraft
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,62 @@
1
+ # Fluent::Plugin::Sumologic, a plugin for [Fluentd](http://fluentd.org)
2
+
3
+ fluent output plugin for Sumologic
4
+
5
+ ## Fluentd
6
+ http://fluentd.org/
7
+
8
+ ## Sumologic
9
+ http://www.sumologic.com/
10
+
11
+ ## Installation
12
+
13
+ Add this line to your application's Gemfile:
14
+
15
+ gem 'fluent-plugin-sumologic'
16
+
17
+ And then execute:
18
+
19
+ $ bundle
20
+
21
+ Or install it yourself as:
22
+
23
+ $ gem install fluent-plugin-sumologic
24
+
25
+ ## Usage
26
+
27
+
28
+ <match *.apache.*>
29
+ type sumologic
30
+ host collectors.sumologic.com
31
+ port 443
32
+ format json|text
33
+ path /receiver/v1/http/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX==
34
+ </match>
35
+
36
+
37
+ #### type
38
+ - sumologic
39
+
40
+ #### host
41
+ - Hostname of HTTP Collectors URL
42
+
43
+ #### port
44
+ - Port of HTTP Collectors URL
45
+
46
+ #### path
47
+ - Path of HTTP Collectors URL
48
+
49
+ #### format
50
+ - json: send as json format in fluent way
51
+ - text: send as raw text format (ex: using "parse using public/apache/access")
52
+
53
+ #### verify_ssl
54
+ - Verify ssl certificate. Default is true.
55
+
56
+ ## Contributing
57
+
58
+ 1. Fork it
59
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
60
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
61
+ 4. Push to the branch (`git push origin my-new-feature`)
62
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,11 @@
1
+ require "bundler/gem_tasks"
2
+
3
+
4
+ require 'rake/testtask'
5
+ Rake::TestTask.new(:test) do |test|
6
+ test.libs << 'lib' << 'test'
7
+ test.pattern = 'test/**/test_*.rb'
8
+ test.verbose = true
9
+ end
10
+
11
+ task :default => :test
@@ -0,0 +1,25 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "fluent-plugin-sumologic-mattk42"
7
+ spec.version = "0.0.2"
8
+ spec.authors = ["mattk42"]
9
+ spec.email = ["matt1988@gmail.com"]
10
+ spec.description = %q{fluent plugin for sumologic}
11
+ spec.summary = %q{sumologic is log management system. this plugin is fluent output plugin send to sumologic}
12
+ spec.homepage = "https://github.com/mattk42/fluent-plugin-sumologic"
13
+ spec.license = "MIT"
14
+
15
+ spec.rubyforge_project = "fluent-plugin-sumologic"
16
+
17
+ spec.files = `git ls-files`.split($/)
18
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.3"
23
+ spec.add_development_dependency "rake"
24
+ spec.add_runtime_dependency "fluentd"
25
+ end
@@ -0,0 +1,84 @@
1
+ # encoding: UTF-8
2
+ require 'net/http'
3
+ require 'date'
4
+
5
+ class Fluent::SumologicOutput< Fluent::BufferedOutput
6
+ Fluent::Plugin.register_output('sumologic', self)
7
+
8
+ config_param :host, :string, :default => 'collectors.sumologic.com'
9
+ config_param :port, :integer, :default => 443
10
+ config_param :verify_ssl, :bool, :default => true
11
+ config_param :path, :string, :default => '/receiver/v1/http/XXX'
12
+ config_param :format, :string, :default => 'json'
13
+ config_param :source_name_key, :string, :default => ''
14
+
15
+ include Fluent::SetTagKeyMixin
16
+ config_set_default :include_tag_key, false
17
+
18
+ include Fluent::SetTimeKeyMixin
19
+ config_set_default :include_time_key, false
20
+
21
+ def initialize
22
+ super
23
+ end
24
+
25
+ def configure(conf)
26
+ super
27
+ end
28
+
29
+ def start
30
+ super
31
+ end
32
+
33
+ def format(tag, time, record)
34
+ [tag, time, record].to_msgpack
35
+ end
36
+
37
+ def shutdown
38
+ super
39
+ end
40
+
41
+ def write(chunk)
42
+ messages_list = {}
43
+
44
+ case @format
45
+ when 'json'
46
+ chunk.msgpack_each do |tag, time, record|
47
+ if @include_tag_key
48
+ record.merge!(@tag_key => tag)
49
+ end
50
+ if @include_time_key
51
+ record.merge!(@time_key => @timef.format(time))
52
+ end
53
+ source_name = record[@source_name_key] || ''
54
+ record.delete(@source_name_key)
55
+ messages_list[source_name] = [] unless messages_list[source_name]
56
+ messages_list[source_name] << record.to_json
57
+ end
58
+ when 'text'
59
+ chunk.msgpack_each do |tag, time, record|
60
+ source_name = record[@source_name_key] || ''
61
+ messages_list[source_name] = [] unless messages_list[source_name]
62
+ messages_list[source_name] << record['message']
63
+ end
64
+ end
65
+
66
+ # (proxy,proxy_port) = ENV['http_proxy'].split(':')
67
+ # http = Net::HTTP::Proxy(proxy,proxy_port).new(@host, @port.to_i)
68
+ http = Net::HTTP.new(@host, @port.to_i)
69
+
70
+ http.use_ssl = true
71
+ http.verify_mode = @verify_ssl ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
72
+ # http.set_debug_output $stderr
73
+
74
+ messages_list.each do |source_name, messages|
75
+ request = Net::HTTP::Post.new(@path)
76
+ request['X-Sumo-Name'] = source_name unless source_name.empty?
77
+ request.body = messages.join("\n")
78
+ response = http.request(request)
79
+ unless response.is_a?(Net::HTTPSuccess)
80
+ raise "Failed to send data to #{@host}. #{response.code} #{response.message}"
81
+ end
82
+ end
83
+ end
84
+ end
data/test/helper.rb ADDED
@@ -0,0 +1,28 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ begin
4
+ Bundler.setup(:default, :development)
5
+ rescue Bundler::BundlerError => e
6
+ $stderr.puts e.message
7
+ $stderr.puts "Run `bundle install` to install missing gems"
8
+ exit e.status_code
9
+ end
10
+ require 'test/unit'
11
+
12
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
13
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
14
+ require 'fluent/test'
15
+ unless ENV.has_key?('VERBOSE')
16
+ nulllogger = Object.new
17
+ nulllogger.instance_eval {|obj|
18
+ def method_missing(method, *args)
19
+ # pass
20
+ end
21
+ }
22
+ $log = nulllogger
23
+ end
24
+
25
+ require 'fluent/plugin/out_sumologic'
26
+
27
+ class Test::Unit::TestCase
28
+ end
@@ -0,0 +1,56 @@
1
+ require 'helper'
2
+
3
+ class SumologicOutputTest < Test::Unit::TestCase
4
+ def setup
5
+ Fluent::Test.setup
6
+ end
7
+
8
+ CONFIG = %[
9
+ ]
10
+ # CONFIG = %[
11
+ # path #{TMP_DIR}/out_file_test
12
+ # compress gz
13
+ # utc
14
+ # ]
15
+
16
+ def create_driver(conf = CONFIG, tag='test')
17
+ Fluent::Test::BufferedOutputTestDriver.new(Fluent::SumologicOutput, tag).configure(conf)
18
+ end
19
+
20
+ def test_configure
21
+ #### set configurations
22
+ # d = create_driver %[
23
+ # path test_path
24
+ # compress gz
25
+ # ]
26
+ #### check configurations
27
+ # assert_equal 'test_path', d.instance.path
28
+ # assert_equal :gz, d.instance.compress
29
+ end
30
+
31
+ def test_format
32
+ d = create_driver
33
+
34
+ # time = Time.parse("2011-01-02 13:14:15 UTC").to_i
35
+ # d.emit({"a"=>1}, time)
36
+ # d.emit({"a"=>2}, time)
37
+
38
+ # d.expect_format %[2011-01-02T13:14:15Z\ttest\t{"a":1}\n]
39
+ # d.expect_format %[2011-01-02T13:14:15Z\ttest\t{"a":2}\n]
40
+
41
+ # d.run
42
+ end
43
+
44
+ def test_write
45
+ d = create_driver
46
+
47
+ # time = Time.parse("2011-01-02 13:14:15 UTC").to_i
48
+ # d.emit({"a"=>1}, time)
49
+ # d.emit({"a"=>2}, time)
50
+
51
+ # ### FileOutput#write returns path
52
+ # path = d.run
53
+ # expect_path = "#{TMP_DIR}/out_file_test._0.log.gz"
54
+ # assert_equal expect_path, path
55
+ end
56
+ end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-sumologic-mattk42
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - mattk42
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-06-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
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: fluentd
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: fluent plugin for sumologic
56
+ email:
57
+ - matt1988@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - Gemfile
64
+ - LICENSE.txt
65
+ - README.md
66
+ - Rakefile
67
+ - fluent-plugin-sumologic.gemspec
68
+ - lib/fluent/plugin/out_sumologic.rb
69
+ - test/helper.rb
70
+ - test/plugin/test_out_sumologic.rb
71
+ homepage: https://github.com/mattk42/fluent-plugin-sumologic
72
+ licenses:
73
+ - MIT
74
+ metadata: {}
75
+ post_install_message:
76
+ rdoc_options: []
77
+ require_paths:
78
+ - lib
79
+ required_ruby_version: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - ">="
82
+ - !ruby/object:Gem::Version
83
+ version: '0'
84
+ required_rubygems_version: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ version: '0'
89
+ requirements: []
90
+ rubyforge_project: fluent-plugin-sumologic
91
+ rubygems_version: 2.4.6
92
+ signing_key:
93
+ specification_version: 4
94
+ summary: sumologic is log management system. this plugin is fluent output plugin send
95
+ to sumologic
96
+ test_files:
97
+ - test/helper.rb
98
+ - test/plugin/test_out_sumologic.rb
99
+ has_rdoc: