fluent-plugin-light-core 0.1.3 → 0.1.8
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 -15
- data/sample/README.md +4 -1
- data/sample/source.conf +2 -2
- 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: f402d3e7add5f4132e862aad254907c08f73068b8e92b4cf82f12c7e64fc01d7
|
4
|
+
data.tar.gz: a03cc3f47b6061a4567f7467d2786dac007e28deede646d511a5de7a58040796
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3ffb7670974e375d66d460237f94de74e2f10d308e72d4b9e2cf62c7fc9113da24e957fad8a17a9af81f8f9b2ac32b93775e3ea24cfa7e4c820e14ccda1347b0
|
7
|
+
data.tar.gz: 5ca326bae0e725610ddf20775db3cb254217497544d60ffbe3f5f4a5d0ecd6176e2b5c3595a65e2abfdd670cd269ec590196c346eb38a6fac7ab658a6ae4eccd
|
@@ -67,7 +67,7 @@ module Fluent
|
|
67
67
|
# 主处理
|
68
68
|
def filter(tag, time, record)
|
69
69
|
|
70
|
-
if
|
70
|
+
if ['app', 'service'].include? tag
|
71
71
|
record = filter_app(tag, time, record)
|
72
72
|
return notice('app', record)
|
73
73
|
end
|
@@ -88,11 +88,12 @@ module Fluent
|
|
88
88
|
|
89
89
|
# Parse the application log
|
90
90
|
def filter_app(tag, time, record)
|
91
|
-
file = record['file'].split('/').last.split('_')
|
92
|
-
log = record['log']
|
91
|
+
file = record['file'].split('/').last.split('_') # Parse log file name
|
92
|
+
log = record['log'] # Get detailed log content
|
93
93
|
|
94
94
|
# Set common items
|
95
|
-
record['environment'] = Socket.gethostname.split('-')[0]
|
95
|
+
# record['environment'] = Socket.gethostname.split('-')[0] # dev | prd
|
96
|
+
record['environment'] = ENV['FLUENTD_ENV'] # dev | prd
|
96
97
|
record['cid'] = file[0] # container id
|
97
98
|
record['cname'] = file[0].split('-')[1] # container name
|
98
99
|
record['ctime'] = record['time'] # container time
|
@@ -127,9 +128,9 @@ module Fluent
|
|
127
128
|
record['method'] = item[:method]
|
128
129
|
record['url'] = item[:url]
|
129
130
|
record['status'] = item[:status]
|
130
|
-
record['size'] = item[:size]
|
131
|
+
record['size'] = format_str(item[:size])
|
131
132
|
record['uid'] = item[:uid]
|
132
|
-
record['elapsed'] = item[:elapsed]
|
133
|
+
record['elapsed'] = format_str(item[:elapsed])
|
133
134
|
record['addr'] = item[:addr].gsub(/\n$/, '')
|
134
135
|
|
135
136
|
return record
|
@@ -146,7 +147,7 @@ module Fluent
|
|
146
147
|
file = record['file'].split('/').last.split('_')
|
147
148
|
log = record['log']
|
148
149
|
|
149
|
-
record['environment'] =
|
150
|
+
record['environment'] = ENV['FLUENTD_ENV']
|
150
151
|
record['cid'] = file[0]
|
151
152
|
record['cname'] = tag
|
152
153
|
record['ctime'] = record['time']
|
@@ -157,7 +158,7 @@ module Fluent
|
|
157
158
|
|
158
159
|
# access log
|
159
160
|
if /^[^ ]+ [^ ]+ [^ ]+ \[\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\+\d{2}:\d{2}\]/.match(log)
|
160
|
-
item = /^(?<remote>[^ ]*) (?<host>[^ ]*) (?<user>[^ ]*) \[(?<time>[^\]]*)\] "(?<method>\S+)(?: +(?<path>[^ ]*) +\S*)?" (?<code>[^ ]*) (?<size>[^ ]*)(?: "(?<referer>[^\"]*)" "(?<agent>[^\"]*)" "(?<
|
161
|
+
item = /^(?<remote>[^ ]*) (?<host>[^ ]*) (?<user>[^ ]*) \[(?<time>[^\]]*)\] "(?<method>\S+)(?: +(?<path>[^ ]*) +\S*)?" (?<code>[^ ]*) (?<size>[^ ]*)(?: "(?<referer>[^\"]*)" "(?<agent>[^\"]*)" "(?<elapsed>[^\"]*)" "(?<requestid>[^\"]*)" "(?<sessionid>[^\"]*)")?/.match(log)
|
161
162
|
|
162
163
|
record['remote'] = item[:remote]
|
163
164
|
record['host'] = item[:host]
|
@@ -166,11 +167,12 @@ module Fluent
|
|
166
167
|
record['method'] = item[:method]
|
167
168
|
record['path'] = item[:path]
|
168
169
|
record['code'] = item[:code]
|
169
|
-
record['size'] = item[:size]
|
170
|
+
record['size'] = format_str(item[:size])
|
170
171
|
record['referer'] = item[:referer]
|
171
172
|
record['agent'] = item[:agent]
|
172
|
-
record['
|
173
|
-
record['
|
173
|
+
record['elapsed'] = format_str(item[:elapsed])
|
174
|
+
record['requestid'] = item[:requestid]
|
175
|
+
record['sessionid'] = item[:sessionid]
|
174
176
|
|
175
177
|
return record
|
176
178
|
end
|
@@ -211,7 +213,7 @@ module Fluent
|
|
211
213
|
file = record['file'].split('/').last.split('_')
|
212
214
|
log = record['log']
|
213
215
|
|
214
|
-
record['environment'] =
|
216
|
+
record['environment'] = ENV['FLUENTD_ENV']
|
215
217
|
record['cid'] = file[0]
|
216
218
|
record['cname'] = tag
|
217
219
|
record['ctime'] = record['time']
|
@@ -235,13 +237,16 @@ module Fluent
|
|
235
237
|
end
|
236
238
|
|
237
239
|
if item[:querytime]
|
238
|
-
record['querytime'] = item[:querytime]
|
240
|
+
record['querytime'] = format_str(item[:querytime])
|
239
241
|
end
|
240
242
|
|
241
243
|
if item[:query]
|
244
|
+
record['command'] = item[:query]
|
242
245
|
query = /^command\s* (?<collection>[^ ]*) (?<command>.*)$/.match(item[:query])
|
243
|
-
|
244
|
-
|
246
|
+
unless query.nil?
|
247
|
+
record['collection'] = query[:collection]
|
248
|
+
record['command'] = query[:command]
|
249
|
+
end
|
245
250
|
end
|
246
251
|
|
247
252
|
return record
|
@@ -328,6 +333,13 @@ module Fluent
|
|
328
333
|
@udp.send(data.to_json, 0, Socket.pack_sockaddr_in(@port, @host))
|
329
334
|
end
|
330
335
|
|
336
|
+
# 转数字
|
337
|
+
def format_str(str)
|
338
|
+
return str.to_i if (str =~ /^\d+$/)
|
339
|
+
return str.to_f if (str =~ /^\d+\.\d+$/)
|
340
|
+
str
|
341
|
+
end
|
342
|
+
|
331
343
|
end
|
332
344
|
end
|
333
345
|
end
|
data/sample/README.md
CHANGED
@@ -21,7 +21,10 @@ Initialized empty Git repository in /Users/lilin/developer/light/fluent-plugin-l
|
|
21
21
|
% gem signin
|
22
22
|
|
23
23
|
- 发布
|
24
|
-
|
24
|
+
1. 删除pkg目录下的所有内容
|
25
|
+
2. 修改 fluent-plugin-light-core.gemspec 中的 spec.version
|
26
|
+
3. 提交所有的修改
|
27
|
+
4. 执行打包发布 $ rake release
|
25
28
|
|
26
29
|
|
27
30
|
## 调试
|
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.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- LIN LI
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|