fluent-plugin-multi-format-parser 0.1.1 → 1.0.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 +51 -19
- data/VERSION +1 -1
- data/fluent-plugin-multi-format-parser.gemspec +1 -1
- data/lib/fluent/plugin/parser_multi_format.rb +29 -83
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da4c776b74c85a0624c5cc7f899b041ff8b0c196
|
4
|
+
data.tar.gz: 866aa7acf91781fdb2959c69ad8d94375f0f569c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 86375df425d675d69613190c69ab05a8d0e304ce51e9456d2338b1ba9dd2c2070c33d9347b2f05c9ec245794f9e1937c8c0afe3bb1d29b7852637202f2918c4a
|
7
|
+
data.tar.gz: 87b2222ffa0188677498299b7570109f4cc11ac4a4a7e0a4c012ec4dccb82a6b54a33cedb0de2cdccbcdd44e7cf8d0b5f9f3cf6e163f2ebe2e3152c6d4704326
|
data/README.md
CHANGED
@@ -2,6 +2,13 @@
|
|
2
2
|
|
3
3
|
Parse format mixed logs.
|
4
4
|
|
5
|
+
## Requirements
|
6
|
+
|
7
|
+
| fluent-plugin-multi-format-parser | fluentd | ruby |
|
8
|
+
|-------------------|---------|------|
|
9
|
+
| >= 1.0.0 | >= v0.14.0 | >= 2.1 |
|
10
|
+
| < 1.0.0 | >= v0.12.0 | >= 1.9 |
|
11
|
+
|
5
12
|
## Installation
|
6
13
|
|
7
14
|
Use RubyGems:
|
@@ -10,50 +17,75 @@ Use RubyGems:
|
|
10
17
|
|
11
18
|
## Configuration
|
12
19
|
|
13
|
-
This plugin is a parser plugin. After installed, you can use `multi_format` in
|
14
|
-
Use multiple `<pattern>` to specify multiple
|
20
|
+
This plugin is a parser plugin. After installed, you can use `multi_format` in `<parse>` supported plugins.
|
21
|
+
Use multiple `<pattern>`s to specify multiple parser formats.
|
15
22
|
|
16
23
|
<source>
|
17
24
|
@type udp
|
18
25
|
tag logs.multi
|
19
26
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
27
|
+
<parse>
|
28
|
+
@type multi_format
|
29
|
+
<pattern>
|
30
|
+
format apache
|
31
|
+
</pattern>
|
32
|
+
<pattern>
|
33
|
+
format json
|
34
|
+
time_key timestamp
|
35
|
+
</pattern>
|
36
|
+
<pattern>
|
37
|
+
format none
|
38
|
+
</pattern>
|
39
|
+
</parse>
|
40
|
+
</source>
|
32
41
|
|
33
42
|
`multi_format` tries pattern matching from top to bottom and returns parsed result when matched.
|
34
43
|
|
35
44
|
Available format patterns and parameters are depends on Fluentd parsers.
|
36
|
-
See [
|
45
|
+
See [parser plugin document](http://docs.fluentd.org/v1.0/articles/parser-plugin-overview) for more details.
|
37
46
|
|
38
|
-
### For v0.14
|
47
|
+
### For v1.0/v0.14
|
39
48
|
|
40
|
-
|
41
|
-
If you want to use this plugin with v0.14, you need to use v0.14 parser syntax like below
|
49
|
+
Put `<pattern>`s inside `<parse>`.
|
42
50
|
|
43
51
|
<filter app.**>
|
44
52
|
@type parser
|
45
53
|
key_name message
|
46
|
-
<parse>
|
54
|
+
<parse>
|
47
55
|
@type multi_format
|
48
56
|
<pattern>
|
49
57
|
format json
|
50
58
|
</pattern>
|
59
|
+
<pattern>
|
60
|
+
format regexp
|
61
|
+
expression /...your regexp pattern.../
|
62
|
+
</pattern>
|
51
63
|
<pattern>
|
52
64
|
format none
|
53
65
|
</pattern>
|
54
66
|
</parse>
|
55
67
|
</filter>
|
56
68
|
|
69
|
+
### For v0.12
|
70
|
+
|
71
|
+
Use `format` instead of `<parse></parse>`.
|
72
|
+
|
73
|
+
<filter app.**>
|
74
|
+
@type parser
|
75
|
+
key_name message
|
76
|
+
|
77
|
+
format multi_format
|
78
|
+
<pattern>
|
79
|
+
format json
|
80
|
+
</pattern>
|
81
|
+
<pattern>
|
82
|
+
format /...your regexp pattern.../
|
83
|
+
</pattern>
|
84
|
+
<pattern>
|
85
|
+
format none
|
86
|
+
</pattern>
|
87
|
+
</filter>
|
88
|
+
|
57
89
|
### NOTE
|
58
90
|
|
59
91
|
This plugin doesn't work with `multiline` parsers because parser itself doesn't store previous lines.
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
1.0.0
|
@@ -17,6 +17,6 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
18
|
gem.require_paths = ['lib']
|
19
19
|
|
20
|
-
gem.add_dependency "fluentd", [">= 0.
|
20
|
+
gem.add_dependency "fluentd", [">= 0.14.0", "< 2"]
|
21
21
|
gem.add_development_dependency "rake", ">= 0.9.2"
|
22
22
|
end
|
@@ -1,98 +1,44 @@
|
|
1
|
-
require 'fluent/parser'
|
1
|
+
require 'fluent/plugin/parser'
|
2
2
|
|
3
3
|
module Fluent
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
Plugin.register_parser('multi_format', self)
|
4
|
+
module Plugin
|
5
|
+
class MultiFormatParser < Parser
|
6
|
+
Plugin.register_parser('multi_format', self)
|
8
7
|
|
9
|
-
|
10
|
-
|
8
|
+
def initialize
|
9
|
+
super
|
11
10
|
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
def configure(conf)
|
16
|
-
super
|
17
|
-
|
18
|
-
conf.elements.each { |e|
|
19
|
-
next unless ['pattern', 'format'].include?(e.name)
|
20
|
-
next if e['format'].nil? && (e['@type'] == 'multi_format')
|
21
|
-
|
22
|
-
parser = Plugin.new_parser(e['format'])
|
23
|
-
parser.configure(e)
|
24
|
-
@parsers << parser
|
25
|
-
}
|
26
|
-
end
|
27
|
-
|
28
|
-
def parse(text)
|
29
|
-
@parsers.each { |parser|
|
30
|
-
begin
|
31
|
-
parser.parse(text) { |time, record|
|
32
|
-
if time && record
|
33
|
-
yield time, record
|
34
|
-
return
|
35
|
-
end
|
36
|
-
}
|
37
|
-
rescue # ignore parser error
|
38
|
-
end
|
39
|
-
}
|
40
|
-
|
41
|
-
yield nil, nil
|
42
|
-
end
|
11
|
+
@parsers = []
|
43
12
|
end
|
44
|
-
else # support old API. Will be removed.
|
45
|
-
class MultiFormatParser
|
46
|
-
include Configurable
|
47
13
|
|
48
|
-
|
49
|
-
|
14
|
+
def configure(conf)
|
15
|
+
super
|
50
16
|
|
51
|
-
|
52
|
-
|
17
|
+
conf.elements.each { |e|
|
18
|
+
next unless ['pattern', 'format'].include?(e.name)
|
19
|
+
next if e['format'].nil? && (e['@type'] == 'multi_format')
|
53
20
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
parser = TextParser.new
|
61
|
-
parser.configure(e)
|
62
|
-
@parsers << parser.parser
|
63
|
-
}
|
64
|
-
end
|
65
|
-
|
66
|
-
def parse(text)
|
67
|
-
@parsers.each { |parser|
|
68
|
-
begin
|
69
|
-
parser.call(text) { |time, record|
|
70
|
-
if time && record
|
71
|
-
if block_given?
|
72
|
-
yield time, record
|
73
|
-
return
|
74
|
-
else
|
75
|
-
return time, record
|
76
|
-
end
|
77
|
-
end
|
78
|
-
}
|
79
|
-
rescue # ignore parser error
|
80
|
-
end
|
81
|
-
}
|
21
|
+
parser = Plugin.new_parser(e['format'])
|
22
|
+
parser.configure(e)
|
23
|
+
@parsers << parser
|
24
|
+
}
|
25
|
+
end
|
82
26
|
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
27
|
+
def parse(text)
|
28
|
+
@parsers.each { |parser|
|
29
|
+
begin
|
30
|
+
parser.parse(text) { |time, record|
|
31
|
+
if time && record
|
32
|
+
yield time, record
|
33
|
+
return
|
34
|
+
end
|
35
|
+
}
|
36
|
+
rescue # ignore parser error
|
87
37
|
end
|
88
|
-
|
38
|
+
}
|
89
39
|
|
90
|
-
|
91
|
-
parse(*a, &b)
|
92
|
-
end
|
40
|
+
yield nil, nil
|
93
41
|
end
|
94
|
-
|
95
|
-
register_template('multi_format', Proc.new { MultiFormatParser.new })
|
96
42
|
end
|
97
43
|
end
|
98
44
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-multi-format-parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masahiro Nakagawa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-12-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.
|
19
|
+
version: 0.14.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '2'
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 0.
|
29
|
+
version: 0.14.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '2'
|
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
77
77
|
version: '0'
|
78
78
|
requirements: []
|
79
79
|
rubyforge_project:
|
80
|
-
rubygems_version: 2.
|
80
|
+
rubygems_version: 2.6.13
|
81
81
|
signing_key:
|
82
82
|
specification_version: 4
|
83
83
|
summary: Multi format parser plugin for Fluentd
|