fluent-plugin-light-core 0.2.1 → 0.2.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: af0f4865440862be4488030659ec9798b8eb9261bc2f9b95ee093a0b5de28387
4
- data.tar.gz: 5a46ab336bb472b47f6572d5836e6fbbfeea8075e19dfa6a6781d4e938ceddb7
3
+ metadata.gz: 840e2f50ffd4383b36db2e72443db1161a9252bf04e4eb305d721af1ce31bb64
4
+ data.tar.gz: b9bf12844a61596b32252fa36266a1a9e875f8314d087993d94874993a698ad3
5
5
  SHA512:
6
- metadata.gz: 045f2e53eba3fcf2ac10aa1a625e539bff38f6221c4a776d4c7a8b5250868e8bda1b0c1c59b07da1458c86787f07e6f9d568e4cb73562b7a4d261aaa0a42be1b
7
- data.tar.gz: 7272c0c901fd28c3aec6b9241060f8dab6e64f3cc91f40ab7a044f866b951e4b3aa4cc4ac9428029914e7104ca43840abceee5b88cae3e0d0a95928ed337311c
6
+ metadata.gz: d67d38209e5ad74bf70a9ff7b4cb9949072c9009632616ad8ba88cb50e49fd2f3dd207e7e5eda1e304d416c3dd3ecfaa88567568ccfdda477f7e2da5491e7e27
7
+ data.tar.gz: f6ed9b675e53d81e54c603972a3e8ba75b6218626fd17f8cb21ab75a89f4644d6e8973d046e6aec4f776cc5c3b1221b660faf797906be01d136efb88d35ea48d
data/.gitignore CHANGED
@@ -1,2 +1,3 @@
1
1
  *.log
2
2
  *.pos
3
+ *.gem
data/Gemfile CHANGED
@@ -2,4 +2,6 @@ source "https://rubygems.org"
2
2
 
3
3
  gemspec
4
4
 
5
- gem "sentry-ruby"
5
+ gem "sentry-ruby"
6
+
7
+ gem "oj", "~> 3.13"
data/Gemfile.lock CHANGED
@@ -1,38 +1,71 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fluent-plugin-light-core (0.1.0)
5
- fluentd (>= 0.14.10, < 2)
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
- cool.io (1.6.0)
11
- fluentd (1.11.2)
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.7.0)
35
+ http_parser.rb (>= 0.5.1, < 0.8.0)
14
36
  msgpack (>= 1.3.1, < 2.0.0)
15
- serverengine (>= 2.0.4, < 3.0.0)
37
+ serverengine (>= 2.2.2, < 3.0.0)
16
38
  sigdump (~> 0.2.2)
17
- strptime (>= 0.2.2, < 1.0.0)
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.6.0)
22
- msgpack (1.3.3)
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
- serverengine (2.2.1)
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.4)
61
+ strptime (0.2.5)
29
62
  test-unit (3.2.9)
30
63
  power_assert
31
- thread_safe (0.3.6)
32
- tzinfo (1.2.5)
33
- thread_safe (~> 0.1)
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.1"
6
+ spec.version = "0.2.5"
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", [">= 0.14.10", "< 2"]
27
- spec.add_runtime_dependency "sentry-ruby", [">= 4.1.5", "< 5"]
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
@@ -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'] = format_str(item[:size])
134
+ record['size'] = str_to_num(item[:size])
134
135
  record['uid'] = item[:uid]
