fluent-plugin-light-core 0.2.0 → 0.2.4
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 -2
- data/lib/fluent/plugin/filter_light_core.rb +33 -63
- data/sample/README.md +5 -0
- data/sample/source.conf +1 -0
- metadata +47 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e720de6ea6a8db7c3fa77fa41ac4563868a78dca908737657f4d33ebffc1075
|
4
|
+
data.tar.gz: e23636b6fe004a65b89564f4c1b522c76d19bdd2708d58e57dc53829f7951536
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6552d305477a2cd31000776eb4626a1cc947d5f12cc810c86cc06482ad065203b76ab3e0441bfdf7f37cf0b69473faa93f79d7db5b2ed7b6682ab882a7c7a79e
|
7
|
+
data.tar.gz: c26f25824e3e2e9d0aa0afdb1368e1ca93fca461d93721803c0bed0715d4fa522c4463bb10a401a3b620c242ef603128121ca7a01f6842d3849dde7638bff509
|
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.4"
|
7
7
|
spec.authors = ["LIN LI"]
|
8
8
|
spec.email = ["l.li@alphabets.cn"]
|
9
9
|
|
@@ -23,5 +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", [">=
|
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"]
|
27
29
|
end
|
@@ -36,6 +36,7 @@ module Fluent
|
|
36
36
|
config_param :lb_stream, :string, default: 'stderr'
|
37
37
|
config_param :lb_code, :array, default: ['400', '500'], value_type: :string
|
38
38
|
config_param :lb_elapsed, :float, default: 3
|
39
|
+
config_param :lb_ignore, :array, default: [], value_type: :string
|
39
40
|
|
40
41
|
# MongoDB 异常 settings
|
41
42
|
config_param :mongo_severity, :array, default: ['F', 'E'], value_type: :string
|
@@ -130,9 +131,9 @@ module Fluent
|
|
130
131
|
record['method'] = item[:method]
|
131
132
|
record['url'] = item[:url]
|
132
133
|
record['status'] = item[:status]
|
133
|
-
record['size'] =
|
134
|
+
record['size'] = str_to_num(item[:size])
|
134
135
|
record['uid'] = item[:uid]
|
135
|
-
record['elapsed'] =
|
136
|
+
record['elapsed'] = str_to_num(item[:elapsed])
|
136
137
|
record['addr'] = item[:addr].gsub(/\n$/, '')
|
137
138
|
|
138
139
|
return record
|
@@ -169,10 +170,10 @@ module Fluent
|
|
169
170
|
record['method'] = item[:method]
|
170
171
|
record['path'] = item[:path]
|
171
172
|
record['code'] = item[:code]
|
172
|
-
record['size'] =
|
173
|
+
record['size'] = str_to_num(item[:size])
|
173
174
|
record['referer'] = item[:referer]
|
174
175
|
record['agent'] = item[:agent]
|
175
|
-
record['elapsed'] =
|
176
|
+
record['elapsed'] = str_to_num(item[:elapsed])
|
176
177
|
record['requestid'] = item[:requestid]
|
177
178
|
record['sessionid'] = item[:sessionid]
|
178
179
|
|
@@ -183,7 +184,7 @@ module Fluent
|
|
183
184
|
if /^\d{4}\/\d{2}\/\d{2} \d{2}:\d{2}:\d{2} \[error\]/.match(log)
|
184
185
|
item = /^(?<time>[^ ]+ [^ ]+) \[(?<level>.*)\] (?<pid>\d*)#(?<tid>[^:]*): \*(?<cid>\d*) (?<message>.*)$/.match(log)
|
185
186
|
|
186
|
-
record['time'] =
|
187
|
+
record['time'] = record['ctime']
|
187
188
|
record['level'] = item[:level]
|
188
189
|
record['message'] = item[:message]
|
189
190
|
record['process'] = item[:pid] # process id
|
@@ -224,61 +225,26 @@ module Fluent
|
|
224
225
|
record.delete('file')
|
225
226
|
record.delete('time')
|
226
227
|
|
227
|
-
#
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
if item[:querytime]
|
243
|
-
record['querytime'] = format_str(item[:querytime])
|
244
|
-
end
|
245
|
-
|
246
|
-
if item[:query]
|
247
|
-
record['command'] = item[:query]
|
248
|
-
query = /^command\s* (?<collection>[^ ]*) (?<command>.*)$/.match(item[:query])
|
249
|
-
unless query.nil?
|
250
|
-
record['collection'] = query[:collection]
|
251
|
-
record['command'] = query[:command]
|
252
|
-
end
|
253
|
-
end
|
254
|
-
|
255
|
-
return record
|
256
|
-
else
|
257
|
-
|
258
|
-
# 版本4.4开始,默认日志为json格式
|
259
|
-
item = JSON.parse(log)
|
260
|
-
record['time'] = item['t']['$date']
|
261
|
-
record['severity'] = item['s']
|
262
|
-
record['component'] = item['c']
|
263
|
-
record['context'] = item['ctx']
|
264
|
-
record['identifier'] = item['id']
|
265
|
-
record['message'] = item['msg']
|
266
|
-
|
267
|
-
attributes = item['attr']
|
268
|
-
if attributes
|
269
|
-
record['querytime'] = attributes['durationMillis']
|
270
|
-
record['collection'] = attributes['ns']
|
271
|
-
record['command'] = attributes['command']
|
272
|
-
record['attr'] = attributes
|
273
|
-
end
|
274
|
-
|
275
|
-
record['tags'] = item['tags']
|
276
|
-
record['truncated'] = item['truncated']
|
277
|
-
record['size'] = item['size']
|
278
|
-
|
279
|
-
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
|
280
243
|
end
|
281
244
|
|
245
|
+
record['tags'] = item['tags']
|
246
|
+
record['truncated'] = item['truncated']
|
247
|
+
record['size'] = item['size']
|
282
248
|
record
|
283
249
|
end
|
284
250
|
|
@@ -291,16 +257,14 @@ module Fluent
|
|
291
257
|
|
292
258
|
if tag == 'app'
|
293
259
|
|
294
|
-
# 未使用
|
295
260
|
if @app_stream && record['stream']
|
296
|
-
send(record) if record['stream'] == @app_stream
|
261
|
+
send(tag, record['message'], record) if record['stream'] == @app_stream
|
297
262
|
end
|
298
263
|
|
299
|
-
# 未使用
|
300
264
|
if @app_message.length > 0 && record['message']
|
301
265
|
@app_message.each do |pattern|
|
302
266
|
if pattern.match(record['message'])
|
303
|
-
send(record)
|
267
|
+
send(tag, record['message'], record)
|
304
268
|
break
|
305
269
|
end
|
306
270
|
end
|
@@ -320,6 +284,11 @@ module Fluent
|
|
320
284
|
end
|
321
285
|
|
322
286
|
if tag == 'lb'
|
287
|
+
|
288
|
+
if @lb_ignore && record['path'] && @lb_ignore.include?(record['path'])
|
289
|
+
return record
|
290
|
+
end
|
291
|
+
|
323
292
|
if @lb_stream && record['stream']
|
324
293
|
send(tag, 'Stderror', record) if record['stream'] == @lb_stream
|
325
294
|
end
|
@@ -363,7 +332,8 @@ module Fluent
|
|
363
332
|
end
|
364
333
|
|
365
334
|
# 转数字
|
366
|
-
def
|
335
|
+
def str_to_num(str)
|
336
|
+
return 0 if (str == '-')
|
367
337
|
return str.to_i if (str =~ /^\d+$/)
|
368
338
|
return str.to_f if (str =~ /^\d+\.\d+$/)
|
369
339
|
str
|
data/sample/README.md
CHANGED
data/sample/source.conf
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.4
|
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
|
+
date: 2021-11-19 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,10 +68,50 @@ 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'
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: sentry-ruby
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ">="
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: 4.8.0
|
82
|
+
- - "<"
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '5'
|
85
|
+
type: :runtime
|
86
|
+
prerelease: false
|
87
|
+
version_requirements: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: 4.8.0
|
92
|
+
- - "<"
|
93
|
+
- !ruby/object:Gem::Version
|
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'
|
75
115
|
description: light core fluent plugin. support mongodb, nginx and application
|
76
116
|
email:
|
77
117
|
- l.li@alphabets.cn
|
@@ -96,7 +136,7 @@ homepage: https://git.alphabets.cn/light/fluent-plugin-light-core
|
|
96
136
|
licenses:
|
97
137
|
- Apache-2.0
|
98
138
|
metadata: {}
|
99
|
-
post_install_message:
|
139
|
+
post_install_message:
|
100
140
|
rdoc_options: []
|
101
141
|
require_paths:
|
102
142
|
- lib
|
@@ -112,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
112
152
|
version: '0'
|
113
153
|
requirements: []
|
114
154
|
rubygems_version: 3.0.3
|
115
|
-
signing_key:
|
155
|
+
signing_key:
|
116
156
|
specification_version: 4
|
117
157
|
summary: light core fluent plugin.
|
118
158
|
test_files:
|