fluent-plugin-redeliver 0.0.2 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -12,7 +12,8 @@ Simple re-delivery plugin to process log record as another tag
12
12
  regexp ^foo\.(.*)$
13
13
  replace bar.\1
14
14
  # add original tag to record['__tag'] (optional)
15
- tag_attr __tag
15
+ include_tag_key true
16
+ tag_key __tag
16
17
  </match>
17
18
 
18
19
  <match bar.**>
@@ -21,6 +22,8 @@ Simple re-delivery plugin to process log record as another tag
21
22
  </match>
22
23
  ```
23
24
 
25
+ For v0.0.2 User: `tag_attr` is obsoleted. But it works compatible with 0.0.2 now.
26
+
24
27
  ### More Effective
25
28
 
26
29
  ```
@@ -36,7 +39,8 @@ Simple re-delivery plugin to process log record as another tag
36
39
  type redeliver
37
40
  regexp ^myapp\.error\.(.*)$
38
41
  replace logging.error.\1
39
- tag_attr __tag
42
+ include_tag_key true
43
+ tag_key __tag
40
44
  </store>
41
45
  </match>
42
46
 
@@ -72,7 +76,8 @@ Simple re-delivery plugin to process log record as another tag
72
76
 
73
77
  * `regexp`: redelivers the record if tag matches specified pattern.
74
78
  * `replace`: rewrites tag for re-emit. You can use n-th matched subexpression(\1,\2...) for replace string.
75
- * `tag_attr`: adds original tag to specified key if regexp matches.
79
+ * `include_tag_key`: enables adding original tag to specified key when regexp matches.
80
+ * `tag_key`: adds original tag to specified key when include_tag_key set `true`.
76
81
 
77
82
 
78
83
  ## Installation
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |gem|
6
6
  gem.name = "fluent-plugin-redeliver"
7
- gem.version = "0.0.2"
7
+ gem.version = "0.1.0"
8
8
  gem.authors = ["Masatoshi Kawazoe (acidlemon)"]
9
9
  gem.email = ["acidlemon@beatsync.net"]
10
10
  gem.description = %q{simple tag-based redeliver plugin}
@@ -1,8 +1,13 @@
1
1
  class Fluent::RedeliverOutput < Fluent::Output
2
2
  Fluent::Plugin.register_output('redeliver', self)
3
3
 
4
+ include Fluent::SetTagKeyMixin
5
+ config_set_default :include_tag_key, false
6
+
4
7
  config_param :regexp, :string, :default => nil
5
8
  config_param :replace, :string, :default => nil
9
+
10
+ # obsolete option
6
11
  config_param :tag_attr, :string, :default => nil
7
12
 
8
13
  def initialize
@@ -11,6 +16,11 @@ class Fluent::RedeliverOutput < Fluent::Output
11
16
 
12
17
  def configure(conf)
13
18
  super
19
+
20
+ if tag_attr
21
+ @include_tag_key = true
22
+ @tag_key = tag_attr
23
+ end
14
24
  end
15
25
 
16
26
  def start
@@ -30,7 +40,7 @@ class Fluent::RedeliverOutput < Fluent::Output
30
40
  if newtag != tag and newtag.length > 0
31
41
  es.each do |time, record|
32
42
  if (record)
33
- record[tag_attr] = tag if tag_attr
43
+ filter_record(tag, time, record)
34
44
  Fluent::Engine.emit(newtag, time, record)
35
45
  end
36
46
  end
@@ -22,6 +22,7 @@ class RedeliverOutputTest < Test::Unit::TestCase
22
22
  assert_equal '^app\.(.*)\.(.*)$', d.instance.regexp
23
23
  assert_equal 'test.hoge.\1_\2', d.instance.replace
24
24
  assert_equal nil, d.instance.tag_attr
25
+ assert_equal false, d.instance.include_tag_key
25
26
 
26
27
  d = create_driver %[
27
28
  regexp ^debug\\.(.*)$
@@ -32,6 +33,21 @@ class RedeliverOutputTest < Test::Unit::TestCase
32
33
  assert_equal '^debug\.(.*)$', d.instance.regexp
33
34
  assert_equal 'ignore.\1', d.instance.replace
34
35
  assert_equal '__tag', d.instance.tag_attr
36
+ assert_equal true, d.instance.include_tag_key
37
+ assert_equal '__tag', d.instance.tag_key
38
+
39
+ d = create_driver %[
40
+ regexp ^powawa\\.(.*)$
41
+ replace powapowa.\\1
42
+ include_tag_key true
43
+ tag_key __tag__
44
+ ]
45
+
46
+ assert_equal '^powawa\.(.*)$', d.instance.regexp
47
+ assert_equal 'powapowa.\1', d.instance.replace
48
+ assert_equal nil, d.instance.tag_attr
49
+ assert_equal true, d.instance.include_tag_key
50
+ assert_equal '__tag__', d.instance.tag_key
35
51
 
36
52
  end
37
53
 
@@ -114,6 +130,32 @@ class RedeliverOutputTest < Test::Unit::TestCase
114
130
 
115
131
  assert_equal 0, emits.length
116
132
 
133
+
134
+ # v0.1.0 SetTagKeyMixIn support
135
+ d5 = create_driver %[
136
+ regexp ^powawa\\.(.*)$
137
+ replace powapowa.\\1
138
+ include_tag_key true
139
+ tag_key __tag__
140
+ ], 'powawa.standalone'
141
+
142
+ d5.run do
143
+ d5.emit({ "test" => "value5" }, now1)
144
+ end
145
+
146
+ emits = d5.emits
147
+
148
+ assert_equal 1, emits.length
149
+
150
+ assert_equal 'powapowa.standalone', emits[0][0]
151
+ assert_equal now1.to_i, emits[0][1]
152
+ assert_equal 'value5', emits[0][2]['test']
153
+ assert_equal nil, emits[0][2]['tag']
154
+ assert_equal nil, emits[0][2]['__tag']
155
+ assert_equal 'powawa.standalone', emits[0][2]['__tag__']
156
+
157
+
158
+
117
159
  end
118
160
 
119
161
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-redeliver
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
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: 2013-01-16 00:00:00.000000000 Z
12
+ date: 2013-07-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: fluentd
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  version: '0'
80
80
  requirements: []
81
81
  rubyforge_project:
82
- rubygems_version: 1.8.24
82
+ rubygems_version: 1.8.23
83
83
  signing_key:
84
84
  specification_version: 3
85
85
  summary: simple tag-based redeliver plugin