fluent-plugin-light-core 0.2.2 → 0.2.3
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-light-core.gemspec +1 -1
- data/lib/fluent/plugin/filter_light_core.rb +27 -63
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a553d56fc47ba8c7ae49428e3d60a5180bb90a9d3b355ebec22b6983265249a9
|
4
|
+
data.tar.gz: b27775457e6b5cea4f80a6d83095460ef2d59087648ef683331615a90e4a2fce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69e2cf2089fb5be1cc62fcdbe86498b1711c0e5bea39767044d9b3e2e853026ec9a0f122609c05b79e57e58f6d74f7fc924563e56526d9ecdde61ec4631dde27
|
7
|
+
data.tar.gz: e384dadbc0567ac19f7013209aa43441981c0aedb85bfa9381b86118422956b839d218b6a2b8083dc5ae9af93ed503d8ecc181afae6de952e148fff1d640bf4c
|
@@ -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,14 @@ module Fluent
|
|
292
257
|
|
293
258
|
if tag == 'app'
|
294
259
|
|
295
|
-
# 未使用
|
296
260
|
if @app_stream && record['stream']
|
297
|
-
send(record) if record['stream'] == @app_stream
|
261
|
+
send(tag, record['message'], record) if record['stream'] == @app_stream
|
298
262
|
end
|
299
263
|
|
300
|
-
# 未使用
|
301
264
|
if @app_message.length > 0 && record['message']
|
302
265
|
@app_message.each do |pattern|
|
303
266
|
if pattern.match(record['message'])
|
304
|
-
send(record)
|
267
|
+
send(tag, record['message'], record)
|
305
268
|
break
|
306
269
|
end
|
307
270
|
end
|
@@ -369,7 +332,8 @@ module Fluent
|
|
369
332
|
end
|
370
333
|
|
371
334
|
# 转数字
|
372
|
-
def
|
335
|
+
def str_to_num(str)
|
336
|
+
return 0 if (str == '-')
|
373
337
|
return str.to_i if (str =~ /^\d+$/)
|
374
338
|
return str.to_f if (str =~ /^\d+\.\d+$/)
|
375
339
|
str
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LIN LI
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-11-
|
11
|
+
date: 2021-11-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|