fluent-plugin-light-core 0.1.0 → 0.1.1

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: 2d3a64892c30aac33a4917c52139e115105f0eb3048c7870100b83227eaa8728
4
- data.tar.gz: 4e0ad9a971081c6aca662fd59d381e97d19e02c0bad8fce9b14fb91041dd2b88
3
+ metadata.gz: 8c42d7ebbc40db04faa3683d2f19cc13b8faaad30f0a103dcd8284015cf41634
4
+ data.tar.gz: 7b1dc8dc732a0cdc15a8e9ac124a86a9981dd8a032488b73a6d2f00dc022b229
5
5
  SHA512:
6
- metadata.gz: 025ae92bbb364872815e18db1c677f658f1d9dbb33ee28a7dc6b9adf39511d342516156f1955e84a6407c3fea1b56ccd2517c5523605462a31a60587ffe5023b
7
- data.tar.gz: 9ddeda7c93a28746aab4c32f320a82c6cabdc35557291ad641b19e9b171b9bd68498681ad230d17eb3972f6296de56236673456f2f51aa7e4db081c64915d41f
6
+ metadata.gz: 27d1c95d1b34923806055fc51e72f16e13af8c33d6c501aff6b2ad829c65817cfaacfce0ef687a373656738051035478cb4d06d6327666b8fa6adf872192a4d7
7
+ data.tar.gz: feb76078202bf213d7692ec0cd2a7faef62ce46219e4165ded55e13e9bc3eaaaf43f8de4eb49a5407c926ee6b091bd435fa7f4ce4f1aba5f2b12bc2507c517ad
data/.gitignore CHANGED
@@ -1 +1,2 @@
1
- /sample
1
+ *.log
2
+ *.pos
@@ -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.0"
6
+ spec.version = "0.1.1"
7
7
  spec.authors = ["LIN LI"]
8
8
  spec.email = ["l.li@alphabets.cn"]
9
9
 
@@ -38,8 +38,9 @@ module Fluent
38
38
 
39
39
  end
40
40
 
41
+ # Parse the application log
41
42
  def filter_app(tag, time, record)
42
- file = record['file'].split('_') # Parse log file name
43
+ file = record['file'].split('/').last.split('_') # Parse log file name
43
44
  log = record['log'] # Get detailed log content
44
45
 
45
46
  # Set common items
@@ -94,13 +95,13 @@ module Fluent
94
95
  # https://docs.nginx.com/nginx/admin-guide/monitoring/logging/
95
96
  def filter_lb(tag, time, record)
96
97
 
97
- file = record['file'].split('_') # 解析日志文件名称
98
- log = record['log'] # 获取日志内容详细
98
+ file = record['file'].split('/').last.split('_')
99
+ log = record['log']
99
100
 
100
- record['environment'] = Socket.gethostname.split('-')[0] # dev | prd
101
- record[:cid] = file[0] # container id
102
- record[:cname] = 'lb' # container name
103
- record[:ctime] = record['time'] # container time
101
+ record['environment'] = Socket.gethostname.split('-')[0]
102
+ record[:cid] = file[0]
103
+ record[:cname] = tag
104
+ record[:ctime] = record['time']
104
105
 
105
106
  record.delete('log')
106
107
  record.delete('file')
@@ -158,12 +159,12 @@ module Fluent
158
159
  # https://docs.mongodb.com/manual/reference/log-messages/
159
160
  def filter_mongo(tag, time, record)
160
161
 
161
- file = record['file'].split('_')
162
+ file = record['file'].split('/').last.split('_')
162
163
  log = record['log']
163
164
 
164
165
  record['environment'] = Socket.gethostname.split('-')[0]
165
166
  record[:cid] = file[0]
166
- record[:cname] = 'mongo'
167
+ record[:cname] = tag
167
168
  record[:ctime] = record['time']
168
169
 
169
170
  record.delete('log')
