fluent-plugin-monolog 0.1.8 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/fluent-plugin-monolog.gemspec +2 -2
- data/lib/fluent/plugin/parser_monolog.rb +44 -41
- metadata +11 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b5f4b67970607199edc905626cd34d204e5c122
|
4
|
+
data.tar.gz: 66df80a1e127d6c20fbfbc1e99203da726925589
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2adca0eb3cd94d6f95b34f2b3c4c571ca05092a68054e19db6355ca2c5e16c1ada222a94240142457516acafbbce4c82f2d4546c878f14f7f2b7191f5c232d16
|
7
|
+
data.tar.gz: efc333a79860925d78e8132c729cac25cfcb150ae716f323137b533a0ff9371e082b9d5d2adb71016af582334c325e2c07b437db4d3e38544682a7cbbcdf2262
|
data/README.md
CHANGED
@@ -19,7 +19,7 @@ We have an example for this plugin, so please use it.
|
|
19
19
|
|
20
20
|
## Usage
|
21
21
|
|
22
|
-
After installed, please add configurations of [in_tail(tail Input Plugin)](
|
22
|
+
After installed, please add configurations of [in_tail(tail Input Plugin)](https://docs.fluentd.org/v0.14/articles/in_tail) to `td-agent.conf`, like below.
|
23
23
|
|
24
24
|
```
|
25
25
|
# /etc/td-agent/td-agent.conf
|
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "fluent-plugin-monolog"
|
7
|
-
spec.version = "0.
|
7
|
+
spec.version = "0.2.0"
|
8
8
|
spec.authors = ["imunew"]
|
9
9
|
spec.email = ["imunew@gmail.com"]
|
10
10
|
|
@@ -29,6 +29,6 @@ Gem::Specification.new do |spec|
|
|
29
29
|
spec.add_development_dependency "bundler", "~> 1.12"
|
30
30
|
spec.add_development_dependency "rake"
|
31
31
|
spec.add_development_dependency "test-unit", "~> 3.1"
|
32
|
-
spec.add_runtime_dependency "fluentd", "
|
32
|
+
spec.add_runtime_dependency "fluentd", [">= 0.14.0", "< 2"]
|
33
33
|
|
34
34
|
end
|
@@ -1,50 +1,53 @@
|
|
1
|
+
require 'fluent/plugin/parser'
|
1
2
|
require 'json'
|
2
3
|
|
3
4
|
module Fluent
|
4
|
-
|
5
|
-
class
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
def patterns
|
18
|
-
{'format' => REGEXP, 'time_format' => TIME_FORMAT}
|
19
|
-
end
|
5
|
+
module Plugin
|
6
|
+
class TextParser
|
7
|
+
class MonologParser < Parser
|
8
|
+
Fluent::Plugin.register_parser('monolog', self)
|
9
|
+
|
10
|
+
REGEXP = /^\[(?<time>[\d\-]+ [\d\:]+)\] (?<channel>.+)\.(?<level>(DEBUG|INFO|NOTICE|WARNING|ERROR|CRITICAL|ALERT|EMERGENCY))\: (?<message>[^\{\}]*) (?<context>(\{.+\})|(\[.*\])) (?<extra>(\{.+\})|(\[.*\]))\s*$/
|
11
|
+
TIME_FORMAT = "%Y-%m-%d %H:%M:%S"
|
12
|
+
|
13
|
+
def initialize
|
14
|
+
super
|
15
|
+
@time_parser = TimeParser.new(TIME_FORMAT)
|
16
|
+
@mutex = Mutex.new
|
17
|
+
end
|
20
18
|
|
21
|
-
|
22
|
-
|
23
|
-
unless m
|
24
|
-
yield nil, nil
|
25
|
-
return
|
19
|
+
def patterns
|
20
|
+
{'format' => REGEXP, 'time_format' => TIME_FORMAT}
|
26
21
|
end
|
27
22
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
23
|
+
def parse(text)
|
24
|
+
m = REGEXP.match(text)
|
25
|
+
unless m
|
26
|
+
yield nil, nil
|
27
|
+
return
|
28
|
+
end
|
29
|
+
|
30
|
+
time = m['time']
|
31
|
+
time = @mutex.synchronize { @time_parser.parse(time) }
|
32
|
+
|
33
|
+
channel = m['channel']
|
34
|
+
level = m['level']
|
35
|
+
message = m['message']
|
36
|
+
context = JSON.parse(m['context'])
|
37
|
+
extra = JSON.parse(m['extra'])
|
38
|
+
|
39
|
+
record = {
|
40
|
+
"channel" => channel,
|
41
|
+
"level" => level,
|
42
|
+
"message" => message,
|
43
|
+
"context" => context,
|
44
|
+
"extra" => extra
|
45
|
+
}
|
46
|
+
record["time"] = m['time'] if @keep_time_key
|
47
|
+
|
48
|
+
yield time, record
|
49
|
+
end
|
47
50
|
end
|
48
51
|
end
|
49
52
|
end
|
50
|
-
end
|
53
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-monolog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- imunew
|
@@ -56,16 +56,22 @@ dependencies:
|
|
56
56
|
name: fluentd
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 0.14.0
|
62
|
+
- - "<"
|
60
63
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
64
|
+
version: '2'
|
62
65
|
type: :runtime
|
63
66
|
prerelease: false
|
64
67
|
version_requirements: !ruby/object:Gem::Requirement
|
65
68
|
requirements:
|
66
|
-
- - "
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: 0.14.0
|
72
|
+
- - "<"
|
67
73
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
74
|
+
version: '2'
|
69
75
|
description: Fluentd parser plugin to parse log text from monolog
|
70
76
|
email:
|
71
77
|
- imunew@gmail.com
|