fluent-plugin-rewrite-tag-filter 1.2.0 → 1.2.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
@@ -28,6 +28,12 @@ rewruterule<num:1-200> <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)
31
+
32
+ # Optional: remove tag prefix for tag placeholder.
33
+ remove_tag_prefix <string>
34
+
35
+ # Optional: set placeholder for hostname.
36
+ hostname_command <string>
31
37
  ```
32
38
 
33
39
  ### Usage
@@ -38,7 +44,7 @@ It's a sample to exclude some static file log before split tag by domain.
38
44
  <source>
39
45
  type tail
40
46
  path /var/log/httpd/access_log
41
- format /^(?<domain>[^ ]*) (?<host>[^ ]*) [^ ]* (?<user>[^ ]*) \[(?<time>[^\]]*)\] "(?<method>\S+)(?: +(?<path>[^ ]*) +\S*)?" (?<status>[^ ]*) (?<size>[^ ]*)(?: "(?<referer>[^\"]*)" "(?<agent>[^\"]*)" (?<response_time>[^ ]*))?$/
47
+ format apache2
42
48
  time_format %d/%b/%Y:%H:%M:%S %z
43
49
  tag td.apache.access
44
50
  pos_file /var/log/td-agent/apache_access.pos
@@ -124,6 +130,13 @@ It's a sample to rewrite a tag with placeholder.
124
130
  type rewrite_tag_filter
125
131
  rewriterule1 domain ^(mail)\.(example)\.com$ rewrited.$2$1.${hostname}
126
132
  </match>
133
+
134
+ # It will get "rewrited.ExampleMail.app30-124" when hostname is "app30-124.foo.com"
135
+ <match apache.access>
136
+ type rewrite_tag_filter
137
+ rewriterule1 domain ^(mail)\.(example)\.com$ rewrited.$2$1.${hostname}
138
+ hostname_command hostname -s
139
+ </match>
127
140
  ```
128
141
 
129
142
  ## Example
@@ -151,6 +164,9 @@ https://gist.github.com/matsumana/4078096
151
164
  - 稼働中のFluentdにflowcounter pluginを導入してみた
152
165
  http://dayafterneet.blogspot.jp/2012/12/fluentdflowcounter-plugin.html
153
166
 
167
+ - fluent-plugin-rewrite-tag-filter v1.2.0 をリリースしました。新機能を紹介します。 #fluentd
168
+ http://y-ken.hatenablog.com/entry/fluent-plugin-rewrite-tag-filter-v1.2.0
169
+
154
170
  ## TODO
155
171
 
156
172
  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.2.0"
6
+ s.version = "1.2.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"
@@ -9,13 +9,14 @@ class Fluent::RewriteTagFilterOutput < Fluent::Output
9
9
  end
10
10
  config_param :capitalize_regex_backreference, :bool, :default => false
11
11
  config_param :remove_tag_prefix, :string, :default => nil
12
+ config_param :hostname_command, :string, :default => 'hostname'
12
13
 
13
14
  def configure(conf)
14
15
  super
15
16
 
16
17
  @rewriterules = []
17
18
  rewriterule_names = []
18
- @hostname = `hostname`.chomp
19
+ @hostname = `#{@hostname_command}`.chomp
19
20
 
20
21
  invalids = conf.keys.select{|k| k =~ /^rewriterule(\d+)$/}.select{|arg| arg =~ /^rewriterule(\d+)/ and not (1..PATTERN_MAX_NUM).include?($1.to_i)}
21
22
  if invalids.size > 0
@@ -30,6 +30,13 @@ class RewriteTagFilterOutputTest < Test::Unit::TestCase
30
30
  remove_tag_prefix input
31
31
  ]
32
32
 
33
+ # hostname placeholder test
34
+ CONFIG4 = %[
35
+ rewriterule1 domain ^www\.google\.com$ ${hostname}
36
+ remove_tag_prefix input
37
+ hostname_command hostname -s
38
+ ]
39
+
33
40
  def create_driver(conf=CONFIG,tag='test')
34
41
  Fluent::Test::OutputTestDriver.new(Fluent::RewriteTagFilterOutput, tag).configure(conf)
35
42
  end
@@ -102,5 +109,16 @@ class RewriteTagFilterOutputTest < Test::Unit::TestCase
102
109
  p emits[0]
103
110
  assert_equal 'access', emits[0][0] # tag
104
111
  end
112
+
113
+ def test_emit4
114
+ d1 = create_driver(CONFIG4, 'input.access')
115
+ d1.run do
116
+ d1.emit({'domain' => 'www.google.com', 'path' => '/foo/bar?key=value', 'agent' => 'Googlebot', 'response_time' => 1000000})
117
+ end
118
+ emits = d1.emits
119
+ assert_equal 1, emits.length
120
+ p emits[0]
121
+ assert_equal `hostname -s`.chomp, emits[0][0] # tag
122
+ end
105
123
  end
106
124
 
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.2.0
4
+ version: 1.2.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-05-03 00:00:00.000000000 Z
12
+ date: 2013-06-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rake