fluent-plugin-grep 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 01c08ca3372864d443be685dbe0ef91252644612
4
- data.tar.gz: 6f7ec217ec20b890536a09de99a7fc28261c69e5
3
+ metadata.gz: 7499ce546c2a6ac26dc827f92d09132e7c31d3c6
4
+ data.tar.gz: 28fc3c637fa0827a1d89c446b657c21a28bf787c
5
5
  SHA512:
6
- metadata.gz: 7b9b72ba0eb1ae64d472f18f8c57afb53ec0f7383f20d5a2c68bd7face9eac46761376542d79b40206fe2acdfb36e786dd8008020153c7021a911c0300d1f24b
7
- data.tar.gz: 444709c11deead3423c8b5601744ecf6b420f1f95277b4fb2ff10627875a5172b52023425d5da8fd11a7619139b0fb69961f0c7a344e2bf25dbfb3b0e79185f0
6
+ metadata.gz: db775624601c8d159c1c9fd20844b2cc6439057e973a7adf6bb29229e4d3a9bcb25371bccf9b9d7a8fbba7344a347edcf7f89b80ca0c31041cb10ef5822a6f79
7
+ data.tar.gz: d873314ee6ff2b8689de0680961d2171cd65a22a6313de4d42554fff998d7fa1c814c150fce94f3a9f33e6f8ead0ffdced273e7a226a5113465a703a871430e3
data/CHANGELOG.md CHANGED
@@ -1,9 +1,19 @@
1
- ## 0.0.2
1
+ ## 0.0.3 (2013/05/14)
2
+
3
+ Features:
4
+
5
+ - Support to grep non-string jsonable values as a string
6
+
7
+ Changes:
8
+
9
+ - Default tag prefix from `grep` to `greped`.
10
+
11
+ ## 0.0.2 (2013/05/02)
2
12
 
3
13
  Features:
4
14
 
5
15
  - Add `replace_invalid_sequence` option
6
16
 
7
- ## 0.0.1
17
+ ## 0.0.1 (2013/05/02)
8
18
 
9
19
  First version
data/README.md CHANGED
@@ -4,30 +4,48 @@ Fluentd plugin to grep messages.
4
4
 
5
5
  ## Configuration
6
6
 
7
- Assume inputs from another plugin are as belows:
8
-
9
- syslog.host1: {"foo":"bar","message":"2013/01/13T07:02:11.124202 INFO GET /ping"}
10
- syslog.host1: {"foo":"bar","message":"2013/01/13T07:02:13.232645 WARN POST /auth"}
11
- syslog.host1: {"foo":"bar","message":"2013/01/13T07:02:21.542145 WARN GET /favicon.ico"}
12
- syslog.host1: {"foo":"bar","message":"2013/01/13T07:02:43.632145 WARN POST /login"}
13
-
14
- An example of grep configuration:
15
-
16
7
  <match syslog.**>
17
8
  type grep
18
9
  input_key message
19
10
  regexp WARN
20
11
  exclude favicon.ico
21
- add_tag_prefix grep
12
+ add_tag_prefix greped
22
13
  </source>
23
14
 
24
- Then, output bocomes as belows:
15
+ Assuming following inputs are coming:
16
+
17
+ foo.bar: {"foo":"bar","message":"2013/01/13T07:02:11.124202 INFO GET /ping"}
18
+ foo.bar: {"foo":"bar","message":"2013/01/13T07:02:13.232645 WARN POST /auth"}
19
+ foo.bar: {"foo":"bar","message":"2013/01/13T07:02:21.542145 WARN GET /favicon.ico"}
20
+ foo.bar: {"foo":"bar","message":"2013/01/13T07:02:43.632145 WARN POST /login"}
25
21
 
26
- grep.syslog.host1: {"foo":"bar","message":"2013/01/13T07:02:13.232645 WARN POST /auth"}
27
- grep.syslog.host1: {"foo":"bar","message":"2013/01/13T07:02:43.632145 WARN POST /login"}
22
+ then output bocomes as belows (like, | grep WARN | grep -v favicon.ico):
23
+
24
+ greped.foo.bar: {"foo":"bar","message":"2013/01/13T07:02:13.232645 WARN POST /auth"}
25
+ greped.foo.bar: {"foo":"bar","message":"2013/01/13T07:02:43.632145 WARN POST /login"}
28
26
 