135
- record['elapsed'] = format_str(item[: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'] = format_str(item[:size])
173
+ record['size'] = str_to_num(item[:size])
173
174
  record['referer'] = item[:referer]
174
175
  record['agent'] = item[:agent]
175
- record['elapsed'] = format_str(item[: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'] = item[: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
- if /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}\+\d{4} [A-Z]/.match(log)
229
-
230
- item = /^(?<time>[^ ]*) (?<severity>[A-Z])\s* (?<component>(-|([^ ]*)))\s* \[(?<context>[^\]]*)\]\s* ((?<query>.*) protocol:op_query (?<querytime>[\d\.]+(?=ms))|(?<message>.*))/.match(log)
231
-
232
- record['time'] = item[:time]
233
- record['severity'] = item[:severity]
234
- record['component'] = item[:component]
235
- record['context'] = item[:context]
236
-
237
- if item[:message]
238
- record['message'] = item[:message]
239
- return record
240
- end
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,15 @@ 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
+ message = 'Stream error' + record['stream']
262
+ send(tag, message, record) if record['stream'] == @app_stream
297
263
  end
298
264
 
299
- # 未使用
300
265
  if @app_message.length > 0 && record['message']
301
266
  @app_message.each do |pattern|
302
267
  if pattern.match(record['message'])
303
- send(record)
268
+ send(tag, record['message'], record)
304
269
  break
305
270
  end
306
271
  end
@@ -320,6 +285,11 @@ module Fluent
320
285
  end
321
286
 
322
287
  if tag == 'lb'
288
+
289
+ if @lb_ignore && record['path'] && @lb_ignore.include?(record['path'])
290
+ return record
291
+ end
292
+
323
293
  if @lb_stream && record['stream']
324
294
  send(tag, 'Stderror', record) if record['stream'] == @lb_stream
325
295
  end
@@ -359,11 +329,13 @@ module Fluent
359
329
  # 发送UDP请求
360
330
  def send(tag, message, record)
361
331
  log.debug('send udp notice')
362
- Sentry.capture_message(message, :extra => record, :tags => {'log' => tag})
332
+ encoded = message.force_encoding(Encoding::UTF_8)
333
+ Sentry.capture_message(encoded, :extra => record, :tags => {'log' => tag}) rescue log.warn(encoded)
363
334
  end
364
335
 
365
336
  # 转数字
366
- def format_str(str)
337
+ def str_to_num(str)
338
+ return 0 if (str == '-')
367
339
  return str.to_i if (str =~ /^\d+$/)
368
340
  return str.to_f if (str =~ /^\d+\.\d+$/)
369
341
  str
data/sample/README.md CHANGED
@@ -42,3 +42,8 @@ Initialized empty Git repository in /Users/lilin/developer/light/fluent-plugin-l
42
42
  - 安装依赖
43
43
 
44
44
  gem install sentry-ruby
45
+
46
+ - 更新依赖版本
47
+
48
+ bundle install
49
+ 会修改Gemfile.lock文件
data/sample/source.conf CHANGED
@@ -86,6 +86,7 @@
86
86
  lb_stream stderr
87
87
  lb_code 400,500
88
88
  lb_elapsed 5
89
+ lb_ignore /api/environment/list,/api/certificate/list?condition%5Bkind%5D=SSL
89
90
  app_status 500
90
91
  app_elapsed 5
91
92
  </filter>
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.1
4
+ version: 0.2.5
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-02-01 00:00:00.000000000 Z
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: 0.14.10
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: 0.14.10
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.1.5
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.1.5
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
@@ -107,7 +127,6 @@ files:
107
127
  - Rakefile
108
128
  - fluent-plugin-light-core.gemspec
109
129
  - lib/fluent/plugin/filter_light_core.rb
110
- - pkg/fluent-plugin-light-core-0.2.0.gem
111
130
  - sample/README.md
112
131
  - sample/source.conf
113
132
  - sample/udpsample.rb
@@ -117,7 +136,7 @@ homepage: https://git.alphabets.cn/light/fluent-plugin-light-core
117
136
  licenses:
118
137
  - Apache-2.0
119
138
  metadata: {}
120
- post_install_message:
139
+ post_install_message:
121
140
  rdoc_options: []
122
141
  require_paths:
123
142
  - lib
@@ -133,7 +152,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
152
  version: '0'
134
153
  requirements: []
135
154
  rubygems_version: 3.0.3
136
- signing_key:
155
+ signing_key:
137
156
  specification_version: 4
138
157
  summary: light core fluent plugin.
139
158
  test_files:
Binary file