fluent-plugin-sumologic 0.0.1 → 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ba1f469b697642b44ecde173e50202ecd86dacf7
4
+ data.tar.gz: 06203c200752f7df9c3e17f767b361867d9aa73d
5
+ SHA512:
6
+ metadata.gz: 1dfe9f890cbd119eb420fbd3e3e657f5d8cd75e3d3758a284e43de9eac1da58ac3743deedfec78a3e2a0c3b9d24b237bf7479e09235a0c215f5e4588aedf182e
7
+ data.tar.gz: 4bb26f011833c1e965957cded02f2e3d1c65c6df3c4163344e4a2c007854d6a82836422aa559a8ae49b1d27df9cf6e00c9ab10f3061d57957ec056060679794c
data/README.md CHANGED
@@ -1,6 +1,12 @@
1
- # Fluent::Plugin::Sumologic
1
+ # Fluent::Plugin::Sumologic, a plugin for [Fluentd](http://fluentd.org)
2
2
 
3
- TODO: Write a gem description
3
+ fluent output plugin for Sumologic
4
+
5
+ ## Fluentd
6
+ http://fluentd.org/
7
+
8
+ ## Sumologic
9
+ http://www.sumologic.com/
4
10
 
5
11
  ## Installation
6
12
 
@@ -18,20 +24,34 @@ Or install it yourself as:
18
24
 
19
25
  ## Usage
20
26
 
21
- <match *.apache.*>
22
- type sumologic
23
- host collectors.sumologic.com
24
- port 443
25
- format json|text
26
- path /receiver/v1/http/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX==
27
- </match>
28
-
29
- type: sumologic
30
- host: hostname of HTTP Collectors URL
31
- port: port of HTTP Collectors URL
32
- path: path of HTTP Collectors URL
33
- format: json - send as json format in fluent way
34
- text - send as raw text format (ex: using "parse using public/apache/access")
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.
35
55
 
36
56
  ## Contributing
37
57
 
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "fluent-plugin-sumologic"
7
- spec.version = "0.0.1"
7
+ spec.version = "0.0.2"
8
8
  spec.authors = ["memorycraft"]
9
9
  spec.email = ["memorycraft@gmail.com"]
10
10
  spec.description = %q{fluent plugin for sumologic}
@@ -5,10 +5,18 @@ require 'date'
5
5
  class Fluent::SumologicOutput< Fluent::BufferedOutput
6
6
  Fluent::Plugin.register_output('sumologic', self)
7
7
 
8
- config_param :host, :string, :default => 'localhost'
9
- config_param :port, :integer, :default => 9200
10
- config_param :path, :string, :default => '/'
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'
11
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
12
20
 
13
21
  def initialize
14
22
  super
@@ -31,26 +39,44 @@ class Fluent::SumologicOutput< Fluent::BufferedOutput
31
39
  end
32
40
 
33
41
  def write(chunk)
34
- messages = []
35
-
42
+ messages_list = {}
43
+
36
44
  case @format
37
45
  when 'json'
38
46
  chunk.msgpack_each do |tag, time, record|
39
- messages << record.to_json
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
40
57
  end
41
58
  when 'text'
42
59
  chunk.msgpack_each do |tag, time, record|
43
- messages << record['message']
60
+ source_name = record[@source_name_key] || ''
61
+ messages_list[source_name] = [] unless messages_list[source_name]
62
+ messages_list[source_name] << record['message']
44
63
  end
45
64
  end
46
65
 
47
- http = Net::HTTP.new(@host, @port.to_i)
66
+ (proxy,proxy_port) = ENV['http_proxy'].split(':')
67
+ http = Net::HTTP::Proxy(proxy,proxy_port).new(@host, @port.to_i)
48
68
  http.use_ssl = true
49
- http.verify_mode = OpenSSL::SSL::VERIFY_NONE
69
+ http.verify_mode = @verify_ssl ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
50
70
  http.set_debug_output $stderr
51
71
 
52
- request = Net::HTTP::Post.new(@path)
53
- request.body = messages.join("\n")
54
- http.request(request)
72
+ messages_list.each do |source_name, messages|
73
+ request = Net::HTTP::Post.new(@path)
74
+ request['X-Sumo-Name'] = source_name unless source_name.empty?
75
+ request.body = messages.join("\n")
76
+ response = http.request(request)
77
+ unless response.is_a?(Net::HTTPSuccess)
78
+ raise "Failed to send data to #{@host}. #{response.code} #{response.message}"
79
+ end
80
+ end
55
81
  end
56
82
  end
metadata CHANGED
@@ -1,62 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-sumologic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
5
- prerelease:
4
+ version: 0.0.2
6
5
  platform: ruby
7
6
  authors:
8
7
  - memorycraft
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-04-30 00:00:00.000000000 Z
11
+ date: 2016-02-13 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: bundler
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ~>
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
19
  version: '1.3'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ~>
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
26
  version: '1.3'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rake
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: fluentd
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :runtime
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  description: fluent plugin for sumologic
@@ -66,7 +59,7 @@ executables: []
66
59
  extensions: []
67
60
  extra_rdoc_files: []
68
61
  files:
69
- - .gitignore
62
+ - ".gitignore"
70
63
  - Gemfile
71
64
  - LICENSE.txt
72
65
  - README.md
@@ -78,27 +71,26 @@ files:
78
71
  homepage: https://github.com/memorycraft/fluent-plugin-sumologic
79
72
  licenses:
80
73
  - MIT
74
+ metadata: {}
81
75
  post_install_message:
82
76
  rdoc_options: []
83
77
  require_paths:
84
78
  - lib
85
79
  required_ruby_version: !ruby/object:Gem::Requirement
86
- none: false
87
80
  requirements:
88
- - - ! '>='
81
+ - - ">="
89
82
  - !ruby/object:Gem::Version
90
83
  version: '0'
91
84
  required_rubygems_version: !ruby/object:Gem::Requirement
92
- none: false
93
85
  requirements:
94
- - - ! '>='
86
+ - - ">="
95
87
  - !ruby/object:Gem::Version
96
88
  version: '0'
97
89
  requirements: []
98
90
  rubyforge_project: fluent-plugin-sumologic
99
- rubygems_version: 1.8.23
91
+ rubygems_version: 2.5.1
100
92
  signing_key:
101
- specification_version: 3
93
+ specification_version: 4
102
94
  summary: sumologic is log management system. this plugin is fluent output plugin send
103
95
  to sumologic
104
96
  test_files: