fluent-plugin-rewrite-tag-filter 2.2.0 → 2.3.0

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
  SHA256:
3
- metadata.gz: 8253bb2b1859438ea797e1fd2046d0b18290a424b340de8a88524b9afd33388a
4
- data.tar.gz: 33e91a5b0570810f2ad802885df4a7e87eb03c4816b5779d847c5004b25afb0a
3
+ metadata.gz: a4e1ce31eba327c311153c8eb2e96b8aef667bca6b92f9695c7b5a3fb11e7d58
4
+ data.tar.gz: fc5e7682a7476dffcfdef523f06401508dcb888d3b4cff39edab742950bf9506
5
5
  SHA512:
6
- metadata.gz: f28d04ee233a9bfdd668f5dc114b7e9b7d5531d275d1c5318100d4a76171607ddf9e03041081b139ba2f7a55b6b73bdbf64c44cae67097df983ae80395d04e69
7
- data.tar.gz: 4e6ee684e6da26e6d0e449cc0650dd482f9cbd5cd6623d540bb63b1b991e48f0ede38f9424f04ef8750e6d7f451afa62c89bda412e3bff66589b3101407414d3
6
+ metadata.gz: '018336a8cf161d92674c7845fc021f4b01a11ce0762ff555067707345671b7d7b40d63f84ce308493beb36ce90ed581c90788905bdb0c14dc62125349ebcdc31'
7
+ data.tar.gz: ecbd7f9591d477aba1fa776a58648e04ac085f442ec685aefbd0dc7d48160c3ca2cd819fc79bc3a59910aa8c5663d595c0339f8e7ab14f32b2d7f542667add00
@@ -1,10 +1,10 @@
1
1
  language: ruby
2
2
 
3
3
  rvm:
4
- - 2.4.2
5
- - 2.3.5
6
- - 2.2
7
- - 2.1
4
+ - 2.7.0
5
+ - 2.6.5
6
+ - 2.5.7
7
+ - 2.4.9
8
8
 
9
9
  # to avoid travis-ci issue since 2015-12-25
10
10
  before_install:
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  ## Overview
4
4
 
