fluent-plugin-sumologic-2 0.0.3 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3a0d22cc698ba1932b5d74ec24824fdf547339aa
4
- data.tar.gz: 1df9814f11b40bb36dcd3c7583ccdba21714d26d
3
+ metadata.gz: 46bda3c26972498aa9a0d588d27e7f264671fd6a
4
+ data.tar.gz: d0b031550a259f7f0b70f87fd2b5a53bdb552acd
5
5
  SHA512:
6
- metadata.gz: ea8dd91736984ed3c98b49c054de45366819052523fb1e341ff75bf8cc12e902ce8c6eb79709948caf0cfd0212fcd56c192f32ccb7ac9f643063b8765644ac6d
7
- data.tar.gz: 9b2c53f159d92e16be11f3f819075a1efea1ac9e91d39326b573038afddafd1cdc4d6d3838b04bb249cab0eed626a2d99dd7962cd1ba8cad21ffe16bac12cf2c
6
+ metadata.gz: ec0540de56be46e14d27c4f6cdcbc49346ea2adc2ffd6f6903a7caf8357cf20de9c25d66dd86a303685d191dbba25b7e8fdab18e2d9992a7cce1aebe1171affe
7
+ data.tar.gz: df41c4874aedc355c2fc7365c8bb252d7a35e2027b9dfc4295c2d8bdc9c225203287928618ff8fb00d40f963ef7bafd6b9cdf495098b9bfa07ebc15841801a5f
data/README.md CHANGED
@@ -29,6 +29,7 @@ Or install it yourself as:
29
29
  type sumologic
30
30
  host collectors.sumologic.com
31
31
  port 443
32
+ proxy 10.0.0.1:3128
32
33
  format json|text
33
34
  path /receiver/v1/http/XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX==
34
35
  </match>
@@ -43,6 +44,9 @@ Or install it yourself as:
43
44
  #### port
44
45
  - Port of HTTP Collectors URL
45
46
 
47
+ #### proxy
48
+ - HTTP proxy address including port
49
+
46
50
  #### path
47
51
  - Path of HTTP Collectors URL
48
52
 
@@ -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-2"
7
- spec.version = "0.0.3"
7
+ spec.version = "0.0.4"
8
8
  spec.authors = ["memorycraft", "adambom"]
9
9
  spec.email = ["memorycraft@gmail.com", "adam.savitzky@gmail.com"]
10
10
  spec.description = %q{fluent plugin for sumologic}
@@ -7,9 +7,11 @@ class Fluent::SumologicOutput< Fluent::BufferedOutput
7
7
 
8
8
  config_param :host, :string, :default => 'collectors.sumologic.com'
9
9
  config_param :port, :integer, :default => 443
10
+ config_param :proxy, :string, :default => nil
10
11
  config_param :verify_ssl, :bool, :default => true
11
12
  config_param :path, :string, :default => '/receiver/v1/http/XXX'
12
13
  config_param :format, :string, :default => 'json'
14
+ config_param :source_name_key, :string, :default => ''
13
15
 
14
16
  include Fluent::SetTagKeyMixin
15
17
  config_set_default :include_tag_key, false
@@ -38,8 +40,8 @@ class Fluent::SumologicOutput< Fluent::BufferedOutput
38
40
  end
39
41
 
40
42
  def write(chunk)
41
- messages = []
42
-
43
+ messages_list = {}
44
+
43
45
  case @format
44
46
  when 'json'
45
47
  chunk.msgpack_each do |tag, time, record|
@@ -49,25 +51,37 @@ class Fluent::SumologicOutput< Fluent::BufferedOutput
49
51
  if @include_time_key
50
52
  record.merge!(@time_key => @timef.format(time))
51
53
  end
52
- messages << record.to_json
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
53
58
  end
54
59
  when 'text'
55
60
  chunk.msgpack_each do |tag, time, record|
56
- messages << record['message']
61
+ source_name = record[@source_name_key] || ''
62
+ messages_list[source_name] = [] unless messages_list[source_name]
63
+ messages_list[source_name] << record['message']
57
64
  end
58
65
  end
59
66
 
60
- (proxy,proxy_port) = ENV['http_proxy'].split(':')
61
- http = Net::HTTP::Proxy(proxy,proxy_port).new(@host, @port.to_i)
67
+ http = Net::HTTP.new(@host, @port.to_i)
68
+ proxy_string = if ENV['http_proxy'] then ENV['http_proxy'] else @proxy end
69
+ if(proxy_string){
70
+ (proxy,proxy_port) = proxy_string.split(':')
71
+ http = Net::HTTP::Proxy(proxy,proxy_port).new(@host, @port.to_i)
72
+ }
62
73
  http.use_ssl = true
63
74
  http.verify_mode = @verify_ssl ? OpenSSL::SSL::VERIFY_PEER : OpenSSL::SSL::VERIFY_NONE
64
75
  http.set_debug_output $stderr
65
76
 
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
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
72
86
  end
73
87
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-sumologic-2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - memorycraft