fluent-plugin-sumologic-2 0.0.3
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 +7 -0
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +62 -0
- data/Rakefile +11 -0
- data/fluent-plugin-sumologic.gemspec +25 -0
- data/lib/fluent/plugin/out_sumologic.rb +73 -0
- data/test/helper.rb +28 -0
- data/test/plugin/test_out_sumologic.rb +56 -0
- metadata +100 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3a0d22cc698ba1932b5d74ec24824fdf547339aa
|
4
|
+
data.tar.gz: 1df9814f11b40bb36dcd3c7583ccdba21714d26d
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ea8dd91736984ed3c98b49c054de45366819052523fb1e341ff75bf8cc12e902ce8c6eb79709948caf0cfd0212fcd56c192f32ccb7ac9f643063b8765644ac6d
|
7
|
+
data.tar.gz: 9b2c53f159d92e16be11f3f819075a1efea1ac9e91d39326b573038afddafd1cdc4d6d3838b04bb249cab0eed626a2d99dd7962cd1ba8cad21ffe16bac12cf2c
|
data/.gitignore
ADDED
data/Gemfile
ADDED
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,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-2"
|
7
|
+
spec.version = "0.0.3"
|
8
|
+
spec.authors = ["memorycraft", "adambom"]
|
9
|
+
spec.email = ["memorycraft@gmail.com", "adam.savitzky@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/memorycraft/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,73 @@
|
|
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
|
+
|
14
|
+
include Fluent::SetTagKeyMixin
|
15
|
+
config_set_default :include_tag_key, false
|
16
|
+
|
17
|
+
include Fluent::SetTimeKeyMixin
|
18
|
+
config_set_default :include_time_key, false
|
19
|
+
|
20
|
+
def initialize
|
21
|
+
super
|
22
|
+
end
|
23
|
+
|
24
|
+
def configure(conf)
|
25
|
+
super
|
26
|
+
end
|
27
|
+
|
28
|
+
def start
|
29
|
+
super
|
30
|
+
end
|
31
|
+
|
32
|
+
def format(tag, time, record)
|
33
|
+
[tag, time, record].to_msgpack
|
34
|
+
end
|
35
|
+
|
36
|
+
def shutdown
|
37
|
+
super
|
38
|
+
end
|
39
|
+
|
40
|
+
def write(chunk)
|
41
|
+
messages = []
|
42
|
+
|
43
|
+
case @format
|
44
|
+
when 'json'
|
45
|
+
chunk.msgpack_each do |tag, time, record|
|
46
|
+
if @include_tag_key
|
47
|
+
record.merge!(@tag_key => tag)
|
48
|
+
end
|
49
|
+
if @include_time_key
|
50
|
+
record.merge!(@time_key => @timef.format(time))
|
51
|
+
end
|
52
|
+
messages << record.to_json
|
53
|
+
end
|
54
|
+
when 'text'
|
55
|
+
chunk.msgpack_each do |tag, time, record|
|
56
|
+
messages << record['message']
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
(proxy,proxy_port) = ENV['http_proxy'].split(':')
|
61
|
+
http = Net::HTTP::Proxy(proxy,proxy_port).new(@host, @port.to_i)
|
62
|
+
http.use_ssl = true
|
63
|
+
http.verify_mode = @verify_ssl ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
|
64
|
+
http.set_debug_output $stderr
|
65
|
+
|
66
|
+
request = Net::HTTP::Post.new(@path)
|
67
|
+
request.body = messages.join("\n")
|
68
|
+
response = http.request(request)
|
69
|
+
unless response.is_a?(Net::HTTPSuccess)
|
70
|
+
raise "Failed to send data to #{@host}. #{response.code} #{response.message}"
|
71
|
+
end
|
72
|
+
end
|
73
|
+
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,100 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: fluent-plugin-sumologic-2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- memorycraft
|
8
|
+
- adambom
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2016-10-19 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
|
+
- adam.savitzky@gmail.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/memorycraft/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
|
93
|
+
rubygems_version: 2.5.1
|
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
|