5
5
  Rewrite Tag Filter for [Fluentd](http://fluentd.org). It is designed to rewrite tags like mod_rewrite.
6
- Re-emit the record with rewrited tag when a value matches/unmatches with a regular expression.
6
+ Re-emit the record with rewritten tag when a value matches/unmatches with a regular expression.
7
7
  Also you can change a tag from Apache log by domain, status code (ex. 500 error),
8
8
  user-agent, request-uri, regex-backreference and so on with regular expression.
9
9
 
@@ -31,7 +31,7 @@ $ sudo td-agent-gem install fluent-plugin-rewrite-tag-filter -v 1.6.0
31
31
  $ sudo td-agent-gem install fluent-plugin-rewrite-tag-filter
32
32
  ```
33
33
 
34
- For more details, see [Plugin Management](https://docs.fluentd.org/v0.14/articles/plugin-management)
34
+ For more details, see [Plugin Management](https://docs.fluentd.org/deployment/plugin-management)
35
35
 
36
36
  ## Configuration
37
37
 
@@ -200,7 +200,7 @@ When original tag is `kubernetes.var.log`, this will be converted to `default.ku
200
200
 
201
201
  ### Tag placeholder
202
202
 
203
- It is supported these placeholder for new_tag (rewrited tag).
203
+ It is supported these placeholder for new_tag (rewritten tag).
204
204
 
205
205
  - `${tag}`
206
206
  - `__TAG__`
@@ -214,12 +214,16 @@ For example with `td.apache.access` tag, it will get `td` by `${tag_parts[0]}` a
214
214
 
215
215
  **Note** Currently, range expression ```${tag_parts[0..2]}``` is not supported.
216
216
 
217
- #### Placeholder Option
217
+ #### Placeholder Options
218
218
 
219
219
  * `remove_tag_prefix`
220
220
 
221
221
  This option adds removing tag prefix for `${tag}` or `__TAG__` in placeholder.
222
222
 
223
+ * `remove_tag_regexp`
224
+
225
+ This option adds removing tag regexp for `${tag}` or `__TAG__` in placeholder.
226
+
223
227
  * `hostname_command`
224
228
 
225
229
  By default, execute command as `hostname` to get full hostname.
@@ -231,45 +235,67 @@ It comes short hostname with `hostname_command hostname -s` configuration specif
231
235
  It's a sample to rewrite a tag with placeholder.
232
236
 
233
237
  ```
234
- # It will get "rewrited.access.ExampleMail"
238
+ # It will get "rewritten.access.ExampleMail"
235
239
  <match apache.access>
236
240
  @type rewrite_tag_filter
237
241
  remove_tag_prefix apache
238
242
  <rule>
239
243
  key domain
240
244
  pattern ^(mail)\.(example)\.com$
241
- tag rewrited.${tag}.$2$1
245
+ tag rewritten.${tag}.$2$1
246
+ </rule>
247
+ </match>
248
+
249
+ # It will get "rewritten.access.ExampleMail"
250
+ <match apache.access>
251
+ @type rewrite_tag_filter
252
+ remove_tag_regexp /^apache\./
253
+ <rule>
254
+ key domain
255
+ pattern ^(mail)\.(example)\.com$
256
+ tag rewritten.${tag}.$2$1
257
+ </rule>
258
+ </match>
259
+
260
+ # It will get "http.access.log"
261
+ <match input.{apache,nginx}.access.log>
262
+ @type rewrite_tag_filter
263
+ remove_tag_regexp /^input\.(apache|nginx)\./
264
+ <rule>
265
+ key domain
266
+ pattern ^.+$
267
+ tag http.${tag}
242
268
  </rule>
243
269
  </match>
244
270
 
245
- # It will get "rewrited.ExampleMail.app30-124.foo.com" when hostname is "app30-124.foo.com"
271
+ # It will get "rewritten.ExampleMail.app30-124.foo.com" when hostname is "app30-124.foo.com"
246
272
  <match apache.access>
247
273
  @type rewrite_tag_filter
248
274
  <rule>
249
275
  key domain
250
276
  pattern ^(mail)\.(example)\.com$
251
- tag rewrited.$2$1.${hostname}
277
+ tag rewritten.$2$1.${hostname}
252
278
  </rule>
253
279
  </match>
254
280
 
255
- # It will get "rewrited.ExampleMail.app30-124" when hostname is "app30-124.foo.com"
281
+ # It will get "rewritten.ExampleMail.app30-124" when hostname is "app30-124.foo.com"
256
282
  <match apache.access>
257
283
  @type rewrite_tag_filter
258
284
  hostname_command hostname -s
259
285
  <rule>
260
286
  key domain
261
287
  pattern ^(mail)\.(example)\.com$
262
- tag rewrited.$2$1.${hostname}
288
+ tag rewritten.$2$1.${hostname}
263
289
  </rule>
264
290
  </match>
265
291
 
266
- # It will get "rewrited.game.pool"
292
+ # It will get "rewritten.game.pool"
267
293
  <match app.game.pool.activity>
268
294
  @type rewrite_tag_filter
269
295
  <rule>
270
296
  key domain
271
297
  pattern ^.+$
272
- tag rewrited.${tag_parts[1]}.${tag_parts[2]}
298
+ tag rewritten.${tag_parts[1]}.${tag_parts[2]}
273
299
  </rule>
274
300
  </match>
275
301
  ```
@@ -1,9 +1,8 @@
1
- # -*- encoding: utf-8 -*-
2
1
  $:.push File.expand_path("../lib", __FILE__)
3
2
 
4
3
  Gem::Specification.new do |s|
5
4
  s.name = "fluent-plugin-rewrite-tag-filter"
6
- s.version = "2.2.0"
5
+ s.version = "2.3.0"
7
6
  s.license = "Apache-2.0"
8
7
  s.authors = ["Kentaro Yoshida"]
9
8
  s.email = ["y.ken.studio@gmail.com"]
@@ -10,6 +10,8 @@ class Fluent::Plugin::RewriteTagFilterOutput < Fluent::Plugin::Output
10
10
  config_param :capitalize_regex_backreference, :bool, :default => false
11
11
  desc 'Remove tag prefix for tag placeholder.'
12
12
  config_param :remove_tag_prefix, :string, :default => nil
13
+ desc "Remove tag regexp for tag placeholder."
14
+ config_param :remove_tag_regexp, :regexp, default: nil
13
15
  desc 'Override hostname command for placeholder.'
14
16
  config_param :hostname_command, :string, :default => 'hostname'
15
17
  desc "The emit mode. If `batch`, this plugin will emit events per rewritten tag."
@@ -58,8 +60,12 @@ class Fluent::Plugin::RewriteTagFilterOutput < Fluent::Plugin::Output
58
60
  raise Fluent::ConfigError, "duplicated rewriterules found #{@rewriterules.inspect}"
59
61
  end
60
62
 
63
+ if @remove_tag_prefix && @remove_tag_regexp
64
+ raise Fluent::ConfigError, "remove_tag_prefix and remove_tag_regexp are exclusive"
65
+ end
66
+
61
67
  unless @remove_tag_prefix.nil?
62
- @remove_tag_prefix = /^#{Regexp.escape(@remove_tag_prefix)}\.?/
68
+ @remove_tag_regexp = /^#{Regexp.escape(@remove_tag_prefix)}\.?/
63
69
  end
64
70
 
65
71
  @batch_mode = @emit_mode == :batch
@@ -135,7 +141,7 @@ class Fluent::Plugin::RewriteTagFilterOutput < Fluent::Plugin::Output
135
141
  end
136
142
 
137
143
  def get_placeholder(tag)
138
- tag = tag.sub(@remove_tag_prefix, '') if @remove_tag_prefix
144
+ tag = tag.sub(@remove_tag_regexp, '') if @remove_tag_regexp
139
145
 
140
146
  result = {
141
147
  '__HOSTNAME__' => @hostname,
@@ -41,6 +41,21 @@ class RewriteTagFilterOutputTest < Test::Unit::TestCase
41
41
  d = create_driver(conf)
42
42
  assert_equal(/.+/, d.instance.rules.first.pattern)
43
43
  end
44
+
45
+ test "remove_tag_prefix and remove_tag_regexp are exclusive" do
46
+ conf = %[
47
+ remove_tag_prefix prefix
48
+ remove_tag_regexp /^prefix\./
49
+ <rule>
50
+ key message
51
+ pattern .+
52
+ tag ${tag}
53
+ </rule>
54
+ ]
55
+ assert_raise(Fluent::ConfigError) do
56
+ create_driver(conf)
57
+ end
58
+ end
44
59
  end
45
60
 
46
61
  sub_test_case "section style" do
@@ -127,6 +142,30 @@ class RewriteTagFilterOutputTest < Test::Unit::TestCase
127
142
  assert_equal 'access', events[0][0] # tag
128
143
  end
129
144
 
145
+ sub_test_case "remove_tag_regexp" do
146
+ test "plain" do
147
+ config = %[
148
+ remove_tag_regexp /^input\.(apache|nginx)\./
149
+ <rule>
150
+ key domain
151
+ pattern ^www\.google\.com$
152
+ tag rewritten.${tag}
153
+ </rule>
154
+ ]
155
+ d = create_driver(config)
156
+ d.run do
157
+ d.feed('input.apache.access', event_time, {'domain' => 'www.google.com', 'path' => '/foo/bar?key=value', 'agent' => 'Googlebot', 'response_time' => 1000000})
158
+ d.feed('input.nginx.access', event_time, {'domain' => 'www.google.com', 'path' => '/foo/bar?key=value', 'agent' => 'Googlebot', 'response_time' => 1000000})
159
+ d.feed('input.tomcat.access', event_time, {'domain' => 'www.google.com', 'path' => '/foo/bar?key=value', 'agent' => 'Googlebot', 'response_time' => 1000000})
160
+ end
161
+ events = d.events
162
+ assert_equal 3, events.length
163
+ assert_equal 'rewritten.access', events[0][0]
164
+ assert_equal 'rewritten.access', events[1][0]
165
+ assert_equal 'rewritten.input.tomcat.access', events[2][0]
166
+ end
167
+ end
168
+
130
169
  test "short hostname" do
131
170
  config = %[
132
171
  remove_tag_prefix input
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-rewrite-tag-filter
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kentaro Yoshida
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-12 00:00:00.000000000 Z
11
+ date: 2020-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-unit
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
124
124
  - !ruby/object:Gem::Version
125
125
  version: '0'
126
126
  requirements: []
127
- rubygems_version: 3.0.1
127
+ rubygems_version: 3.1.2
128
128
  signing_key:
129
129
  specification_version: 4
130
130
  summary: Fluentd Output filter plugin. It has designed to rewrite tag like mod_rewrite.