fluent-plugin-archagent 0.1.0 → 0.1.1

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: c8d4bc1d6fb2199551bf48ffd48914441fb00742
4
- data.tar.gz: dfa58103ce087c95edfe454fcf65c95cf3d7aa58
3
+ metadata.gz: 546c5a6ad8db55c14e830f9630cfe690b243409b
4
+ data.tar.gz: ef30d7d2bcfdc913d03b08d13e21df16ffe8b81d
5
5
  SHA512:
6
- metadata.gz: 3e6e9c1dc0aa3680364b8e2a6d7a079fd60328b1403c227b99fd672e4b8878e0b87720ed01c3913f3102f7519013f41ff960db27f0ca46473c882c1211c73c52
7
- data.tar.gz: c38b70566d66f8753481b85a21c874ce3758bcc1bc73cbbc08c950003d5b3ddd44c26b438e374e453b3e4eff6a7b530fe49d3cdab794e101c1366c71741c7229
6
+ metadata.gz: 271fd165b1236a7758c11a11176dab8e607c3da08b7803f7052280ee5f19d57fe8b1573c361b7747529d971c3971c1f71e8d842ab544edc39cd05412b5aa1bb1
7
+ data.tar.gz: 2e26fa7cb03296cb0d951a90604ca162310e04cbcd31277f5704f021814a2f74599dca04df5d3ae50984a29d6d91a62bca2372da66b7759903785371d87318bf
@@ -3,7 +3,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = "fluent-plugin-archagent"
6
- spec.version = "0.1.0"
6
+ spec.version = "0.1.1"
7
7
  spec.authors = ["apoorv"]
8
8
  spec.email = ["apoorv@archsaber.com"]
9
9
 
@@ -1,99 +1,93 @@
1
- require "fluent/plugin/output"
1
+ module Fluent::Plugin
2
+ class ArchagentOutput < Fluent::BufferedOutput
3
+ Fluent::Plugin.register_output("archagent", self)
4
+
5
+ def initialize
6
+ super
7
+ require 'net/http'
8
+ require 'uri'
9
+ end
2
10
 
3
- module Fluent
4
- module Plugin
5
- class ArchagentOutput < Fluent::BufferedOutput
6
- Fluent::Plugin.register_output("archagent", self)
7
- end
11
+ # Archagent port for listening to logs from apache. This should be same as the one specified
12
+ # in data.json for archagent
13
+ config_param :port, :string, default: '8018'
8
14
 
9
- def initialize
10
- super
11
- require 'net/http'
12
- require 'uri'
13
- end
15
+ # read timeout for the http call
16
+ config_param :http_read_timeout, :float, default: 2.0
14
17
 
15
- # Archagent port for listening to logs from apache. This should be same as the one specified
16
- # in data.json for archagent
17
- config_param :port, :string
18
+ # open timeout for the http call
19
+ config_param :http_open_timeout, :float, default: 2.0
18
20
 
19
- # read timeout for the http call
20
- config_param :http_read_timeout, :float, default: 2.0
21
+ def configure(conf)
22
+ super
21
23
 
22
- # open timeout for the http call
23
- config_param :http_open_timeout, :float, default: 2.0
24
+ endpoint_url = 'http://localhost:' + @port
25
+ # Check if endpoint URL is valid
26
+ unless endpoint_url =~ /^#{URI.regexp}$/
27
+ fail Fluent::ConfigError, 'port invalid'
28
+ end
24
29
 
25
- def configure(conf)
26
- super
30
+ begin
31
+ @uri = URI.parse(endpoint_url)
32
+ rescue URI::InvalidURIError
33
+ raise Fluent::ConfigError, 'port invalid'
34
+ end
27
35
 
28
- endpoint_url = 'localhost:' + @port
29
- # Check if endpoint URL is valid
30
- unless endpoint_url =~ /^#{URI.regexp}$/
31
- fail Fluent::ConfigError, 'port invalid'
32
- end
36
+ @http = Net::HTTP.new(@uri.host, @uri.port)
37
+ @http.read_timeout = @http_read_timeout
38
+ @http.open_timeout = @http_open_timeout
39
+ end
33
40
 
34
- begin
35
- @uri = URI.parse(endpoint_url)
36
- rescue URI::InvalidURIError
37
- raise Fluent::ConfigError, 'port invalid'
38
- end
41
+ def format(tag, time, record)
42
+ [tag, time, record].to_msgpack
43
+ end
39
44
 
40
- @http = Net::HTTP.new(@uri.host, @uri.port)
41
- @http.read_timeout = @http_read_timeout
42
- @http.open_timeout = @http_open_timeout
43
- end
45
+ def start
46
+ super
47
+ end
44
48
 
45
- def format(tag, time, record)
46
- [tag, time, record].to_msgpack
49
+ def shutdown
50
+ super
51
+ begin
52
+ @http.finish
53
+ rescue
47
54
  end
55
+ end
48
56
 
49
- def start
50
- super
57
+ def write(chunk)
58
+ data = []
59
+ chunk.msgpack_each do |(tag, time, record)|
60
+ data << record
51
61
  end
62
+ request = create_request(data)
52
63
 
53
- def shutdown
54
- super
64
+ begin
65
+ response = @http.start do |http|
66
+ request = create_request(data)
67
+ http.request request
68
+ end
69
+ rescue IOError, EOFError, SystemCallError => e
70
+ # server didn't respond
71
+ $log.warn "Net::HTTP.#{request.method.capitalize} raises exception: #{e.class}, '#{e.message}'"
72
+ ensure
55
73
  begin
56
74
  @http.finish
57
75
  rescue
58
76
  end
59
77
  end
78
+ end
60
79
 
61
- def write(chunk)
62
- data = []
63
- chunk.msgpack_each do |(tag, time, record)|
64
- data << [tag, time, record]
65
- end
66
-
67
- request = create_request(data)
68
-
69
- begin
70
- response = @http.start do |http|
71
- request = create_request(data)
72
- http.request request
73
- end
74
- rescue IOError, EOFError, SystemCallError => e
75
- # server didn't respond
76
- $log.warn "Net::HTTP.#{request.method.capitalize} raises exception: #{e.class}, '#{e.message}'"
77
- ensure
78
- begin
79
- @http.finish
80
- rescue
81
- end
82
- end
83
- end
84
-
85
- protected
86
-
87
- def create_request(data)
88
- request = Net::HTTP::Post.new(@uri.request_uri)
80
+ protected
89
81
 
90
- # Headers
91
- request['Content-Type'] = 'application/json'
82
+ def create_request(data)
83
+ request = Net::HTTP::Post.new(@uri.request_uri)
92
84
 
93
- # Body
94
- request.body = JSON.dump(data)
85
+ # Headers
86
+ request['Content-Type'] = 'application/json'
95
87
 
96
- request
97
- end
88
+ # Body
89
+ request.body = JSON.dump(data)
90
+ request
98
91
  end
99
92
  end
93
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-archagent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - apoorv
@@ -83,6 +83,7 @@ files:
83
83
  - LICENSE
84
84
  - README.md
85
85
  - Rakefile
86
+ - fluent-plugin-archagent-0.1.0.gem
86
87
  - fluent-plugin-archagent.gemspec
87
88
  - lib/fluent/plugin/out_archagent.rb
88
89
  - test/helper.rb