@@ -0,0 +1,32 @@
1
+
2
+ ## 插件制作
3
+
4
+ ```
5
+ % fluent-plugin-generate filter light-core
6
+ License: Apache-2.0
7
+ create Gemfile
8
+ create README.md
9
+ create Rakefile
10
+ create fluent-plugin-light-core.gemspec
11
+ create lib/fluent/plugin/filter_light_core.rb
12
+ create test/helper.rb
13
+ create test/plugin/test_filter_light_core.rb
14
+ Initialized empty Git repository in /Users/lilin/developer/light/fluent-plugin-light-core/.git/
15
+ ```
16
+
17
+
18
+ ## 上传
19
+
20
+ - 登陆rubygems
21
+ % gem signin
22
+
23
+ - 发布
24
+ rake release
25
+
26
+
27
+ ## 调试
28
+ - 执行fluentd
29
+
30
+ % cd sample
31
+ % fluentd -c source.conf -p ../lib/fluent/plugin
32
+
@@ -0,0 +1,101 @@
1
+
2
+ <source>
3
+ @type tail
4
+ path sample/app*.log
5
+ pos_file sample/source.app.pos
6
+ tag app
7
+ format json
8
+ read_from_head true
9
+ path_key file
10
+ time_key time
11
+ keep_time_key true
12
+ time_format %Y-%m-%dT%H:%M:%S.%NZ
13
+ </source>
14
+
15
+ <source>
16
+ @type tail
17
+ path sample/lb*.log
18
+ pos_file sample/source.lb.pos
19
+ tag lb
20
+ format json
21
+ read_from_head true
22
+ path_key file
23
+ time_key time
24
+ keep_time_key true
25
+ time_format %Y-%m-%dT%H:%M:%S.%NZ
26
+ </source>
27
+
28
+ <source>
29
+ @type tail
30
+ path sample/hub*.log
31
+ pos_file sample/source.hub.pos
32
+ tag hub
33
+ format json
34
+ read_from_head true
35
+ path_key file
36
+ time_key time
37
+ keep_time_key true
38
+ time_format %Y-%m-%dT%H:%M:%S.%NZ
39
+ </source>
40
+
41
+ <source>
42
+ @type tail
43
+ path sample/db*.log
44
+ pos_file sample/source.mongo.pos
45
+ tag mongo
46
+ format json
47
+ read_from_head true
48
+ path_key file
49
+ time_key time
50
+ keep_time_key true
51
+ time_format %Y-%m-%dT%H:%M:%S.%NZ
52
+ </source>
53
+
54
+ <source>
55
+ @type tail
56
+ path sample/secondary*.log
57
+ pos_file sample/source.secondary.pos
58
+ tag secondary
59
+ format json
60
+ read_from_head true
61
+ path_key file
62
+ time_key time
63
+ keep_time_key true
64
+ time_format %Y-%m-%dT%H:%M:%S.%NZ
65
+ </source>
66
+
67
+ <source>
68
+ @type tail
69
+ path sample/arbiter*.log
70
+ pos_file sample/source.arbiter.pos
71
+ tag arbiter
72
+ format json
73
+ read_from_head true
74
+ path_key file
75
+ time_key time
76
+ keep_time_key true
77
+ time_format %Y-%m-%dT%H:%M:%S.%NZ
78
+ </source>
79
+
80
+ <filter **>
81
+ @type light_core
82
+ </filter>
83
+
84
+ # <match app>
85
+ # @type rewrite_tag_filter
86
+ # <rule>
87
+ # key cname
88
+ # pattern ^(.+)$
89
+ # tag $1
90
+ # </rule>
91
+ # </match>
92
+
93
+ <match **>
94
+ @type stdout
95
+ </match>
96
+
97
+ <label @FLUENT_LOG>
98
+ <match fluent.*>
99
+ @type stdout
100
+ </match>
101
+ </label>
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.0
4
+ version: 0.1.1
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-09-22 00:00:00.000000000 Z
11
+ date: 2020-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -87,6 +87,8 @@ files:
87
87
  - Rakefile
88
88
  - fluent-plugin-light-core.gemspec
89
89
  - lib/fluent/plugin/filter_light_core.rb
90
+ - sample/README.md
91
+ - sample/source.conf
90
92
  - test/helper.rb
91
93
  - test/plugin/test_filter_light_core.rb
92
94
  homepage: https://git.alphabets.cn/light/fluent-plugin-light-core