fluent-plugin-light-core 0.1.3 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 262f7c2b69259e409b93285c4138386a24d7ee2d12d81f120ef1306875d0d701
4
- data.tar.gz: 19ecb1abd1e754ffe2da66f72c8cb211fe81aa5a4e3543c742f63d6ee121a474
3
+ metadata.gz: f402d3e7add5f4132e862aad254907c08f73068b8e92b4cf82f12c7e64fc01d7
4
+ data.tar.gz: a03cc3f47b6061a4567f7467d2786dac007e28deede646d511a5de7a58040796
5
5
  SHA512:
6
- metadata.gz: a39111482eb7fcd051f14f92d4a6f062df5f9673f0a474c2c26ea5c73ba25074a2e13237ae3dc9c67e9ec2743009c4cc59a63476dd20a98883151fb691e62090
7
- data.tar.gz: de9645e74a662f9b5be93e4bdfb7141f8e473c27dff352755f7dca683ced2d505a2a7188270ef5a0a540e1a15f1bce8f5fcb15eaa963efeca89994397eb56abb
6
+ metadata.gz: 3ffb7670974e375d66d460237f94de74e2f10d308e72d4b9e2cf62c7fc9113da24e957fad8a17a9af81f8f9b2ac32b93775e3ea24cfa7e4c820e14ccda1347b0
7
+ data.tar.gz: 5ca326bae0e725610ddf20775db3cb254217497544d60ffbe3f5f4a5d0ecd6176e2b5c3595a65e2abfdd670cd269ec590196c346eb38a6fac7ab658a6ae4eccd
@@ -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.1.3"
6
+ spec.version = "0.1.8"
7
7
  spec.authors = ["LIN LI"]
8
8
  spec.email = ["l.li@alphabets.cn"]
9
9
 
@@ -67,7 +67,7 @@ module Fluent
67
67
  # 主处理
68
68
  def filter(tag, time, record)
69
69
 
70
- if tag == 'app'
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('_') # Parse log file name
92
- log = record['log'] # Get detailed log content
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] # dev | prd
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'] = Socket.gethostname.split('-')[0]
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>[^\"]*)" "(?<forwarder>[^\"]*)" "(?<elapsed>[^\"]*)")?/.match(log)
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['forwarder'] = item[:forwarder]
173
- record['elapsed'] = item[:elapsed]
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'] = Socket.gethostname.split('-')[0]
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
- record['collection'] = query[:collection]
244
- record['command'] = query[:command]
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
@@ -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
- rake release
24
+ 1. 删除pkg目录下的所有内容
25
+ 2. 修改 fluent-plugin-light-core.gemspec 中的 spec.version
26
+ 3. 提交所有的修改
27
+ 4. 执行打包发布 $ rake release
25
28
 
26
29
 
27
30
  ## 调试
@@ -14,8 +14,8 @@
14
14
 
15
15
  <source>
16
16
  @type tail
17
- path sample/lb*.log
18
- pos_file sample/source.lb.pos
17
+ path sample/ingress-nginx*.log
18
+ pos_file sample/source.ingress-nginx.pos
19
19
  tag lb
20
20
  format json
21
21
  read_from_head true
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.3
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: 2020-11-09 00:00:00.000000000 Z
11
+ date: 2021-01-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler