fluent-plugin-heroku-syslog-http 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +1 -1
- data/{fluent-plugin-heroku-syslog.gemspec → fluent-plugin-heroku-syslog-http.gemspec} +1 -1
- data/lib/fluent/plugin/in_heroku_syslog_http.rb +12 -1
- data/lib/fluent/plugin/parser_heroku_syslog_http.rb +1 -1
- data/test/plugin/test_in_heroku_syslog_http.rb +8 -8
- data/test/plugin/test_parser_heroku_syslog_http.rb +4 -4
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 532357c0144bd00b49441c441a413a1418857f42
|
4
|
+
data.tar.gz: 7d0804f14d7d041736c35d986f8c0db2fd6e34a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fad8aed05a98d60e1e684ea0b9b3e99cdefcd296003a536d910ef0597fe77839b2c01f3fa3a0cfff2322209f6b5143b3d1ca3cde172ffd297d9c06440a1f6e62
|
7
|
+
data.tar.gz: 73df938e9c8a26fc7f53601631d633f5c4e852caf8973dd763f42f9f40b28a92e0c8d6fa173b834c8d561ff064672064903b0f32c027372042ada494fb50ded0
|
data/Gemfile
CHANGED
@@ -18,8 +18,18 @@ module Fluent
|
|
18
18
|
content = params[EVENT_RECORD_PARAMETER]
|
19
19
|
raise "'#{EVENT_RECORD_PARAMETER}' parameter is required" unless content
|
20
20
|
|
21
|
+
messages = []
|
22
|
+
while payload = content.match(/^([0-9]+) (.*)$/) do
|
23
|
+
length = payload[1].to_i
|
24
|
+
raise "Invalid message length specified: #{length}" unless payload[2].size >= length
|
25
|
+
|
26
|
+
messages << payload[2][0...length]
|
27
|
+
content = payload[2][length..-1] || ''
|
28
|
+
end
|
29
|
+
content << content
|
30
|
+
raise "#{content.size} bytes left in payload" unless content.size == 0
|
31
|
+
|
21
32
|
records = []
|
22
|
-
messages = content.split("\n")
|
23
33
|
messages.each do |msg|
|
24
34
|
@parser.parse(msg) do |time, record|
|
25
35
|
raise "Could not parse event: #{content}" if record.nil?
|
@@ -34,6 +44,7 @@ module Fluent
|
|
34
44
|
records << record
|
35
45
|
end
|
36
46
|
end
|
47
|
+
|
37
48
|
[nil, records]
|
38
49
|
end
|
39
50
|
end
|
@@ -8,7 +8,7 @@ module Fluent
|
|
8
8
|
class HerokuSyslogHttpParser < RegexpParser
|
9
9
|
Fluent::Plugin.register_parser('heroku_syslog_http', self)
|
10
10
|
|
11
|
-
SYSLOG_HTTP_REGEXP = %r{
|
11
|
+
SYSLOG_HTTP_REGEXP = %r{^\<(?<syslog.pri>[0-9]+)\>([0-9]+) (?<syslog.timestamp>[^ ]+) (?<syslog.hostname>[^ ]+) (?<syslog.appname>[^ ]+) (?<syslog.procid>[^ ]+) - *(?<message>.*)$}
|
12
12
|
|
13
13
|
FACILITY_MAP = {
|
14
14
|
0 => 'kern',
|
@@ -67,8 +67,8 @@ class HerokuSyslogHttpInputTest < Test::Unit::TestCase
|
|
67
67
|
|
68
68
|
def test_msg_size
|
69
69
|
messages = [
|
70
|
-
'
|
71
|
-
'
|
70
|
+
'156 <13>1 2014-01-01T01:23:45.123456+00:00 host app web.1 - ' + 'x' * 100,
|
71
|
+
'1080 <13>1 2014-01-01T01:23:45.123456+00:00 host app web.1 - ' + 'x' * 1024
|
72
72
|
]
|
73
73
|
|
74
74
|
d = create_driver
|
@@ -83,8 +83,8 @@ class HerokuSyslogHttpInputTest < Test::Unit::TestCase
|
|
83
83
|
|
84
84
|
def test_accept_matched_drain_id_multiple
|
85
85
|
messages = [
|
86
|
-
'
|
87
|
-
'
|
86
|
+
'59 <13>1 2014-01-01T01:23:45.123456+00:00 host app web.1 - foo',
|
87
|
+
'59 <13>1 2014-01-01T01:23:45.123456+00:00 host app web.1 - bar'
|
88
88
|
]
|
89
89
|
d = create_driver(CONFIG + %(
|
90
90
|
drain_ids ["abc", "d.fc6b856b-3332-4546-93de-7d0ee272c3bd"]
|
@@ -99,8 +99,8 @@ class HerokuSyslogHttpInputTest < Test::Unit::TestCase
|
|
99
99
|
|
100
100
|
def test_ignore_unmatched_drain_id
|
101
101
|
messages = [
|
102
|
-
'
|
103
|
-
'
|
102
|
+
'59 <13>1 2014-01-01T01:23:45.123456+00:00 host app web.1 - foo',
|
103
|
+
'59 <13>1 2014-01-01T01:23:45.123456+00:00 host app web.1 - bar'
|
104
104
|
]
|
105
105
|
d = create_driver(CONFIG + %(
|
106
106
|
drain_ids ["abc"]
|
@@ -115,7 +115,7 @@ class HerokuSyslogHttpInputTest < Test::Unit::TestCase
|
|
115
115
|
|
116
116
|
def test_logplex_metas
|
117
117
|
messages = [
|
118
|
-
'
|
118
|
+
'156 <13>1 2014-01-01T01:23:45.123456+00:00 host app web.1 - ' + 'x' * 100
|
119
119
|
]
|
120
120
|
d = create_driver
|
121
121
|
d.run(expect_records: 1, timeout: 5) do
|
@@ -138,7 +138,7 @@ class HerokuSyslogHttpInputTest < Test::Unit::TestCase
|
|
138
138
|
'User-Agent' => 'Logplex/v49'
|
139
139
|
}
|
140
140
|
req = Net::HTTP::Post.new('/heroku', headers)
|
141
|
-
req.body = messages.join(
|
141
|
+
req.body = messages.join('')
|
142
142
|
http.request(req)
|
143
143
|
end
|
144
144
|
end
|
@@ -30,7 +30,7 @@ class HerokuSyslogHttpParseTest < Test::Unit::TestCase
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def test_parsing_with_default_conf
|
33
|
-
text = '
|
33
|
+
text = '<13>1 2014-01-29T06:25:52.589365+00:00 host app web.1 - foo'
|
34
34
|
expected_time = Time.strptime('2014-01-29T07:25:52+01:00', '%Y-%m-%dT%H:%M:%S%z').to_i
|
35
35
|
event = {
|
36
36
|
'syslog.pri' => '13',
|
@@ -52,15 +52,15 @@ class HerokuSyslogHttpParseTest < Test::Unit::TestCase
|
|
52
52
|
def test_parsing_pri_conf
|
53
53
|
d = create_driver
|
54
54
|
|
55
|
-
d.instance.parse('
|
55
|
+
d.instance.parse('<13>1 2014-01-29T06:25:52.589365+00:00 host app web.1 - foo') do |_, record|
|
56
56
|
assert_equal 'notice', record['syslog.severity']
|
57
57
|
assert_equal 'user', record['syslog.facility']
|
58
58
|
end
|
59
|
-
d.instance.parse('
|
59
|
+
d.instance.parse('<42>1 2014-01-29T06:25:52.589365+00:00 host app web.1 - foo') do |_, record|
|
60
60
|
assert_equal 'crit', record['syslog.severity']
|
61
61
|
assert_equal 'syslog', record['syslog.facility']
|
62
62
|
end
|
63
|
-
d.instance.parse('
|
63
|
+
d.instance.parse('<27>1 2014-01-29T06:25:52.589365+00:00 host app web.1 - foo') do |_, record|
|
64
64
|
assert_equal 'err', record['syslog.severity']
|
65
65
|
assert_equal 'daemon', record['syslog.facility']
|
66
66
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-heroku-syslog-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Drivy
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2019-08-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: fluentd
|
@@ -67,7 +67,7 @@ files:
|
|
67
67
|
- LICENSE.txt
|
68
68
|
- README.md
|
69
69
|
- Rakefile
|
70
|
-
- fluent-plugin-heroku-syslog.gemspec
|
70
|
+
- fluent-plugin-heroku-syslog-http.gemspec
|
71
71
|
- lib/fluent/plugin/in_heroku_syslog_http.rb
|
72
72
|
- lib/fluent/plugin/parser_heroku_syslog_http.rb
|
73
73
|
- test/helper.rb
|
@@ -93,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
93
|
version: '0'
|
94
94
|
requirements: []
|
95
95
|
rubyforge_project:
|
96
|
-
rubygems_version: 2.
|
96
|
+
rubygems_version: 2.5.2.3
|
97
97
|
signing_key:
|
98
98
|
specification_version: 4
|
99
99
|
summary: fluent plugin to drain heroku syslog
|