fluent-plugin-sumologic-carsonoid 0.0.3

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: 3b4ff5e2aa997cf3487299701405602cbd4c81e0
4
+ data.tar.gz: 5ff680f968381ef33a4c335203a7a92a4e2f2397
5
+ SHA512:
6
+ metadata.gz: 7f3445052f08e74cc0841d3bab45fec748a26fe4b67fe2d555591aa299e32b0be2e53899975f518154a15c30ee28c0bcb6b0849f863f925fb5641ec3f5b79637
7
+ data.tar.gz: 97e830dbe31e7e73859dcf0e853b30e7d22a04ee079a98e790ad1d6ae20d15af4295cd03d44d01a56b628af755341ee04dcd49f00528b3298785faa2a4674331
@@ -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
@@ -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.
@@ -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
@@ -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-carsonoid"
7
+ spec.version = "0.0.3"
8
+ spec.authors = ["memorycraft", "carsonoid"]
9
+ spec.email = ["memorycraft@gmail.com", "ca@carson-anderson.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/carsonoid/fluent-plugin-sumologic"
13
+ spec.license = "MIT"
14
+
15
+ spec.rubyforge_project = "fluent-plugin-sumologic-carsonoid"
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,87 @@
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
+ if ENV.has_key?("http_proxy")
67
+ (proxy,proxy_port) = ENV['http_proxy'].split(':')
68
+ http = Net::HTTP::Proxy(proxy,proxy_port).new(@host, @port.to_i)
69
+ else
70
+ http = Net::HTTP.new(@host, @port.to_i)
71
+ end
72
+
73
+ http.use_ssl = true
74
+ http.verify_mode = @verify_ssl ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
75
+ http.set_debug_output $stderr
76
+
77
+ messages_list.each do |source_name, messages|
78
+ request = Net::HTTP::Post.new(@path)
79
+ request['X-Sumo-Name'] = source_name unless source_name.empty?
80
+ request.body = messages.join("\n")
81
+ response = http.request(request)
82
+ unless response.is_a?(Net::HTTPSuccess)
83
+ raise "Failed to send data to #{@host}. #{response.code} #{response.message}"
84
+ end
85
+ end
86
+ end
87
+ end
@@ -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,100 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: fluent-plugin-sumologic-carsonoid
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - memorycraft
8
+ - carsonoid
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2016-03-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - "~>"
19
+ - !ruby/object:Gem::Version
20
+ version: '1.3'
21
+ type: :development
22
+ prerelease: false
23
+ version_requirements: !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - "~>"
26
+ - !ruby/object:Gem::Version
27
+ version: '1.3'
28
+ - !ruby/object:Gem::Dependency
29
+ name: rake
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: '0'
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ - !ruby/object:Gem::Dependency
43
+ name: fluentd
44
+ requirement: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
49
+ type: :runtime
50
+ prerelease: false
51
+ version_requirements: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ description: fluent plugin for sumologic
57
+ email:
58
+ - memorycraft@gmail.com
59
+ - ca@carson-anderson.com
60
+ executables: []
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - ".gitignore"
65
+ - Gemfile
66
+ - LICENSE.txt
67
+ - README.md
68
+ - Rakefile
69
+ - fluent-plugin-sumologic.gemspec
70
+ - lib/fluent/plugin/out_sumologic.rb
71
+ - test/helper.rb
72
+ - test/plugin/test_out_sumologic.rb
73
+ homepage: https://github.com/carsonoid/fluent-plugin-sumologic
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ required_ruby_version: !ruby/object:Gem::Requirement
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ required_rubygems_version: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - ">="
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ requirements: []
92
+ rubyforge_project: fluent-plugin-sumologic-carsonoid
93
+ rubygems_version: 2.5.2
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: sumologic is log management system. this plugin is fluent output plugin send
97
+ to sumologic
98
+ test_files:
99
+ - test/helper.rb
100
+ - test/plugin/test_out_sumologic.rb