fluent-plugin-filter-parse-postfix 0.2.5 → 0.2.6
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
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b33cd07e187b679a65cac69b0ae4cd01baadd6d
|
4
|
+
data.tar.gz: e9786672b2557cac83ba517f9093402ea2128d9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6c5f72e1e9cf9acdc438336cd385557de9057c2298442a2fab1c14b4d89e75138f19da7cca0413f171c22f0f67f01d71e253b1bbc40c89723ba30b11c43e7831
|
7
|
+
data.tar.gz: 5a9117c1efac16ae25e91ddf47753888dc85b46a9b19ccaf07d9b94503f686142a2a085e443bf9ff5a5615513958a18320643961161026b2bb4de93c2b40f5b7
|
data/README.md
CHANGED
@@ -31,6 +31,7 @@ Or install it yourself as:
|
|
31
31
|
#include_hash false
|
32
32
|
#salt my_salt
|
33
33
|
#sha_algorithm 512 # 1, 224, 256, 384, 512 (default)
|
34
|
+
#header_checks_warning false
|
34
35
|
</filter>
|
35
36
|
```
|
36
37
|
|
@@ -92,3 +93,34 @@ see https://github.com/winebarrel/postfix_status_line
|
|
92
93
|
"status_detail":"(250 ok ; id=en4req0070M63004172202102)"
|
93
94
|
}
|
94
95
|
```
|
96
|
+
|
97
|
+
### Parse Header Checks Warning
|
98
|
+
|
99
|
+
```sh
|
100
|
+
$ cat fluent.conf
|
101
|
+
...
|
102
|
+
<filter postfix.maillog>
|
103
|
+
@type grep
|
104
|
+
regexp1 message warning: header
|
105
|
+
</filter>
|
106
|
+
|
107
|
+
<filter postfix.maillog>
|
108
|
+
@type parse_postfix
|
109
|
+
header_checks_warning true
|
110
|
+
</filter>
|
111
|
+
...
|
112
|
+
|
113
|
+
$ fluentd -c fluent.conf
|
114
|
+
```
|
115
|
+
|
116
|
+
```sh
|
117
|
+
$ echo '{"message":"Mar 4 14:44:19 P788 postfix/cleanup[7426]: E80A9DF6F7E: warning: header Subject: test from local; from=<sugawara@P788.local> to=<sgwr_dts@yahoo.co.jp>"}' | fluent-cat postfix.maillog
|
118
|
+
#=> 2017-03-04 18:26:46.146399000 +0900 postfix.maillog: {
|
119
|
+
# "time":"Mar 4 14:44:19","hostname":"P788",
|
120
|
+
# "process":"postfix/cleanup[7426]",
|
121
|
+
# "queue_id":"E80A9DF6F7E",
|
122
|
+
# "to":"********@yahoo.co.jp",
|
123
|
+
# "domain":"yahoo.co.jp",
|
124
|
+
# "from":"********@P788.local",
|
125
|
+
# "Subject":"test from local;"}
|
126
|
+
```
|
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.require_paths = ['lib']
|
21
21
|
|
22
22
|
spec.add_dependency 'fluentd', '>= 0.12'
|
23
|
-
spec.add_dependency 'postfix_status_line', '~> 0.2.
|
23
|
+
spec.add_dependency 'postfix_status_line', '~> 0.2.7'
|
24
24
|
|
25
25
|
spec.add_development_dependency 'bundler'
|
26
26
|
spec.add_development_dependency 'rake'
|
@@ -6,46 +6,40 @@ module Fluent
|
|
6
6
|
class ParsePostfixFilter < Filter
|
7
7
|
Plugin.register_filter('parse_postfix', self)
|
8
8
|
|
9
|
-
config_param :key,
|
10
|
-
config_param :mask,
|
11
|
-
config_param :use_log_time,
|
12
|
-
config_param :include_hash,
|
13
|
-
config_param :salt,
|
14
|
-
config_param :sha_algorithm,
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
es.each do |time, record|
|
20
|
-
parse_postfix(time, record, result_es)
|
21
|
-
end
|
22
|
-
|
23
|
-
result_es
|
24
|
-
end
|
25
|
-
|
26
|
-
private
|
27
|
-
|
28
|
-
def parse_postfix(time, record, result_es)
|
9
|
+
config_param :key, :string, :default => 'message'
|
10
|
+
config_param :mask, :bool, :default => true
|
11
|
+
config_param :use_log_time , :bool, :default => false
|
12
|
+
config_param :include_hash, :bool, :default => false
|
13
|
+
config_param :salt, :string, :default => nil
|
14
|
+
config_param :sha_algorithm, :integer, :default => nil
|
15
|
+
config_param :header_checks_warning, :bool, :default => false
|
16
|
+
|
17
|
+
def filter(tag, time, record)
|
29
18
|
line = record[@key]
|
30
|
-
return unless line
|
19
|
+
return record unless line
|
20
|
+
|
21
|
+
options = {mask: @mask, hash: @include_hash, salt: @salt, parse_time: @use_log_time, sha_algorithm: @sha_algorithm}
|
31
22
|
|
32
|
-
|
33
|
-
line,
|
34
|
-
|
23
|
+
if @header_checks_warning
|
24
|
+
parsed = PostfixStatusLine.parse_header_checks_warning(line, options)
|
25
|
+
else
|
26
|
+
parsed = PostfixStatusLine.parse(line, options)
|
27
|
+
end
|
35
28
|
|
36
29
|
unless parsed
|
37
30
|
log.warn "cannot parse a postfix log: #{line}"
|
38
|
-
return
|
31
|
+
return record
|
39
32
|
end
|
40
33
|
|
41
34
|
if @use_log_time and parsed['epoch']
|
42
35
|
time = parsed.delete('epoch')
|
43
36
|
end
|
44
37
|
|
45
|
-
|
38
|
+
parsed
|
46
39
|
rescue => e
|
47
40
|
log.warn "failed to parse a postfix log: #{line}", :error_class => e.class, :error => e.message
|
48
41
|
log.warn_backtrace
|
42
|
+
record
|
49
43
|
end
|
50
44
|
end
|
51
45
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-filter-parse-postfix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genki Sugawara
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-03-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.2.
|
33
|
+
version: 0.2.7
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.2.
|
40
|
+
version: 0.2.7
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|