fluent-plugin-sumologic-caugustus 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: a2a7eb753d213478e6fa622a47319e9761c61282
4
+ data.tar.gz: 769de6ec86e8d1675359a6dd9d2631c9d6768a32
5
+ SHA512:
6
+ metadata.gz: 82595ea6fbe33eeab43cd8205b15717c7690882f54aea98b8dd7f71d1e4a6be2cb82dce59f0c5f40a61cb64188c08a36e11d84cc491be23a5abaf1c46575eeff
7
+ data.tar.gz: 81b8ae9ea3ea267bec817d74bdead17441ba0d5d37222adbf9e3a34d5c664bd1a6c47f972448244d2eddbec62180d7fdd2cb8faf0cc632dae5bc3d2d5bcfb694
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-caugustus"
7
+ spec.version = "0.0.2"
8
+ spec.authors = ["memorycraft"]
9
+ spec.email = ["memorycraft@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. Forked from mfowlewebs/fluent-plugin-sumologic}
12
+ spec.homepage = "https://github.com/caugustus/fluent-plugin-sumologic"
13
+ spec.license = "MIT"
14
+
15
+ spec.rubyforge_project = "fluent-plugin-sumologic-caugustus"
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,83 @@
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
+ config_param :debug, :bool, :default => false
15
+
16
+ include Fluent::SetTagKeyMixin
17
+ config_set_default :include_tag_key, false
18
+
19
+ include Fluent::SetTimeKeyMixin
20
+ config_set_default :include_time_key, false
21
+
22
+ def initialize
23
+ super
24
+ end
25
+
26
+ def configure(conf)
27
+ super
28
+ end
29
+
30
+ def start
31
+ super
32
+ end
33
+
34
+ def format(tag, time, record)
35
+ [tag, time, record].to_msgpack
36
+ end
37
+
38
+ def shutdown
39
+ super
40
+ end
41
+
42
+ def write(chunk)
43
+ messages_list = {}
44
+
45
+ case @format
46
+ when 'json'
47
+ chunk.msgpack_each do |tag, time, record|
48
+ if @include_tag_key
49
+ record.merge!(@tag_key => tag)
50
+ end
51
+ if @include_time_key
52
+ record.merge!(@time_key => @timef.format(time))
53
+ end
54
+ source_name = record[@source_name_key] || ''
55
+ record.delete(@source_name_key)
56
+ messages_list[source_name] = [] unless messages_list[source_name]
57
+ messages_list[source_name] << record.to_json
58
+ end
59
+ when 'text'
60
+ chunk.msgpack_each do |tag, time, record|
61
+ source_name = record[@source_name_key] || ''
62
+ messages_list[source_name] = [] unless messages_list[source_name]
63
+ messages_list[source_name] << record['message']
64
+ end
65
+ end
66
+
67
+ (proxy,proxy_port) = ENV['http_proxy'].split(':')
68
+ http = Net::HTTP::Proxy(proxy,proxy_port).new(@host, @port.to_i)
69
+ http.use_ssl = true
70
+ http.verify_mode = @verify_ssl ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
71
+ http.set_debug_output $stderr if @debug
72
+
73
+ messages_list.each do |source_name, messages|
74
+ request = Net::HTTP::Post.new(@path)
75
+ request['X-Sumo-Name'] = source_name unless source_name.empty?
76
+ request.body = messages.join("\n")
77
+ response = http.request(request)
78
+ unless response.is_a?(Net::HTTPSuccess)
79
+ raise "Failed to send data to #{@host}. #{response.code} #{response.message}"
80
+ end
81
+ end
82
+ end
83
+ 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,98 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-sumologic-caugustus
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - memorycraft
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-10-19 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
+ - memorycraft@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/caugustus/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-caugustus
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. Forked from mfowlewebs/fluent-plugin-sumologic
96
+ test_files:
97
+ - test/helper.rb
98
+ - test/plugin/test_out_sumologic.rb