franz 1.6.5 → 1.6.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Readme.md +13 -2
- data/VERSION +1 -1
- data/lib/franz/agg.rb +8 -0
- data/lib/franz/input.rb +1 -1
- data/lib/franz/input_config.rb +75 -37
- data/test/test_franz_agg.rb +31 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b85070420e513988180b780d2a8a38d1b9814d34
|
4
|
+
data.tar.gz: 6737e0f12e74f791afcfb829647baa5046af5f4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef9f70ca09c8f20e4f56887ec557c1b34a5b8406b1b109a2bea69c10b7e4f896aa9a7f0ad57a7ba7dbd693801741bb60d6905636cff3aaead4583cdebe0a0d79
|
7
|
+
data.tar.gz: 38892366770b0622e58591d48c5b0b16ed2d4d58c350d8917602626dd6e089c64370b67c92a810805c436541927200cbf9218d63b5e0d1ae834ce6b98bb6d011
|
data/Readme.md
CHANGED
@@ -118,17 +118,28 @@ It's kinda like a JSON version of the Logstash config language:
|
|
118
118
|
"output": {
|
119
119
|
"rabbitmq": {
|
120
120
|
|
121
|
-
// Must be a consistently-hashed exchange
|
121
|
+
// Must be a consistently-hashed exchange!
|
122
122
|
"exchange": {
|
123
123
|
"name": "logs"
|
124
124
|
},
|
125
125
|
|
126
|
-
// See Bunny docs for connection configuration
|
126
|
+
// See Bunny docs for connection configuration:
|
127
|
+
// http://rubybunny.info/articles/connecting.html
|
128
|
+
// http://rubybunny.info/articles/tls.html
|
127
129
|
"connection": {
|
130
|
+
"port": 5672,
|
128
131
|
"host": "localhost",
|
129
132
|
"vhost": "/logs",
|
130
133
|
"user": "logs",
|
131
134
|
"pass": "logs"
|
135
|
+
|
136
|
+
// Sample TLS (SSL) attributes:
|
137
|
+
// "port": 5671,
|
138
|
+
// "tls": true,
|
139
|
+
// "tls_cert": "/path/to/client.cert",
|
140
|
+
// "tls_key": "/path/to/client.key",
|
141
|
+
// "tls_ca_certificates": [ "/path/to/cacert.pem" ],
|
142
|
+
// "verify_peer": true
|
132
143
|
}
|
133
144
|
}
|
134
145
|
}
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.6.
|
1
|
+
1.6.6
|
data/lib/franz/agg.rb
CHANGED
data/lib/franz/input.rb
CHANGED
data/lib/franz/input_config.rb
CHANGED
@@ -4,7 +4,12 @@ module Franz
|
|
4
4
|
|
5
5
|
def initialize configs
|
6
6
|
@configs = configs
|
7
|
+
@configs.map! do |c|
|
8
|
+
normalized_config c
|
9
|
+
end
|
7
10
|
@types = Hash.new
|
11
|
+
@drop = Hash.new
|
12
|
+
@keep = Hash.new
|
8
13
|
end
|
9
14
|
|
10
15
|
def config path
|
@@ -13,52 +18,85 @@ module Franz
|
|
13
18
|
end
|
14
19
|
|
15
20
|
def json? path
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
+
config(path)[:json?]
|
22
|
+
rescue
|
23
|
+
false
|
24
|
+
end
|
25
|
+
|
26
|
+
def keep? path, message
|
27
|
+
patterns = keeps_for(path)
|
28
|
+
return true if patterns.nil?
|
29
|
+
return true if patterns.empty?
|
30
|
+
apply_patterns patterns, message
|
21
31
|
end
|
22
32
|
|
23
33
|
def drop? path, message
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
29
|
-
if drop
|
30
|
-
drop = drop.is_a?(Array) ? drop : [ drop ]
|
31
|
-
drop.each do |pattern|
|
32
|
-
return true if message =~ pattern
|
33
|
-
end
|
34
|
-
end
|
35
|
-
return false
|
34
|
+
patterns = drops_for(path)
|
35
|
+
return true if patterns.nil?
|
36
|
+
return false if patterns.empty?
|
37
|
+
apply_patterns patterns, message
|
36
38
|
end
|
37
39
|
|
38
40
|
def type path
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
File.fnmatch? exlude, File::basename(path)
|
48
|
-
}
|
49
|
-
included && !excluded
|
41
|
+
@types.fetch path
|
42
|
+
rescue KeyError
|
43
|
+
configs.each do |config|
|
44
|
+
type = config[:type] if config[:includes].any? { |glob|
|
45
|
+
included = File.fnmatch? glob, path
|
46
|
+
excludes = !config[:excludes].nil?
|
47
|
+
excluded = excludes && config[:excludes].any? { |exlude|
|
48
|
+
File.fnmatch? exlude, File::basename(path)
|
50
49
|
}
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
50
|
+
included && !excluded
|
51
|
+
}
|
52
|
+
unless type.nil?
|
53
|
+
@types[path] = type
|
54
|
+
return type
|
55
55
|
end
|
56
|
-
log.warn \
|
57
|
-
event: 'type unknown',
|
58
|
-
file: path
|
59
|
-
@types[path] = nil
|
60
|
-
return nil
|
61
56
|
end
|
57
|
+
log.warn \
|
58
|
+
event: 'type unknown',
|
59
|
+
file: path
|
60
|
+
@types[path] = nil
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
private
|
65
|
+
def normalized_config config
|
66
|
+
config[:keep] = realize_regexps config[:keep]
|
67
|
+
config[:drop] = realize_regexps config[:drop]
|
68
|
+
config
|
62
69
|
end
|
70
|
+
|
71
|
+
def realize_regexps ps
|
72
|
+
return [] if ps.nil?
|
73
|
+
ps = ps.is_a?(Array) ? ps : [ ps ]
|
74
|
+
ps.map do |pattern|
|
75
|
+
Regexp.new pattern
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def apply_patterns patterns, message
|
80
|
+
return true if patterns.nil?
|
81
|
+
patterns.each do |pattern|
|
82
|
+
return true if message =~ pattern
|
83
|
+
end
|
84
|
+
return false
|
85
|
+
end
|
86
|
+
|
87
|
+
def drops_for path
|
88
|
+
patterns_for path, :drop, @drop
|
89
|
+
end
|
90
|
+
|
91
|
+
def keeps_for path
|
92
|
+
patterns_for path, :keep, @keep
|
93
|
+
end
|
94
|
+
|
95
|
+
def patterns_for path, kind, memo
|
96
|
+
memo.fetch path
|
97
|
+
rescue KeyError
|
98
|
+
memo[path] = config(path)[kind]
|
99
|
+
end
|
100
|
+
|
63
101
|
end
|
64
102
|
end
|
data/test/test_franz_agg.rb
CHANGED
@@ -74,6 +74,37 @@ class TestFranzAgg < MiniTest::Test
|
|
74
74
|
assert seqs[path] == 2 # should be two lines
|
75
75
|
end
|
76
76
|
|
77
|
+
def test_handles_singular_keep
|
78
|
+
sample = "keep this\nbut not this\n"
|
79
|
+
tmp = tempfile %w[ test1 .log ]
|
80
|
+
tmp.write sample
|
81
|
+
tmp.flush
|
82
|
+
tmp.close
|
83
|
+
start_agg keep: /^keep/
|
84
|
+
sleep 3
|
85
|
+
seqs = stop_agg
|
86
|
+
path = realpath tmp.path
|
87
|
+
assert seqs.include?(path)
|
88
|
+
assert_equal sample.lines.first.strip, @agg_events.shift[:message]
|
89
|
+
assert seqs[path] == 1 # should be one line
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_handles_plural_keep
|
93
|
+
sample = "keep this\nbut not this\noh this too\nreally\n"
|
94
|
+
tmp = tempfile %w[ test1 .log ]
|
95
|
+
tmp.write sample
|
96
|
+
tmp.flush
|
97
|
+
tmp.close
|
98
|
+
start_agg keep: [ /^keep/, /^oh/ ]
|
99
|
+
sleep 5
|
100
|
+
seqs = stop_agg
|
101
|
+
path = realpath tmp.path
|
102
|
+
assert seqs.include?(path)
|
103
|
+
assert_equal sample.lines[0].strip, @agg_events.shift[:message]
|
104
|
+
assert_equal sample.lines[2].strip, @agg_events.shift[:message]
|
105
|
+
assert seqs[path] == 2 # should be two lines
|
106
|
+
end
|
107
|
+
|
77
108
|
private
|
78
109
|
def tempfile prefix=nil
|
79
110
|
Tempfile.new prefix, @tmpdir
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: franz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Clemmer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slog
|