fluent-plugin-grep 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +0 -1
- data/Gemfile.fluentd.lt.0.10.43 +4 -0
- data/README.md +40 -14
- data/fluent-plugin-grep.gemspec +1 -1
- data/lib/fluent/plugin/out_grep.rb +7 -2
- data/spec/out_grep_spec.rb +32 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f8ed5698594f518f8856725be943ebe18632086e
|
4
|
+
data.tar.gz: c52945cd2644ff09ec8ca4ed71d3d4196fa76768
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e00ac4165583c2647cf00c1704b8bdc3d0913008ec7f0d2edc2f904b553b8b613770373df37b4575cfb9aeddfae467ac8f032b76d855bb96f2134df1804089e5
|
7
|
+
data.tar.gz: d45ed519f94552d0d84b76da994ef378021566065052e62f46932bc13223bb42b7c896938974c5fa95730b6a9f16fcf9ea570d4134e6226f4a5fd06ee8a900f0
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -4,10 +4,13 @@ Fluentd plugin to grep messages.
|
|
4
4
|
|
5
5
|
## Configuration
|
6
6
|
|
7
|
+
### Example 1:
|
8
|
+
|
7
9
|
<match foo.bar.**>
|
8
10
|
type grep
|
9
|
-
|
10
|
-
|
11
|
+
input_key message
|
12
|
+
regexp WARN
|
13
|
+
exclude favicon
|
11
14
|
add_tag_prefix greped
|
12
15
|
</source>
|
13
16
|
|
@@ -23,8 +26,43 @@ then output bocomes as belows (like, | grep WARN | grep -v favicon):
|
|
23
26
|
greped.foo.bar: {"foo":"bar","message":"2013/01/13T07:02:13.232645 WARN POST /auth"}
|
24
27
|
greped.foo.bar: {"foo":"bar","message":"2013/01/13T07:02:43.632145 WARN POST /login"}
|
25
28
|
|
29
|
+
### Example 2:
|
30
|
+
|
31
|
+
Now, `regexpN` and `excludeN` options are available to specify grep conditions for *multiple* fields.
|
32
|
+
|
33
|
+
<match foo.bar.**>
|
34
|
+
type grep
|
35
|
+
regexp1 message WARN
|
36
|
+
regexp2 foo ^awesome$
|
37
|
+
exclude1 message favicon
|
38
|
+
add_tag_prefix greped
|
39
|
+
</source>
|
40
|
+
|
41
|
+
Assuming following inputs are coming:
|
42
|
+
|
43
|
+
foo.bar: {"foo":"bar","message":"2013/01/13T07:02:11.124202 INFO GET /ping"}
|
44
|
+
foo.bar: {"foo":"awesome","message":"2013/01/13T07:02:13.232645 WARN POST /auth"}
|
45
|
+
foo.bar: {"foo":"bar","message":"2013/01/13T07:02:21.542145 WARN GET /favicon.ico"}
|
46
|
+
foo.bar: {"foo":"bar","message":"2013/01/13T07:02:43.632145 WARN POST /login"}
|
47
|
+
|
48
|
+
then output bocomes as belows:
|
49
|
+
|
50
|
+
greped.foo.bar: {"foo":"awesome","message":"2013/01/13T07:02:13.232645 WARN POST /auth"}
|
51
|
+
|
26
52
|
## Parameters
|
27
53
|
|
54
|
+
- input\_key *field\_key*
|
55
|
+
|
56
|
+
The target field key to grep out. Use with regexp or exclude.
|
57
|
+
|
58
|
+
- regexp *regexp*
|
59
|
+
|
60
|
+
The filtering regular expression
|
61
|
+
|
62
|
+
- exclude *regexp*
|
63
|
+
|
64
|
+
The excluding regular expression like grep -v
|
65
|
+
|
28
66
|
- regexp[1-20] *field\_key* *regexp*
|
29
67
|
|
30
68
|
The target field key and the filtering regular expression to grep out.
|
@@ -49,18 +87,6 @@ then output bocomes as belows (like, | grep WARN | grep -v favicon):
|
|
49
87
|
|
50
88
|
Replace invalid byte sequence in UTF-8 with '?' character if `true`
|
51
89
|
|
52
|
-
- input\_key *field\_key* (obsolete)
|
53
|
-
|
54
|
-
The target field key to grep out. Use with regexp or exclude.
|
55
|
-
|
56
|
-
- regexp *regexp* (obsolete)
|
57
|
-
|
58
|
-
The filtering regular expression
|
59
|
-
|
60
|
-
- exclude *regexp* (obsolete)
|
61
|
-
|
62
|
-
The excluding regular expression like grep -v
|
63
|
-
|
64
90
|
## ChangeLog
|
65
91
|
|
66
92
|
See [CHANGELOG.md](CHANGELOG.md) for details.
|
data/fluent-plugin-grep.gemspec
CHANGED
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "fluent-plugin-grep"
|
6
|
-
s.version = "0.3.
|
6
|
+
s.version = "0.3.2"
|
7
7
|
s.authors = ["Naotoshi Seo"]
|
8
8
|
s.email = ["sonots@gmail.com"]
|
9
9
|
s.homepage = "https://github.com/sonots/fluent-plugin-grep"
|
@@ -17,6 +17,11 @@ class Fluent::GrepOutput < Fluent::Output
|
|
17
17
|
attr_reader :regexps
|
18
18
|
attr_reader :excludes
|
19
19
|
|
20
|
+
# To support log_level option implemented by Fluentd v0.10.43
|
21
|
+
unless method_defined?(:log)
|
22
|
+
define_method("log") { $log }
|
23
|
+
end
|
24
|
+
|
20
25
|
def configure(conf)
|
21
26
|
super
|
22
27
|
|
@@ -77,8 +82,8 @@ class Fluent::GrepOutput < Fluent::Output
|
|
77
82
|
|
78
83
|
chain.next
|
79
84
|
rescue => e
|
80
|
-
|
81
|
-
|
85
|
+
log.warn e.message
|
86
|
+
log.warn e.backtrace.join(', ')
|
82
87
|
end
|
83
88
|
|
84
89
|
private
|
data/spec/out_grep_spec.rb
CHANGED
@@ -236,4 +236,36 @@ describe Fluent::GrepOutput do
|
|
236
236
|
it { emit }
|
237
237
|
end
|
238
238
|
end
|
239
|
+
|
240
|
+
describe 'test log' do
|
241
|
+
let(:log) { driver.instance.log }
|
242
|
+
|
243
|
+
def capture_log(log)
|
244
|
+
tmp = log.instance_variable_get(:@out)
|
245
|
+
out = StringIO.new
|
246
|
+
log.instance_variable_set(:@out, out)
|
247
|
+
yield log
|
248
|
+
return out.string
|
249
|
+
ensure
|
250
|
+
log.instance_variable_set(:@out, tmp)
|
251
|
+
end
|
252
|
+
|
253
|
+
if Fluent::VERSION >= "0.10.43"
|
254
|
+
context "log_level info" do
|
255
|
+
let(:config) { CONFIG + %[log_level info] }
|
256
|
+
|
257
|
+
it "should not contain debug level" do
|
258
|
+
capture_log(log) {|log| log.debug "foobar" }.should == ""
|
259
|
+
end
|
260
|
+
end
|
261
|
+
end
|
262
|
+
|
263
|
+
context "log" do
|
264
|
+
let(:config) { CONFIG }
|
265
|
+
it "should work" do
|
266
|
+
capture_log(log) {|log| log.info "foobar" }.should include("foobar")
|
267
|
+
end
|
268
|
+
end
|
269
|
+
end
|
270
|
+
|
239
271
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-grep
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Naotoshi Seo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-02-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- .travis.yml
|
109
109
|
- CHANGELOG.md
|
110
110
|
- Gemfile
|
111
|
+
- Gemfile.fluentd.lt.0.10.43
|
111
112
|
- LICENSE
|
112
113
|
- README.md
|
113
114
|
- Rakefile
|