fluent-plugin-http 0.2.0 → 0.3.0
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/lib/fluent/plugin/http/error.rb +1 -1
- data/lib/fluent/plugin/out_http.rb +21 -12
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a05bb6dde35957eb0441bae8de152a7388a6b109
|
4
|
+
data.tar.gz: 64da30f0548d530bcdeca791bf3b7921931c7127
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6dc693aae20a9fc985b4d060ad7874e2043dc5be8f2dc0e46e041ee0477eded844f5ef530bbcc9662230b6d896437c593c0c6aee233e23976c5e486d7a8534fc
|
7
|
+
data.tar.gz: 4c27023f556ad1a1750b050c2afc8226e6e32ae7cc3b36741fbea09f9b83d0ede74f6732d98bd4dfb6cb13921c1499f6cdbb4463681041dd42abcbf59a6e612d
|
@@ -4,7 +4,7 @@ module Fluent
|
|
4
4
|
# Unsuccessful response error
|
5
5
|
ResponseError = Class.new(StandardError) do
|
6
6
|
def self.error(request, response)
|
7
|
-
new "Failed to POST event
|
7
|
+
new "Failed to POST event records to #{request.uri} because of " \
|
8
8
|
"unsuccessful response code: #{response.code.inspect} " \
|
9
9
|
"#{response.body.inspect}"
|
10
10
|
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
require 'fluent/output'
|
3
3
|
require 'uri'
|
4
4
|
require 'net/http'
|
5
|
+
require 'json'
|
5
6
|
|
6
7
|
# Fluentd
|
7
8
|
module Fluent
|
@@ -61,32 +62,40 @@ module Fluent
|
|
61
62
|
[tag, time, record].to_msgpack
|
62
63
|
end
|
63
64
|
|
64
|
-
USER_AGENT = 'FluentPluginHTTP'
|
65
|
-
private_constant :USER_AGENT
|
66
|
-
|
67
65
|
# Sends the event records
|
68
66
|
#
|
69
67
|
# @param chunk [#msgpack_each] buffer chunk that includes multiple
|
70
68
|
# formatted events
|
71
69
|
# @return void
|
72
70
|
def write(chunk)
|
73
|
-
|
74
|
-
|
75
|
-
post_record.set_form_data(record)
|
76
|
-
post_record['User-Agent'] = USER_AGENT
|
71
|
+
records = []
|
72
|
+
chunk.msgpack_each { |_tag, _time, record| records << record }
|
77
73
|
|
78
|
-
|
74
|
+
post_records = post_records_request(records)
|
75
|
+
response = http.request(post_records)
|
79
76
|
|
80
|
-
|
81
|
-
|
82
|
-
end
|
83
|
-
end
|
77
|
+
return if accept_status_code.include?(response.code)
|
78
|
+
raise ResponseError.error(post_records, response)
|
84
79
|
end
|
85
80
|
|
86
81
|
private
|
87
82
|
|
88
83
|
attr_reader :http
|
89
84
|
|
85
|
+
JSON_MIME_TYPE = 'application/json'
|
86
|
+
USER_AGENT = 'FluentPluginHTTP'
|
87
|
+
SERIALIZER = JSON
|
88
|
+
|
89
|
+
private_constant :USER_AGENT, :JSON_MIME_TYPE, :SERIALIZER
|
90
|
+
|
91
|
+
def post_records_request(records)
|
92
|
+
Net::HTTP::Post.new(url).tap do |request|
|
93
|
+
request.body = SERIALIZER.dump(records)
|
94
|
+
request.content_type = JSON_MIME_TYPE
|
95
|
+
request['User-Agent'] = USER_AGENT
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
90
99
|
def validate_url(test_url)
|
91
100
|
url = URI(test_url)
|
92
101
|
return url if url.scheme == 'http' || url.scheme == 'https'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Konstantin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -136,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
136
|
version: '0'
|
137
137
|
requirements: []
|
138
138
|
rubyforge_project:
|
139
|
-
rubygems_version: 2.6.
|
139
|
+
rubygems_version: 2.6.8
|
140
140
|
signing_key:
|
141
141
|
specification_version: 4
|
142
142
|
summary: Fluentd output plugin that sends event records via HTTP
|