29
27
  ## Parameters
30
28
 
29
+ - input_key
30
+
31
+ The target field key to grep out
32
+
33
+ - regexp
34
+
35
+ The filtering regular expression
36
+
37
+ - exclude
38
+
39
+ The excluding regular expression like grep -v
40
+
41
+ - tag
42
+
43
+ The output tag name
44
+
45
+ - add_tag_prefix
46
+
47
+ Add tag prefix for output message
48
+
31
49
  - replace_invalid_sequence
32
50
 
33
51
  Replace invalid byte sequence in UTF-8 with '?' character if `true`
@@ -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.0.2"
6
+ s.version = "0.0.3"
7
7
  s.authors = ["Naotoshi SEO"]
8
8
  s.email = ["sonots@gmail.com"]
9
9
  s.homepage = "https://github.com/sonots/fluent-plugin-grep"
@@ -5,7 +5,7 @@ class Fluent::GrepOutput < Fluent::Output
5
5
  config_param :regexp, :string, :default => nil
6
6
  config_param :exclude, :string, :default => nil
7
7
  config_param :tag, :string, :default => nil
8
- config_param :add_tag_prefix, :string, :default => 'grep'
8
+ config_param :add_tag_prefix, :string, :default => 'greped'
9
9
  config_param :replace_invalid_sequence, :bool, :default => false
10
10
 
11
11
  def configure(conf)
@@ -21,11 +21,14 @@ class Fluent::GrepOutput < Fluent::Output
21
21
 
22
22
  es.each do |time,record|
23
23
  value = record[@input_key]
24
- next unless match(value)
24
+ next unless match(value.to_s)
25
25
  Fluent::Engine.emit(emit_tag, time, record)
26
26
  end
27
27
 
28
28
  chain.next
29
+ rescue => e
30
+ $log.warn e.message
31
+ $log.warn e.backtrace.join(', ')
29
32
  end
30
33
 
31
34
  private
@@ -26,7 +26,7 @@ describe Fluent::GrepOutput do
26
26
  its(:regexp) { should be_nil }
27
27
  its(:exclude) { should be_nil }
28
28
  its(:tag) { should be_nil }
29
- its(:add_tag_prefix) { should == 'grep' }
29
+ its(:add_tag_prefix) { should == 'greped' }
30
30
  end
31
31
  end
32
32
  end
@@ -49,10 +49,10 @@ describe Fluent::GrepOutput do
49
49
  let(:config) { CONFIG }
50
50
  before do
51
51
  Fluent::Engine.stub(:now).and_return(time)
52
- Fluent::Engine.should_receive(:emit).with("grep.#{tag}", time, {'foo'=>'bar', 'message'=>"2013/01/13T07:02:11.124202 INFO GET /ping"})
53
- Fluent::Engine.should_receive(:emit).with("grep.#{tag}", time, {'foo'=>'bar', 'message'=>"2013/01/13T07:02:13.232645 WARN POST /auth"})
54
- Fluent::Engine.should_receive(:emit).with("grep.#{tag}", time, {'foo'=>'bar', 'message'=>"2013/01/13T07:02:21.542145 WARN GET /favicon.ico"})
55
- Fluent::Engine.should_receive(:emit).with("grep.#{tag}", time, {'foo'=>'bar', 'message'=>"2013/01/13T07:02:43.632145 WARN POST /login"})
52
+ Fluent::Engine.should_receive(:emit).with("greped.#{tag}", time, {'foo'=>'bar', 'message'=>"2013/01/13T07:02:11.124202 INFO GET /ping"})
53
+ Fluent::Engine.should_receive(:emit).with("greped.#{tag}", time, {'foo'=>'bar', 'message'=>"2013/01/13T07:02:13.232645 WARN POST /auth"})
54
+ Fluent::Engine.should_receive(:emit).with("greped.#{tag}", time, {'foo'=>'bar', 'message'=>"2013/01/13T07:02:21.542145 WARN GET /favicon.ico"})
55
+ Fluent::Engine.should_receive(:emit).with("greped.#{tag}", time, {'foo'=>'bar', 'message'=>"2013/01/13T07:02:43.632145 WARN POST /login"})
56
56
  end
57
57
  it { emit }
58
58
  end
@@ -65,9 +65,9 @@ describe Fluent::GrepOutput do
65
65
  end
