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 +4 -4
- data/fluent-plugin-archagent-0.1.0.gem +0 -0
- data/fluent-plugin-archagent.gemspec +1 -1
- data/lib/fluent/plugin/out_archagent.rb +68 -74
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 546c5a6ad8db55c14e830f9630cfe690b243409b
|
4
|
+
data.tar.gz: ef30d7d2bcfdc913d03b08d13e21df16ffe8b81d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 271fd165b1236a7758c11a11176dab8e607c3da08b7803f7052280ee5f19d57fe8b1573c361b7747529d971c3971c1f71e8d842ab544edc39cd05412b5aa1bb1
|
7
|
+
data.tar.gz: 2e26fa7cb03296cb0d951a90604ca162310e04cbcd31277f5704f021814a2f74599dca04df5d3ae50984a29d6d91a62bca2372da66b7759903785371d87318bf
|
Binary file
|
@@ -1,99 +1,93 @@
|
|
1
|
-
|
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
|
-
|
4
|
-
|
5
|
-
|
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
|
-
|
10
|
-
|
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
|
-
|
16
|
-
|
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
|
-
|
20
|
-
|
21
|
+
def configure(conf)
|
22
|
+
super
|
21
23
|
|
22
|
-
|
23
|
-
|
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
|
-
|
26
|
-
|
30
|
+
begin
|
31
|
+
@uri = URI.parse(endpoint_url)
|
32
|
+
rescue URI::InvalidURIError
|
33
|
+
raise Fluent::ConfigError, 'port invalid'
|
34
|
+
end
|
27
35
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
-
|
35
|
-
|
36
|
-
|
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
|
-
|
41
|
-
|
42
|
-
|
43
|
-
end
|
45
|
+
def start
|
46
|
+
super
|
47
|
+
end
|
44
48
|
|
45
|
-
|
46
|
-
|
49
|
+
def shutdown
|
50
|
+
super
|
51
|
+
begin
|
52
|
+
@http.finish
|
53
|
+
rescue
|
47
54
|
end
|
55
|
+
end
|
48
56
|
|
49
|
-
|
50
|
-
|
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
|
-
|
54
|
-
|
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
|
-
|
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
|
-
|
91
|
-
|
82
|
+
def create_request(data)
|
83
|
+
request = Net::HTTP::Post.new(@uri.request_uri)
|
92
84
|
|
93
|
-
|
94
|
-
|
85
|
+
# Headers
|
86
|
+
request['Content-Type'] = 'application/json'
|
95
87
|
|
96
|
-
|
97
|
-
|
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.
|
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
|