fluent-plugin-light-core 0.2.6 → 0.3.0
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 +25 -10
- data/sample/README.md +16 -0
- data/sample/source.conf +1 -0
- 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: 6119d11808512bdf44f83123c91c633d8f11ca5c2dac44fc1e7576d075273d08
|
4
|
+
data.tar.gz: 891aa7bc78a8d191733805b3de356f003c32fcddc0365d5ccebd97cc91a5615a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30231e1d3b211c71b11370bd482eb12d6070d61da621907e95df5140e04b4eb1c5572851a838aaa54a407f13ec6ddaf778e960e4026d8333573f7c45bfea259c
|
7
|
+
data.tar.gz: 2bd9370ed15a793354809c6cff4c6a2a08251cf48e9c33948cd541700a928dac3c28a44233fd70f055eeaf310b69bbac273af74fa80200b6b539a4333611c395
|
@@ -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
|
|
@@ -257,11 +266,6 @@ module Fluent
|
|
257
266
|
|
258
267
|
if tag == 'app'
|
259
268
|
|
260
|
-
if @app_stream && record['stream']
|
261
|
-
message = 'Stream error' + record['stream']
|
262
|
-
send(tag, message, record) if record['stream'] == @app_stream
|
263
|
-
end
|
264
|
-
|
265
269
|
if @app_message.length > 0 && record['message']
|
266
270
|
@app_message.each do |pattern|
|
267
271
|
if pattern.match(record['message'])
|
@@ -319,6 +323,18 @@ module Fluent
|
|
319
323
|
send(tag, message, record) if record['querytime'].to_f >= @mongo_querytime
|
320
324
|
end
|
321
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
|
+
|
322
338
|
return record
|
323
339
|
end
|
324
340
|
|
@@ -328,9 +344,8 @@ module Fluent
|
|
328
344
|
|
329
345
|
# 发送UDP请求
|
330
346
|
def send(tag, message, record)
|
331
|
-
|
332
|
-
log.info(message)
|
333
|
-
# Sentry.capture_message(message, :extra => record, :tags => {'log' => tag})
|
347
|
+
Sentry.capture_message(message, :extra => record, :tags => {'log' => tag})
|
348
|
+
log.info('msg has been sent to sentry : ', message)
|
334
349
|
end
|
335
350
|
|
336
351
|
# 转数字
|
data/sample/README.md
CHANGED
@@ -47,3 +47,19 @@ Initialized empty Git repository in /Users/lilin/developer/light/fluent-plugin-l
|
|
47
47
|
|
48
48
|
bundle install
|
49
49
|
会修改Gemfile.lock文件
|
50
|
+
|
51
|
+
|
52
|
+
## 在Linxu上运行
|
53
|
+
|
54
|
+
- 进入fluentd容器, 安装依赖
|
55
|
+
$ yum groupinstall 'Development Tools'
|
56
|
+
$ yum install rubygems ruby-devel
|
57
|
+
|
58
|
+
- 下载代码, 安装依赖
|
59
|
+
$ git clone http://git.alphabets.cn/light/fluent-plugin-light-core.git
|
60
|
+
$ cd fluent-plugin-light-core
|
61
|
+
$ gem install bundler:1.17.2
|
62
|
+
$ bundler install
|
63
|
+
|
64
|
+
- 运行代码
|
65
|
+
$ rm -f sample/*.pos && fluentd -c sample/source.conf -p lib/fluent/plugin
|
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.
|
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
|
+
date: 2021-12-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|