66
66
  before do
67
67
  Fluent::Engine.stub(:now).and_return(time)
68
- Fluent::Engine.should_receive(:emit).with("grep.#{tag}", time, {'foo'=>'bar', 'message'=>"2013/01/13T07:02:13.232645 WARN POST /auth"})
69
- Fluent::Engine.should_receive(:emit).with("grep.#{tag}", time, {'foo'=>'bar', 'message'=>"2013/01/13T07:02:21.542145 WARN GET /favicon.ico"})
70
- Fluent::Engine.should_receive(:emit).with("grep.#{tag}", time, {'foo'=>'bar', 'message'=>"2013/01/13T07:02:43.632145 WARN POST /login"})
68
+ Fluent::Engine.should_receive(:emit).with("greped.#{tag}", time, {'foo'=>'bar', 'message'=>"2013/01/13T07:02:13.232645 WARN POST /auth"})
69
+ Fluent::Engine.should_receive(:emit).with("greped.#{tag}", time, {'foo'=>'bar', 'message'=>"2013/01/13T07:02:21.542145 WARN GET /favicon.ico"})
70
+ Fluent::Engine.should_receive(:emit).with("greped.#{tag}", time, {'foo'=>'bar', 'message'=>"2013/01/13T07:02:43.632145 WARN POST /login"})
71
71
  end
72
72
  it { emit }
73
73
  end
@@ -80,9 +80,9 @@ describe Fluent::GrepOutput do
80
80
  end
81
81
  before do
82
82
  Fluent::Engine.stub(:now).and_return(time)
83
- Fluent::Engine.should_receive(:emit).with("grep.#{tag}", time, {'foo'=>'bar', 'message'=>"2013/01/13T07:02:11.124202 INFO GET /ping"})
84
- Fluent::Engine.should_receive(:emit).with("grep.#{tag}", time, {'foo'=>'bar', 'message'=>"2013/01/13T07:02:13.232645 WARN POST /auth"})
85
- Fluent::Engine.should_receive(:emit).with("grep.#{tag}", time, {'foo'=>'bar', 'message'=>"2013/01/13T07:02:43.632145 WARN POST /login"})
83
+ Fluent::Engine.should_receive(:emit).with("greped.#{tag}", time, {'foo'=>'bar', 'message'=>"2013/01/13T07:02:11.124202 INFO GET /ping"})
84
+ Fluent::Engine.should_receive(:emit).with("greped.#{tag}", time, {'foo'=>'bar', 'message'=>"2013/01/13T07:02:13.232645 WARN POST /auth"})
85
+ Fluent::Engine.should_receive(:emit).with("greped.#{tag}", time, {'foo'=>'bar', 'message'=>"2013/01/13T07:02:43.632145 WARN POST /login"})
86
86
  end
87
87
  it { emit }
88
88
  end
@@ -134,7 +134,40 @@ describe Fluent::GrepOutput do
134
134
  end
135
135
  end
136
136
 
137
- end
137
+ describe 'grep non-string jsonable values' do
138
+ let(:config) { CONFIG + %[regexp 0] }
139
+ let(:message) { 0 }
140
+ let(:time) { Time.now.to_i }
141
+ let(:emit) { driver.run { driver.emit({'foo'=>'bar', 'message' => message}, time) } }
142
+ before do
143
+ Fluent::Engine.stub(:now).and_return(time)
144
+ Fluent::Engine.should_receive(:emit).with("greped.#{tag}", time, {'foo'=>'bar', 'message'=>message})
145
+ end
138
146
 
147
+ context "array" do
148
+ let(:message) { ["0"] }
149
+ it { emit }
150
+ end
139
151
 
152
+ context "hash" do
153
+ let(:message) { ["0"=>"0"] }
154
+ it { emit }
155
+ end
140
156
 
157
+ context "integer" do
158
+ let(:message) { 0 }
159
+ it { emit }
160
+ end
161
+
162
+ context "float" do
163
+ let(:message) { 0.1 }
164
+ it { emit }
165
+ end
166
+
167
+ context "boolean" do
168
+ let(:config) { CONFIG + %[regexp true] }
169
+ let(:message) { true }
170
+ it { emit }
171
+ end
172
+ end
173
+ 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.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naotoshi SEO
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-05-02 00:00:00.000000000 Z
11
+ date: 2013-05-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd