fluent-plugin-light-core 0.2.9 → 0.3.0

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: 5144ababaafd02b252534db4f948037d55fb63b688eaf2f243eb085215fdd09b
4
- data.tar.gz: 2c34efb8b2cea7ff556d5bdc21e927251fe8920b28ee6e39cb20da7afed5ea4d
3
+ metadata.gz: 6119d11808512bdf44f83123c91c633d8f11ca5c2dac44fc1e7576d075273d08
4
+ data.tar.gz: 891aa7bc78a8d191733805b3de356f003c32fcddc0365d5ccebd97cc91a5615a
5
5
  SHA512:
6
- metadata.gz: db8615ee2d064865a3e570b1d26f58fd2cd1db6febb5bcbb745579ed3e4fab0278447cd2c3cde07c2f19b8863f34bc645a55137dccbb63667fcdb08fed9692ad
7
- data.tar.gz: e4b9146e96aadc71f60e2040772806a84f0174a2d2d945f84708e795a547db9f3dc46aea944334adc0b5c5103b3677854b62160472c12cdd49e91bf79dae1cf3
6
+ metadata.gz: 30231e1d3b211c71b11370bd482eb12d6070d61da621907e95df5140e04b4eb1c5572851a838aaa54a407f13ec6ddaf778e960e4026d8333573f7c45bfea259c
7
+ data.tar.gz: 2bd9370ed15a793354809c6cff4c6a2a08251cf48e9c33948cd541700a928dac3c28a44233fd70f055eeaf310b69bbac273af74fa80200b6b539a4333611c395
@@ -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.9"
6
+ spec.version = "0.3.0"
7
7
  spec.authors = ["LIN LI"]
8
8
  spec.email = ["l.li@alphabets.cn"]
9
9
 
@@ -41,6 +41,7 @@ module Fluent
41
41
  # MongoDB 异常 settings
42
42
  config_param :mongo_severity, :array, default: ['F', 'E'], value_type: :string
43
43
  config_param :mongo_querytime, :float, default: 100
44
+ config_param :mongo_dataBytes, :float, default: 1073741824
44
45
 
45
46
  # 初始化 Sentry
46
47
  def start
@@ -69,7 +70,7 @@ module Fluent
69
70
 
70
71
  # 主处理
71
72
  def filter(tag, time, record)
72
-
73
+
73
74
  if ['app', 'service'].include? tag
74
75
  record = filter_app(tag, time, record)
75
76
  return notice('app', record)
@@ -212,7 +213,7 @@ module Fluent
212
213
 
213
214
  # https://docs.mongodb.com/manual/reference/log-messages/
214
215
  def filter_mongo(tag, time, record)
215
-
216
+
216
217
  file = record['file'].split('/').last.split('_')
217
218
  log = record['log']
218
219
 
@@ -239,6 +240,14 @@ module Fluent
239
240
  record['querytime'] = attributes['durationMillis']
240
241
  record['collection'] = attributes['ns']
241
242
  record['command'] = attributes['command']
243
+ storage = attributes['storage']
244
+ if storage
245
+ data = storage['data']
246
+ if data
247
+ record['bytesRead'] = data['bytesRead']
248
+ record['bytesWritten'] = data['bytesWritten']
249
+ end
250
+ end
242
251
  record['attr'] = attributes
243
252
  end
244
253
 
@@ -314,6 +323,18 @@ module Fluent
314
323
  send(tag, message, record) if record['querytime'].to_f >= @mongo_querytime
315
324
  end
316
325
 
326
+ if @mongo_dataBytes > 0 && record['bytesRead']
327
+ message = 'bytesRead data is:' + record['bytesRead'].to_s
328
+ message = message + ' : ' + record['collection'] if record['collection']
329
+ send(tag, message, record) if record['bytesRead'].to_f >= @mongo_dataBytes
330
+ end
331
+
332
+ if @mongo_dataBytes > 0 && record['bytesWritten']
333
+ message = 'bytesWritten data is:' + record['bytesWritten'].to_s
334
+ message = message + ' : ' + record['collection'] if record['collection']
335
+ send(tag, message, record) if record['bytesWritten'].to_f >= @mongo_dataBytes
336
+ end
337
+
317
338
  return record
318
339
  end
319
340
 
data/sample/source.conf CHANGED
@@ -83,6 +83,7 @@
83
83
  sentry_dsn https://4447403a2a86437491d307ceb72898e5@sentry.zf.link/4
84
84
  mongo_querytime 300
85
85
  mongo_severity F,E
86
+ mongo_dataBytes 1073741824
86
87
  lb_stream stderr
87
88
  lb_code 400,500
88
89
  lb_elapsed 5
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.9
4
+ version: 0.3.0
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-20 00:00:00.000000000 Z
11
+ date: 2021-12-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler