fluent-plugin-rewrite-tag-filter 1.3.0 → 1.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md
CHANGED
@@ -24,7 +24,7 @@ gem install fluent-plugin-rewrite-tag-filter
|
|
24
24
|
### Syntax
|
25
25
|
|
26
26
|
```
|
27
|
-
rewriterule<num
|
27
|
+
rewriterule<num> <attribute> <regex_pattern> <new_tag>
|
28
28
|
|
29
29
|
# Optional: Capitalize every matched regex backreference. (ex: $1, $2)
|
30
30
|
capitalize_regex_backreference <yes/no> (default no)
|
@@ -176,9 +176,16 @@ https://gist.github.com/matsumana/4078096
|
|
176
176
|
- 稼働中のFluentdにflowcounter pluginを導入してみた
|
177
177
|
http://dayafterneet.blogspot.jp/2012/12/fluentdflowcounter-plugin.html
|
178
178
|
|
179
|
-
- fluent-plugin-rewrite-tag-filter v1.2.0
|
179
|
+
- fluent-plugin-rewrite-tag-filter v1.2.0 をリリースしました。新機能であるremove_tag_prefix設定の使い方を解説します。 #fluentd
|
180
180
|
http://y-ken.hatenablog.com/entry/fluent-plugin-rewrite-tag-filter-v1.2.0
|
181
181
|
|
182
|
+
- fluent-plugin-rewrite-tag-filter v1.2.1 をリリースしました。設定サンプルと共にプレースホルダ機能強化内容を紹介します。 #fluentd
|
183
|
+
http://y-ken.hatenablog.com/entry/fluent-plugin-rewrite-tag-filter-v1.2.1
|
184
|
+
|
185
|
+
- 待望の正規表現の否定パターンに対応した fluent-plugin-rewrite-tag-filter v1.3.0 をリリースしました #fluentd
|
186
|
+
http://y-ken.hatenablog.com/entry/fluent-plugin-rewrite-tag-filter-v1.3.0
|
187
|
+
|
188
|
+
|
182
189
|
## TODO
|
183
190
|
|
184
191
|
Pull requests are very welcome!!
|
@@ -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-rewrite-tag-filter"
|
6
|
-
s.version = "1.3.
|
6
|
+
s.version = "1.3.1"
|
7
7
|
s.authors = ["Kentaro Yoshida"]
|
8
8
|
s.email = ["y.ken.studio@gmail.com"]
|
9
9
|
s.homepage = "https://github.com/y-ken/fluent-plugin-rewrite-tag-filter"
|
@@ -19,7 +19,7 @@ class Fluent::RewriteTagFilterOutput < Fluent::Output
|
|
19
19
|
if regexp.nil? || rewritetag.nil?
|
20
20
|
raise Fluent::ConfigError, "failed to parse rewriterules at #{key} #{conf[key]}"
|
21
21
|
end
|
22
|
-
@rewriterules.push([rewritekey,
|
22
|
+
@rewriterules.push([rewritekey, /#{trim_regex_quote(regexp)}/, get_match_operator(regexp), rewritetag])
|
23
23
|
rewriterule_names.push(rewritekey + regexp)
|
24
24
|
$log.info "adding rewrite_tag_filter rule: #{key} #{@rewriterules.last}"
|
25
25
|
end
|
@@ -32,8 +32,8 @@ class Fluent::RewriteTagFilterOutput < Fluent::Output
|
|
32
32
|
raise Fluent::ConfigError, "duplicated rewriterules found #{@rewriterules.inspect}"
|
33
33
|
end
|
34
34
|
|
35
|
-
unless
|
36
|
-
@remove_tag_prefix =
|
35
|
+
unless @remove_tag_prefix.nil?
|
36
|
+
@remove_tag_prefix = /^#{Regexp.escape(@remove_tag_prefix)}\.?/
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -59,9 +59,9 @@ class Fluent::RewriteTagFilterOutput < Fluent::Output
|
|
59
59
|
else
|
60
60
|
next if !matched
|
61
61
|
backreference_table = get_backreference_table($~.captures)
|
62
|
-
rewritetag.gsub
|
62
|
+
rewritetag = rewritetag.gsub(/\$\d+/, backreference_table)
|
63
63
|
end
|
64
|
-
rewritetag.gsub
|
64
|
+
rewritetag = rewritetag.gsub(/(\${[a-z]+}|__[A-Z]+__)/, placeholder)
|
65
65
|
return rewritetag
|
66
66
|
end
|
67
67
|
return nil
|
@@ -78,14 +78,14 @@ class Fluent::RewriteTagFilterOutput < Fluent::Output
|
|
78
78
|
$log.info "rewrite_tag_filter: [DEPRECATED] Use ^....$ pattern for partial word match instead of double-quote-delimiter. #{regexp}"
|
79
79
|
regexp = regexp[1..-2]
|
80
80
|
end
|
81
|
-
if regexp.start_with?(
|
81
|
+
if regexp.start_with?(MATCH_OPERATOR_EXCLUDE)
|
82
82
|
regexp = regexp[1, regexp.length]
|
83
83
|
end
|
84
84
|
return regexp
|
85
85
|
end
|
86
86
|
|
87
87
|
def get_match_operator(regexp)
|
88
|
-
return
|
88
|
+
return MATCH_OPERATOR_EXCLUDE if regexp.start_with?(MATCH_OPERATOR_EXCLUDE)
|
89
89
|
return ''
|
90
90
|
end
|
91
91
|
|
@@ -30,6 +30,12 @@ class RewriteTagFilterOutputTest < Test::Unit::TestCase
|
|
30
30
|
remove_tag_prefix input
|
31
31
|
]
|
32
32
|
|
33
|
+
# remove_tag_prefix test2
|
34
|
+
CONFIG_REMOVE_TAG_PREFIX_WITH_DOT = %[
|
35
|
+
rewriterule1 domain ^www\.google\.com$ ${tag}
|
36
|
+
remove_tag_prefix input.
|
37
|
+
]
|
38
|
+
|
33
39
|
# hostname placeholder test
|
34
40
|
CONFIG_SHORT_HOSTNAME = %[
|
35
41
|
rewriterule1 domain ^www\.google\.com$ ${hostname}
|
@@ -129,7 +135,18 @@ class RewriteTagFilterOutputTest < Test::Unit::TestCase
|
|
129
135
|
assert_equal 'access', emits[0][0] # tag
|
130
136
|
end
|
131
137
|
|
132
|
-
def
|
138
|
+
def test_emit4_remove_tag_prefix_with_dot
|
139
|
+
d1 = create_driver(CONFIG_REMOVE_TAG_PREFIX_WITH_DOT, 'input.access')
|
140
|
+
d1.run do
|
141
|
+
d1.emit({'domain' => 'www.google.com', 'path' => '/foo/bar?key=value', 'agent' => 'Googlebot', 'response_time' => 1000000})
|
142
|
+
end
|
143
|
+
emits = d1.emits
|
144
|
+
assert_equal 1, emits.length
|
145
|
+
p emits[0]
|
146
|
+
assert_equal 'access', emits[0][0] # tag
|
147
|
+
end
|
148
|
+
|
149
|
+
def test_emit5_short_hostname
|
133
150
|
d1 = create_driver(CONFIG_SHORT_HOSTNAME, 'input.access')
|
134
151
|
d1.run do
|
135
152
|
d1.emit({'domain' => 'www.google.com', 'path' => '/foo/bar?key=value', 'agent' => 'Googlebot', 'response_time' => 1000000})
|
@@ -140,7 +157,7 @@ class RewriteTagFilterOutputTest < Test::Unit::TestCase
|
|
140
157
|
assert_equal `hostname -s`.chomp, emits[0][0] # tag
|
141
158
|
end
|
142
159
|
|
143
|
-
def
|
160
|
+
def test_emit6_non_matching
|
144
161
|
d1 = create_driver(CONFIG_NON_MATCHING, 'input.access')
|
145
162
|
d1.run do
|
146
163
|
d1.emit({'domain' => 'www.google.com'})
|
@@ -157,7 +174,7 @@ class RewriteTagFilterOutputTest < Test::Unit::TestCase
|
|
157
174
|
assert_equal 'not_start_with_www', emits[2][0] # tag
|
158
175
|
end
|
159
176
|
|
160
|
-
def
|
177
|
+
def test_emit7_jump_index
|
161
178
|
d1 = create_driver(CONFIG_JUMP_INDEX, 'input.access')
|
162
179
|
d1.run do
|
163
180
|
d1.emit({'domain' => 'www.google.com', 'path' => '/', 'agent' => 'Googlebot', 'response_time' => 1000000})
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-rewrite-tag-filter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
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-07-
|
12
|
+
date: 2013-07-21 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|