fluent-plugin-light-core 0.2.2 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/Gemfile +3 -1
- data/Gemfile.lock +50 -15
- data/fluent-plugin-light-core.gemspec +4 -3
- data/lib/fluent/plugin/filter_light_core.rb +30 -64
- data/sample/README.md +5 -0
- metadata +29 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa263e49f613865247d281b1bb9f5cd65df261da7047466a11c428d77742f4c2
|
4
|
+
data.tar.gz: 763f163046a38dca3a9341bfdcc36a18a1da34a9fa9bc78933983ba7c2c955ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ed1cb6b3a76b067dd3734bc9fa446211e6b4e3fbb2abf179327f18b47f88ca8c6dc5c5fe23711872b3a40fbd471bfe193363469fc10b37ffa63bb0329886ad15
|
7
|
+
data.tar.gz: 950534c7d8bc3c443eb442e6d3d6bcf0a81c0cd7c66f6ef94dc55122587ca2e31aecd9df4e4303133d51aeb041c1cdbdd60b904c12ba3054df2e9d408f834a95
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,38 +1,71 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
fluent-plugin-light-core (0.
|
5
|
-
fluentd (>=
|
4
|
+
fluent-plugin-light-core (0.2.3)
|
5
|
+
fluentd (>= 1.14.2, < 2)
|
6
|
+
sentry-ruby (>= 4.8.0, < 5)
|
6
7
|
|
7
8
|
GEM
|
8
9
|
remote: https://rubygems.org/
|
9
10
|
specs:
|
10
|
-
|
11
|
-
|
11
|
+
concurrent-ruby (1.1.9)
|
12
|
+
cool.io (1.7.1)
|
13
|
+
faraday (1.8.0)
|
14
|
+
faraday-em_http (~> 1.0)
|
15
|
+
faraday-em_synchrony (~> 1.0)
|
16
|
+
faraday-excon (~> 1.1)
|
17
|
+
faraday-httpclient (~> 1.0.1)
|
18
|
+
faraday-net_http (~> 1.0)
|
19
|
+
faraday-net_http_persistent (~> 1.1)
|
20
|
+
faraday-patron (~> 1.0)
|
21
|
+
faraday-rack (~> 1.0)
|
22
|
+
multipart-post (>= 1.2, < 3)
|
23
|
+
ruby2_keywords (>= 0.0.4)
|
24
|
+
faraday-em_http (1.0.0)
|
25
|
+
faraday-em_synchrony (1.0.0)
|
26
|
+
faraday-excon (1.1.0)
|
27
|
+
faraday-httpclient (1.0.1)
|
28
|
+
faraday-net_http (1.0.1)
|
29
|
+
faraday-net_http_persistent (1.2.0)
|
30
|
+
faraday-patron (1.0.0)
|
31
|
+
faraday-rack (1.0.0)
|
32
|
+
fluentd (1.14.2)
|
33
|
+
bundler
|
12
34
|
cool.io (>= 1.4.5, < 2.0.0)
|
13
|
-
http_parser.rb (>= 0.5.1, < 0.
|
35
|
+
http_parser.rb (>= 0.5.1, < 0.8.0)
|
14
36
|
msgpack (>= 1.3.1, < 2.0.0)
|
15
|
-
serverengine (>= 2.
|
37
|
+
serverengine (>= 2.2.2, < 3.0.0)
|
16
38
|
sigdump (~> 0.2.2)
|
17
|
-
strptime (>= 0.2.
|
39
|
+
strptime (>= 0.2.4, < 1.0.0)
|
18
40
|
tzinfo (>= 1.0, < 3.0)
|
19
41
|
tzinfo-data (~> 1.0)
|
42
|
+
webrick (>= 1.4.2, < 1.8.0)
|
20
43
|
yajl-ruby (~> 1.0)
|
21
|
-
http_parser.rb (0.
|
22
|
-
msgpack (1.
|
44
|
+
http_parser.rb (0.7.0)
|
45
|
+
msgpack (1.4.2)
|
46
|
+
multipart-post (2.1.1)
|
47
|
+
oj (3.13.9)
|
23
48
|
power_assert (1.1.3)
|
24
49
|
rake (12.3.2)
|
25
|
-
|
50
|
+
ruby2_keywords (0.0.5)
|
51
|
+
sentry-ruby (4.8.0)
|
52
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
53
|
+
faraday (>= 1.0)
|
54
|
+
sentry-ruby-core (= 4.8.0)
|
55
|
+
sentry-ruby-core (4.8.0)
|
56
|
+
concurrent-ruby
|
57
|
+
faraday
|
58
|
+
serverengine (2.2.4)
|
26
59
|
sigdump (~> 0.2.2)
|
27
60
|
sigdump (0.2.4)
|
28
|
-
strptime (0.2.
|
61
|
+
strptime (0.2.5)
|
29
62
|
test-unit (3.2.9)
|
30
63
|
power_assert
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
tzinfo-data (1.2020.1)
|
64
|
+
tzinfo (2.0.4)
|
65
|
+
concurrent-ruby (~> 1.0)
|
66
|
+
tzinfo-data (1.2021.5)
|
35
67
|
tzinfo (>= 1.0.0)
|
68
|
+
webrick (1.7.0)
|
36
69
|
yajl-ruby (1.4.1)
|
37
70
|
|
38
71
|
PLATFORMS
|
@@ -41,7 +74,9 @@ PLATFORMS
|
|
41
74
|
DEPENDENCIES
|
42
75
|
bundler (~> 1.14)
|
43
76
|
fluent-plugin-light-core!
|
77
|
+
oj (~> 3.13)
|
44
78
|
rake (~> 12.0)
|
79
|
+
sentry-ruby
|
45
80
|
test-unit (~> 3.0)
|
46
81
|
|
47
82
|
BUNDLED WITH
|
@@ -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-light-core"
|
6
|
-
spec.version = "0.2.
|
6
|
+
spec.version = "0.2.6"
|
7
7
|
spec.authors = ["LIN LI"]
|
8
8
|
spec.email = ["l.li@alphabets.cn"]
|
9
9
|
|
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
|
|
23
23
|
spec.add_development_dependency "bundler", "~> 1.14"
|
24
24
|
spec.add_development_dependency "rake", "~> 12.0"
|
25
25
|
spec.add_development_dependency "test-unit", "~> 3.0"
|
26
|
-
spec.add_runtime_dependency "fluentd", [">=
|
27
|
-
spec.add_runtime_dependency "sentry-ruby", [">= 4.
|
26
|
+
spec.add_runtime_dependency "fluentd", [">= 1.14.2", "< 2"]
|
27
|
+
spec.add_runtime_dependency "sentry-ruby", [">= 4.8.0", "< 5"]
|
28
|
+
spec.add_runtime_dependency "oj", [">= 3.13", "< 4"]
|
28
29
|
end
|
@@ -131,9 +131,9 @@ module Fluent
|
|
131
131
|
record['method'] = item[:method]
|
132
132
|
record['url'] = item[:url]
|
133
133
|
record['status'] = item[:status]
|
134
|
-
record['size'] =
|
134
|
+
record['size'] = str_to_num(item[:size])
|
135
135
|
record['uid'] = item[:uid]
|
136
|
-
record['elapsed'] =
|
136
|
+
record['elapsed'] = str_to_num(item[:elapsed])
|
137
137
|
record['addr'] = item[:addr].gsub(/\n$/, '')
|
138
138
|
|
139
139
|
return record
|
@@ -170,10 +170,10 @@ module Fluent
|
|
170
170
|
record['method'] = item[:method]
|
171
171
|
record['path'] = item[:path]
|
172
172
|
record['code'] = item[:code]
|
173
|
-
record['size'] =
|
173
|
+
record['size'] = str_to_num(item[:size])
|
174
174
|
record['referer'] = item[:referer]
|
175
175
|
record['agent'] = item[:agent]
|
176
|
-
record['elapsed'] =
|
176
|
+
record['elapsed'] = str_to_num(item[:elapsed])
|
177
177
|
record['requestid'] = item[:requestid]
|
178
178
|
record['sessionid'] = item[:sessionid]
|
179
179
|
|
@@ -184,7 +184,7 @@ module Fluent
|
|
184
184
|
if /^\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2} \[error\]/.match(log)
|
185
185
|
item = /^(?<time>[^ ]+ [^ ]+) \[(?<level>.*)\] (?<pid>\d*)#(?<tid>[^:]*): \*(?<cid>\d*) (?<message>.*)$/.match(log)
|
186
186
|
|
187
|
-
record['time'] =
|
187
|
+
record['time'] = record['ctime']
|
188
188
|
record['level'] = item[:level]
|
189
189
|
record['message'] = item[:message]
|
190
190
|
record['process'] = item[:pid] # process id
|
@@ -225,61 +225,26 @@ module Fluent
|
|
225
225
|
record.delete('file')
|
226
226
|
record.delete('time')
|
227
227
|
|
228
|
-
#
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
if item[:querytime]
|
244
|
-
record['querytime'] = format_str(item[:querytime])
|
245
|
-
end
|
246
|
-
|
247
|
-
if item[:query]
|
248
|
-
record['command'] = item[:query]
|
249
|
-
query = /^command\s* (?<collection>[^ ]*) (?<command>.*)$/.match(item[:query])
|
250
|
-
unless query.nil?
|
251
|
-
record['collection'] = query[:collection]
|
252
|
-
record['command'] = query[:command]
|
253
|
-
end
|
254
|
-
end
|
255
|
-
|
256
|
-
return record
|
257
|
-
else
|
258
|
-
|
259
|
-
# 版本4.4开始,默认日志为json格式
|
260
|
-
item = JSON.parse(log)
|
261
|
-
record['time'] = item['t']['$date']
|
262
|
-
record['severity'] = item['s']
|
263
|
-
record['component'] = item['c']
|
264
|
-
record['context'] = item['ctx']
|
265
|
-
record['identifier'] = item['id']
|
266
|
-
record['message'] = item['msg']
|
267
|
-
|
268
|
-
attributes = item['attr']
|
269
|
-
if attributes
|
270
|
-
record['querytime'] = attributes['durationMillis']
|
271
|
-
record['collection'] = attributes['ns']
|
272
|
-
record['command'] = attributes['command']
|
273
|
-
record['attr'] = attributes
|
274
|
-
end
|
275
|
-
|
276
|
-
record['tags'] = item['tags']
|
277
|
-
record['truncated'] = item['truncated']
|
278
|
-
record['size'] = item['size']
|
279
|
-
|
280
|
-
return record
|
228
|
+
# 版本4.4开始,默认日志为json格式
|
229
|
+
item = JSON.parse(log)
|
230
|
+
record['time'] = item['t']['$date']
|
231
|
+
record['severity'] = item['s']
|
232
|
+
record['component'] = item['c']
|
233
|
+
record['context'] = item['ctx']
|
234
|
+
record['identifier'] = item['id']
|
235
|
+
record['message'] = item['msg']
|
236
|
+
|
237
|
+
attributes = item['attr']
|
238
|
+
if attributes
|
239
|
+
record['querytime'] = attributes['durationMillis']
|
240
|
+
record['collection'] = attributes['ns']
|
241
|
+
record['command'] = attributes['command']
|
242
|
+
record['attr'] = attributes
|
281
243
|
end
|
282
244
|
|
245
|
+
record['tags'] = item['tags']
|
246
|
+
record['truncated'] = item['truncated']
|
247
|
+
record['size'] = item['size']
|
283
248
|
record
|
284
249
|
end
|
285
250
|
|
@@ -292,16 +257,15 @@ module Fluent
|
|
292
257
|
|
293
258
|
if tag == 'app'
|
294
259
|
|
295
|
-
# 未使用
|
296
260
|
if @app_stream && record['stream']
|
297
|
-
|
261
|
+
message = 'Stream error' + record['stream']
|
262
|
+
send(tag, message, record) if record['stream'] == @app_stream
|
298
263
|
end
|
299
264
|
|
300
|
-
# 未使用
|
301
265
|
if @app_message.length > 0 && record['message']
|
302
266
|
@app_message.each do |pattern|
|
303
267
|
if pattern.match(record['message'])
|
304
|
-
send(record)
|
268
|
+
send(tag, record['message'], record)
|
305
269
|
break
|
306
270
|
end
|
307
271
|
end
|
@@ -365,11 +329,13 @@ module Fluent
|
|
365
329
|
# 发送UDP请求
|
366
330
|
def send(tag, message, record)
|
367
331
|
log.debug('send udp notice')
|
368
|
-
|
332
|
+
log.info(message)
|
333
|
+
# Sentry.capture_message(message, :extra => record, :tags => {'log' => tag})
|
369
334
|
end
|
370
335
|
|
371
336
|
# 转数字
|
372
|
-
def
|
337
|
+
def str_to_num(str)
|
338
|
+
return 0 if (str == '-')
|
373
339
|
return str.to_i if (str =~ /^\d+$/)
|
374
340
|
return str.to_f if (str =~ /^\d+\.\d+$/)
|
375
341
|
str
|
data/sample/README.md
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-light-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LIN LI
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,7 +58,7 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 1.14.2
|
62
62
|
- - "<"
|
63
63
|
- !ruby/object:Gem::Version
|
64
64
|
version: '2'
|
@@ -68,7 +68,7 @@ dependencies:
|
|
68
68
|
requirements:
|
69
69
|
- - ">="
|
70
70
|
- !ruby/object:Gem::Version
|
71
|
-
version:
|
71
|
+
version: 1.14.2
|
72
72
|
- - "<"
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '2'
|
@@ -78,7 +78,7 @@ dependencies:
|
|
78
78
|
requirements:
|
79
79
|
- - ">="
|
80
80
|
- !ruby/object:Gem::Version
|
81
|
-
version: 4.
|
81
|
+
version: 4.8.0
|
82
82
|
- - "<"
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '5'
|
@@ -88,10 +88,30 @@ dependencies:
|
|
88
88
|
requirements:
|
89
89
|
- - ">="
|
90
90
|
- !ruby/object:Gem::Version
|
91
|
-
version: 4.
|
91
|
+
version: 4.8.0
|
92
92
|
- - "<"
|
93
93
|
- !ruby/object:Gem::Version
|
94
94
|
version: '5'
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: oj
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '3.13'
|
102
|
+
- - "<"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '4'
|
105
|
+
type: :runtime
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - ">="
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '3.13'
|
112
|
+
- - "<"
|
113
|
+
- !ruby/object:Gem::Version
|
114
|
+
version: '4'
|
95
115
|
description: light core fluent plugin. support mongodb, nginx and application
|
96
116
|
email:
|
97
117
|
- l.li@alphabets.cn
|
@@ -116,7 +136,7 @@ homepage: https://git.alphabets.cn/light/fluent-plugin-light-core
|
|
116
136
|
licenses:
|
117
137
|
- Apache-2.0
|
118
138
|
metadata: {}
|
119
|
-
post_install_message:
|
139
|
+
post_install_message:
|
120
140
|
rdoc_options: []
|
121
141
|
require_paths:
|
122
142
|
- lib
|
@@ -132,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
132
152
|
version: '0'
|
133
153
|
requirements: []
|
134
154
|
rubygems_version: 3.0.3
|
135
|
-
signing_key:
|
155
|
+
signing_key:
|
136
156
|
specification_version: 4
|
137
157
|
summary: light core fluent plugin.
|
138
158
|
test_files:
|