fluent-plugin-rewrite 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -37,6 +37,12 @@ matching and re-emit them.
37
37
  append_to_tag true
38
38
  fallback others
39
39
  </rule>
40
+ <rule>
41
+ key is_loggged_in
42
+ pattern 1
43
+ append_to_tag true
44
+ tag user
45
+ </rule>
40
46
  </match>
41
47
  ```
42
48
 
@@ -145,6 +151,30 @@ This time, the messabe above will be re-emmited as the message below:
145
151
  apache.log.others { "path" : "/foo/bar" }
146
152
  ```
147
153
 
154
+ If `tag` option set,
155
+
156
+ ```
157
+ <rule>
158
+ key is_loggged_in
159
+ pattern 1
160
+ append_to_tag true
161
+ tag user
162
+ </rule>
163
+ ```
164
+
165
+ the value designated by `tag` will be appended to the original tag, that is:
166
+
167
+
168
+ ```
169
+ test { "is_logged_in" => "1" }
170
+ ```
171
+
172
+ will be
173
+
174
+ ```
175
+ test.user { "is_logged_in" => "1" }
176
+ ```
177
+
148
178
  ### rule: last
149
179
 
150
180
  If you set `last` option to true, rewriting chain stops applying rule where the pattern matches first.
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = "fluent-plugin-rewrite"
3
- gem.version = '0.0.3'
3
+ gem.version = '0.0.4'
4
4
  gem.authors = ["Kentaro Kuribayashi"]
5
5
  gem.email = ["kentarok@gmail.com"]
6
6
  gem.homepage = "http://github.com/kentaro/fluent-plugin-rewrite"
@@ -93,7 +93,11 @@ module Fluent
93
93
  end
94
94
 
95
95
  if rule["append_to_tag"]
96
- matched.captures.each { |m| tag << ".#{m}" }
96
+ if rule["tag"]
97
+ tag << ".#{rule["tag"]}"
98
+ else
99
+ matched.captures.each { |m| tag << ".#{m}" }
100
+ end
97
101
  end
98
102
 
99
103
  if rule["last"]
@@ -140,6 +140,24 @@ class RewriteOutputTest < Test::Unit::TestCase
140
140
  [ "test.others", { "path" => "/unmatched/path" } ],
141
141
  d2.instance.rewrite("test", { "path" => "/unmatched/path" })
142
142
  )
143
+
144
+ d3 = create_driver(%[
145
+ <rule>
146
+ key is_logged_in
147
+ pattern 1
148
+ append_to_tag true
149
+ tag user
150
+ </rule>
151
+ ])
152
+
153
+ assert_equal(
154
+ [ "test.user", { "is_logged_in" => "1" } ],
155
+ d3.instance.rewrite("test", { "is_logged_in" => "1" })
156
+ )
157
+ assert_equal(
158
+ [ "test", { "is_logged_in" => "0" } ],
159
+ d3.instance.rewrite("test", { "is_logged_in" => "0" })
160
+ )
143
161
  end
144
162
 
145
163
  def test_last
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-rewrite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-07-01 00:00:00.000000000 Z
12
+ date: 2012-07-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake