fluent-plugin-geoip 0.8.2 → 1.0.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
  SHA1:
3
- metadata.gz: cd066ccaec269f0423567cb6b67fb2f740bd75bf
4
- data.tar.gz: 59ceed4885348c00333ae21b859311474ed1a01e
3
+ metadata.gz: d8ae0d73eec8f27ed950ce080d02d0ada455fdc7
4
+ data.tar.gz: 3e442d004f0e4852ea8b713749eedb1f05991eaa
5
5
  SHA512:
6
- metadata.gz: 7e1c15b06c1916d28656c6607e0d31c716622a0c1436a45d15eeab7d4cea049b9a728a87af7603693305399fa98180a63b43f954298feff9a7cbfa439bccf93d
7
- data.tar.gz: 1699358cd3e9841ba975d07853a05a5af2ead21c42469fa892f1cce9917f08baabc711905011d6547d8bd10da00616e53b437ff4adb64dd0baddb99f0276c57b
6
+ metadata.gz: a026783f1b3578c27081c142dc4829cdda7ed0ec0be13867ee42e6052818fde41630154d8311fc63d52b6808213bec0caf84281006143cbc8f9845f96a3e01b6
7
+ data.tar.gz: 70836a38b6e1596ff5dcae93dda3961b67e7a16f4dd050b2ddaa7c33ff17df63475526e8baf2b8a8e103eb81cc250be029d0ed96d7388c871fcd7bfcd8e5f79e
@@ -10,10 +10,6 @@ env:
10
10
  - TARGET_RUBY_VERSION=2.2 BUNDLE_GEMFILE=/app/gemfiles/fluentd_v1.0_with_backport_dig.gemfile
11
11
  - TARGET_RUBY_VERSION=2.3 BUNDLE_GEMFILE=/app/gemfiles/fluentd_v1.0_without_backport_dig.gemfile
12
12
  - TARGET_RUBY_VERSION=2.4 BUNDLE_GEMFILE=/app/gemfiles/fluentd_v1.0_without_backport_dig.gemfile
13
- - TARGET_RUBY_VERSION=2.1 BUNDLE_GEMFILE=/app/gemfiles/fluentd_v0.12_with_backport_dig.gemfile
14
- - TARGET_RUBY_VERSION=2.2 BUNDLE_GEMFILE=/app/gemfiles/fluentd_v0.12_with_backport_dig.gemfile
15
- - TARGET_RUBY_VERSION=2.3 BUNDLE_GEMFILE=/app/gemfiles/fluentd_v0.12_without_backport_dig.gemfile
16
- - TARGET_RUBY_VERSION=2.4 BUNDLE_GEMFILE=/app/gemfiles/fluentd_v0.12_without_backport_dig.gemfile
17
13
 
18
14
  before_install:
19
15
  #- sudo apt-get update
data/Appraisals CHANGED
@@ -1,12 +1,3 @@
1
- appraise "fluentd v0.12 with backport_dig" do
2
- gem "fluentd", "~> 0.12.0"
3
- gem "backport_dig", "~> 1.0.0"
4
- end
5
-
6
- appraise "fluentd v0.12 without backport_dig" do
7
- gem "fluentd", "~> 0.12.0"
8
- end
9
-
10
1
  appraise "fluentd v1.0 with backport_dig" do
11
2
  gem "fluentd", "~> 1.0.0"
12
3
  gem "backport_dig", "~> 1.0.0"
data/README.md CHANGED
@@ -10,26 +10,84 @@ The accuracy details for GeoLite City (free) and GeoIP City (purchased) has desc
10
10
  * http://www.maxmind.com/en/geolite_city_accuracy ([lang:ja](http://www.maxmind.com/ja/geolite_city_accuracy))
11
11
  * http://www.maxmind.com/en/city_accuracy ([lang:ja](http://www.maxmind.com/ja/city_accuracy))
12
12
 
13
+ ## Requirements
14
+
15
+ | fluent-plugin-geoip | fluentd | ruby |
16
+ |---------------------|------------|--------|
17
+ | >= 1.0.0 | >= v1.0.2 | >= 2.1 |
18
+ | < 1.0.0 | >= v0.12.0 | >= 1.9 |
19
+
20
+ If you want to use this plugin with Fluentd v0.12.x or earlier use 0.8.x.
21
+
22
+ ### Compatibility notice
23
+
24
+ We've used Fluentd v1 API in this plugin since 1.0.0.
25
+ So we have dropped some features.
26
+
27
+ See also [official document](http://docs.fluentd.org/v1.0/articles/plugin-update-from-v12)
28
+
29
+ #### Fluent::Mixin::RewriteTagName
30
+
31
+ * `${tag}`, `__TAG__`
32
+
33
+ Alternative: Use `${tag}` placeholder
34
+
35
+ * `${tag_parts[n]}`, `__TAG_PARTS[n]__`
36
+
37
+ Alternative: Use `${tag[n]}` placeholder
38
+
39
+ * `${hostname}`, `__HOSTNAME__`
40
+
41
+ Alternative1: Use filter before this plugin and chunk keys:
42
+ ```
43
+ <filter>
44
+ @type record_transformer
45
+ <record>
46
+ hostname ${hostname}
47
+ </record>
48
+ </filter>
49
+ <match **>
50
+ @type geoip
51
+ tag geoip.${tag[1]}.${hostname}
52
+ <record>
53
+ city ${city["host"]}
54
+ </record>
55
+ <buffer tag, hostname>
56
+ flush_interval 1s
57
+ </buffer>
58
+ </match>
59
+ ```
60
+
61
+ Alternative2: Just inject hostname into record you can use `<inject>` section instead:
62
+ ```
63
+ <match **>
64
+ @type geoip
65
+ tag geoip.${tag[1]}.${hostname}
66
+ <record>
67
+ city ${city["host"]}
68
+ </record>
69
+ <inject>
70
+ hostname_key hostname
71
+ </inject>
72
+ </match>
73
+ ```
74
+
13
75
  ## Dependency
14
76
 
15
77
  before use, install dependent library as:
16
78
 
17
79
  ```bash
18
80
  # for RHEL/CentOS
19
- $ sudo yum groupinstall "Development Tools"
81
+ $ sudo yum group install "Development Tools"
20
82
  $ sudo yum install geoip-devel --enablerepo=epel
21
- $ sudo yum install libmaxminddb-devel --enablerepo=epel
22
83
 
23
84
  # for Ubuntu/Debian
24
85
  $ sudo apt-get install build-essential
25
86
  $ sudo apt-get install libgeoip-dev
26
- $ sudo apt-get install libmaxminddb-dev
27
87
 
28
88
  # for OS X
29
89
  $ brew install geoip
30
- $ brew install libmaxminddb
31
90
  $ bundle config build.geoip-c --with-geoip-dir=/usr/local/include/
32
- $ bundle config build.geoip2_c --with-opt-include=/usr/local/include/
33
91
  ```
34
92
 
35
93
  ## Installation
@@ -61,6 +119,10 @@ $ sudo td-agent-gem install fluent-plugin-geoip
61
119
 
62
120
  # Specify optional geoip database (using bundled GeoLiteCity databse by default)
63
121
  geoip_database "/path/to/your/GeoIPCity.dat"
122
+ # Specify optional geoip2 database
123
+ # geoip2_database "/path/to/your/GeoLite2-City.mmdb"
124
+ # Specify backend library (geoip, geoip2_compat, geoip2_c)
125
+ backend_library geoip
64
126
 
65
127
  # Set adding field with placeholder (more than one settings are required.)
66
128
  <record>
@@ -76,8 +138,7 @@ $ sudo td-agent-gem install fluent-plugin-geoip
76
138
  </record>
77
139
 
78
140
  # Settings for tag
79
- remove_tag_prefix access.
80
- tag geoip.${tag}
141
+ tag geoip.${tag[1]}
81
142
 
82
143
  # To avoid get stacktrace error with `[null, null]` array for elasticsearch.
83
144
  skip_adding_null_record true
@@ -85,8 +146,10 @@ $ sudo td-agent-gem install fluent-plugin-geoip
85
146
  # Set log_level for fluentd-v0.10.43 or earlier (default: warn)
86
147
  log_level info
87
148
 
88
- # Set buffering time (default: 0s)
89
- flush_interval 1s
149
+ <buffer tag>
150
+ # Set buffering time (default: 0s)
151
+ flush_interval 1s
152
+ </buffer>
90
153
  </match>
91
154
  ```
92
155
 
@@ -100,8 +163,7 @@ $ sudo td-agent-gem install fluent-plugin-geoip
100
163
  user1_city ${city["user1_host"]}
101
164
  user2_city ${city["user2_host"]}
102
165
  </record>
103
- remove_tag_prefix access.
104
- tag geoip.${tag}
166
+ tag geoip.${tag[1]}
105
167
  </match>
106
168
  ```
107
169
 
@@ -109,6 +171,7 @@ $ sudo td-agent-gem install fluent-plugin-geoip
109
171
 
110
172
  It is a sample to get friendly geo point recdords for elasticsearch with Yajl (JSON) parser.<br />
111
173
 
174
+ **Notice** v0 config will be deprecated in the future.
112
175
 
113
176
  ```
114
177
  <match access.apache>
@@ -127,15 +190,14 @@ It is a sample to get friendly geo point recdords for elasticsearch with Yajl (J
127
190
  # ex. [-122.05740356445312, 37.4192008972168]
128
191
  location_array '[${longitude["host"]},${latitude["host"]}]'
129
192
  </record>
130
- remove_tag_prefix access.
131
- tag geoip.${tag}
193
+ tag geoip.${tag[1]}
132
194
 
133
195
  # To avoid get stacktrace error with `[null, null]` array for elasticsearch.
134
196
  skip_adding_null_record true
135
197
  </match>
136
198
  ```
137
199
 
138
- On the case of using td-agent2 (v1-config), it have to quote `{ ... }` or `[ ... ]` block with quotation like below.
200
+ On the case of using td-agent3 (v1-config), it have to quote `{ ... }` or `[ ... ]` block with quotation like below.
139
201
 
140
202
  ```
141
203
  <match access.apache>
@@ -166,6 +228,10 @@ Note that filter version of geoip plugin does not have handling tag feature.
166
228
 
167
229
  # Specify optional geoip database (using bundled GeoLiteCity databse by default)
168
230
  geoip_database "/path/to/your/GeoIPCity.dat"
231
+ # Specify optional geoip2 database
232
+ # geoip2_database "/path/to/your/GeoLite2-City.mmdb"
233
+ # Specify backend library (geoip, geoip2_compat, geoip2_c)
234
+ backend_library geoip
169
235
 
170
236
  # Set adding field with placeholder (more than one settings are required.)
171
237
  <record>
@@ -185,9 +251,6 @@ Note that filter version of geoip plugin does not have handling tag feature.
185
251
 
186
252
  # Set log_level for fluentd-v0.10.43 or earlier (default: warn)
187
253
  log_level info
188
-
189
- # Set buffering time (default: 0s)
190
- flush_interval 1s
191
254
  </filter>
192
255
  ```
193
256
 
@@ -215,8 +278,7 @@ Note that filter version of geoip plugin does not have handling tag feature.
215
278
  lon ${longitude["host"]}
216
279
  country ${country_code["host"]}
217
280
  </record>
218
- remove_tag_prefix test.
219
- tag debug.${tag}
281
+ tag debug.${tag[1]}
220
282
  </store>
221
283
  </match>
222
284
 
@@ -299,6 +361,11 @@ For more example of geolocating, you can try these websites like [Geo IP Address
299
361
 
300
362
  Further more specification available at http://dev.maxmind.com/geoip/legacy/csv/#GeoIP_City_Edition_CSV_Database_Fields
301
363
 
364
+ Related configurations:
365
+
366
+ * `backend_library`: `geoip` (default)
367
+ * `geoip_database`: path to your GeoLiteCity.dat
368
+
302
369
  ### GeoIP2
303
370
 
304
371
  You can get any fields in the
@@ -333,6 +400,11 @@ For example(geoip2_compat backend):
333
400
 
334
401
  **NOTE**: geoip2_compat backend supports only above fields.
335
402
 
403
+ Related configurations:
404
+
405
+ * `backend_library`: `geoip2_compat` or `geoip2_c`
406
+ * `geoip2_database`: path to your GeoLite2-City.mmdb
407
+
336
408
  ## Parameters
337
409
 
338
410
  ### GeoipOutput
@@ -348,16 +420,9 @@ Further details are written at http://docs.fluentd.org/articles/in_exec
348
420
  Skip adding geoip fields when this valaues to `true`.
349
421
  On the case of getting nothing of GeoIP info (such as local IP), it will output the original record without changing anything.
350
422
 
351
- * `remove_tag_prefix`
352
- * `remove_tag_suffix`
353
- * `add_tag_prefix`
354
- * `add_tag_suffix`
355
-
356
- Set one or more option are required unless using `tag` option for editing tag name. (HandleTagNameMixin feature)
357
-
358
423
  * `tag`
359
424
 
360
- On using this option with tag placeholder like `tag geoip.${tag}` (test code is available at [test_out_geoip.rb](https://github.com/y-ken/fluent-plugin-geoip/blob/master/test/plugin/test_out_geoip.rb)), it will be overwrite after these options affected. which are remove_tag_prefix, remove_tag_suffix, add_tag_prefix and add_tag_suffix.
425
+ On using this option with tag placeholder like `tag geoip.${tag}` (test code is available at [test_out_geoip.rb](https://github.com/y-ken/fluent-plugin-geoip/blob/master/test/plugin/test_out_geoip.rb)).
361
426
 
362
427
  * `flush_interval` (default: 0 sec)
363
428
 
@@ -377,10 +442,6 @@ Further details are written at http://docs.fluentd.org/articles/in_exec
377
442
  Skip adding geoip fields when this valaues to `true`.
378
443
  On the case of getting nothing of GeoIP info (such as local IP), it will output the original record without changing anything.
379
444
 
380
- * `flush_interval` (default: 0 sec)
381
-
382
- Set buffering time to execute bulk lookup geoip.
383
-
384
445
  ## Articles
385
446
 
386
447
  * [IPアドレスを元に位置情報をリアルタイムに付与する fluent-plugin-geoip v0.0.1をリリースしました #fluentd - Y-Ken Studio](http://y-ken.hatenablog.com/entry/fluent-plugin-geoip-has-released)<br />
@@ -2,7 +2,7 @@ FROM ruby:2.1-alpine
2
2
 
3
3
  ENV BUNDLE_GEMFILE=$BUNDLE_GEMFILE
4
4
 
5
- RUN apk --no-cache --update add build-base automake autoconf libtool ruby-dev libc6-compat geoip-dev git
5
+ RUN apk --no-cache --update add build-base ruby-dev libc6-compat libmaxminddb-dev geoip-dev git
6
6
 
7
7
  WORKDIR /app
8
8
  COPY . .
@@ -2,7 +2,7 @@ FROM ruby:2.2-alpine
2
2
 
3
3
  ENV BUNDLE_GEMFILE=$BUNDLE_GEMFILE
4
4
 
5
- RUN apk --no-cache --update add build-base automake autoconf libtool ruby-dev libc6-compat geoip-dev git
5
+ RUN apk --no-cache --update add build-base ruby-dev libc6-compat libmaxminddb-dev geoip-dev git
6
6
 
7
7
  WORKDIR /app
8
8
  COPY . .
@@ -2,7 +2,7 @@ FROM ruby:2.3-alpine
2
2
 
3
3
  ENV BUNDLE_GEMFILE=$BUNDLE_GEMFILE
4
4
 
5
- RUN apk --no-cache --update add build-base automake autoconf libtool ruby-dev libc6-compat geoip-dev git
5
+ RUN apk --no-cache --update add build-base ruby-dev libc6-compat libmaxminddb-dev geoip-dev git
6
6
 
7
7
  WORKDIR /app
8
8
  COPY . .
@@ -2,7 +2,7 @@ FROM ruby:2.4-alpine
2
2
 
3
3
  ENV BUNDLE_GEMFILE=$BUNDLE_GEMFILE
4
4
 
5
- RUN apk --no-cache --update add build-base automake autoconf libtool ruby-dev libc6-compat geoip-dev git
5
+ RUN apk --no-cache --update add build-base ruby-dev libc6-compat libmaxminddb-dev geoip-dev git
6
6
 
7
7
  WORKDIR /app
8
8
  COPY . .
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "fluent-plugin-geoip"
7
- spec.version = "0.8.2"
7
+ spec.version = "1.0.0"
8
8
  spec.authors = ["Kentaro Yoshida"]
9
9
  spec.email = ["y.ken.studio@gmail.com"]
10
10
  spec.summary = %q{Fluentd Filter plugin to add information about geographical location of IP addresses with Maxmind GeoIP databases.}
@@ -21,10 +21,9 @@ Gem::Specification.new do |spec|
21
21
  spec.add_development_dependency "appraisal"
22
22
  spec.add_development_dependency "test-unit", ">= 3.1.0"
23
23
  spec.add_development_dependency "geoip2_compat"
24
- spec.add_development_dependency "geoip2_c"
25
24
 
26
- spec.add_runtime_dependency "fluentd"
27
- spec.add_runtime_dependency "fluent-mixin-rewrite-tag-name"
25
+ spec.add_runtime_dependency "fluentd", [">= 0.14.8", "< 2"]
28
26
  spec.add_runtime_dependency "geoip-c"
27
+ spec.add_runtime_dependency "geoip2_c"
29
28
  spec.add_runtime_dependency "dig_rb"
30
29
  end
@@ -1,40 +1,34 @@
1
+ require 'fluent/plugin/filter'
1
2
  require 'fluent/plugin/geoip'
2
3
 
3
- module Fluent
4
- class GeoipFilter < Filter
5
- Plugin.register_filter('geoip', self)
4
+ module Fluent::Plugin
5
+ class GeoipFilter < Fluent::Plugin::Filter
6
+ Fluent::Plugin.register_filter('geoip', self)
6
7
 
7
- config_param :geoip_database, :string, :default => File.dirname(__FILE__) + '/../../../data/GeoLiteCity.dat'
8
- config_param :geoip2_database, :string, :default => File.dirname(__FILE__) + '/../../../data/GeoLite2-City.mmdb'
9
- config_param :geoip_lookup_key, :string, :default => 'host'
10
- config_param :skip_adding_null_record, :bool, :default => false
8
+ config_param :geoip_database, :string, default: File.dirname(__FILE__) + '/../../../data/GeoLiteCity.dat'
9
+ config_param :geoip2_database, :string, default: File.dirname(__FILE__) + '/../../../data/GeoLite2-City.mmdb'
10
+ config_param :geoip_lookup_key, :string, default: 'host'
11
+ config_param :skip_adding_null_record, :bool, default: false
11
12
 
12
- include Fluent::SetTagKeyMixin
13
13
  config_set_default :include_tag_key, false
14
14
 
15
- config_param :hostname_command, :string, :default => 'hostname'
15
+ config_param :hostname_command, :string, default: 'hostname'
16
16
 
17
- config_param :log_level, :string, :default => 'warn'
17
+ config_param :log_level, :string, default: 'warn'
18
18
 
19
- config_param :backend_library, :enum, :list => Fluent::GeoIP::BACKEND_LIBRARIES, :default => :geoip
19
+ config_param :backend_library, :enum, list: Fluent::GeoIP::BACKEND_LIBRARIES, default: :geoip2_c
20
20
 
21
21
  def configure(conf)
22
22
  super
23
23
  @geoip = Fluent::GeoIP.new(self, conf)
24
24
  end
25
25
 
26
- def filter_stream(tag, es)
27
- new_es = MultiEventStream.new
28
- es.each do |time, record|
29
- begin
30
- filter_record(tag, time, record)
31
- filtered_record = @geoip.add_geoip_field(record)
32
- new_es.add(time, filtered_record) if filtered_record
33
- rescue => e
34
- router.emit_error_event(tag, time, record, e)
35
- end
26
+ def filter(tag, time, record)
27
+ filtered_record = @geoip.add_geoip_field(record)
28
+ if filtered_record
29
+ record = filtered_record
36
30
  end
37
- new_es
31
+ record
38
32
  end
39
33
  end
40
34
  end
@@ -77,13 +77,6 @@ module Fluent
77
77
  end
78
78
  end
79
79
 
80
- if plugin.is_a?(Fluent::BufferedOutput)
81
- @placeholder_expander = PlaceholderExpander.new
82
- unless have_tag_option?(plugin)
83
- raise Fluent::ConfigError, "geoip: required at least one option of 'tag', 'remove_tag_prefix', 'remove_tag_suffix', 'add_tag_prefix', 'add_tag_suffix'."
84
- end
85
- end
86
-
87
80
  @geoip = load_database(plugin)
88
81
  end
89
82
 
@@ -109,12 +102,6 @@ module Fluent
109
102
 
110
103
  private
111
104
 
112
- def have_tag_option?(plugin)
113
- plugin.tag ||
114
- plugin.remove_tag_prefix || plugin.remove_tag_suffix ||
115
- plugin.add_tag_prefix || plugin.add_tag_suffix
116
- end
117
-
118
105
  def json?(text)
119
106
  text.match(/^\[.+\]$/) || text.match(/^\{.+\}$/)
120
107
  end
@@ -129,7 +116,7 @@ module Fluent
129
116
  begin
130
117
  return Yajl::Parser.parse(message)
131
118
  rescue Yajl::ParseError => e
132
- log.info "geoip: failed to parse '#{message}' as json.", :error_class => e.class, :error => e.message
119
+ log.info "geoip: failed to parse '#{message}' as json.", error_class: e.class, error: e.message
133
120
  return nil
134
121
  end
135
122
  end
@@ -164,13 +151,7 @@ module Fluent
164
151
  position = placeholder_key.match(REGEXP_PLACEHOLDER_SINGLE)
165
152
  next if position.nil? or geodata[position[:record_key]].nil?
166
153
  keys = [position[:record_key]] + position[:geoip_key].split('.').map(&:to_sym)
167
- value = geodata.dig(*keys)
168
- value = if [:latitude, :longitude].include?(keys.last)
169
- value || 0.0
170
- else
171
- value
172
- end
173
- placeholder[placeholder_key] = value
154
+ placeholder[placeholder_key] = geodata.dig(*keys)
174
155
  end
175
156
  placeholder
176
157
  end
@@ -1,54 +1,51 @@
1
- require 'fluent/mixin/rewrite_tag_name'
1
+ require 'fluent/plugin/output'
2
2
  require 'fluent/plugin/geoip'
3
3
 
4
- class Fluent::GeoipOutput < Fluent::BufferedOutput
4
+ class Fluent::Plugin::GeoipOutput < Fluent::Plugin::Output
5
5
  Fluent::Plugin.register_output('geoip', self)
6
6
 
7
- config_param :geoip_database, :string, :default => File.dirname(__FILE__) + '/../../../data/GeoLiteCity.dat'
8
- config_param :geoip2_database, :string, :default => File.dirname(__FILE__) + '/../../../data/GeoLite2-City.mmdb'
9
- config_param :geoip_lookup_key, :string, :default => 'host'
10
- config_param :tag, :string, :default => nil
11
- config_param :skip_adding_null_record, :bool, :default => false
7
+ helpers :event_emitter, :inject, :compat_parameters
12
8
 
13
- include Fluent::HandleTagNameMixin
14
- include Fluent::SetTagKeyMixin
15
- config_set_default :include_tag_key, false
9
+ config_param :geoip_database, :string, default: File.dirname(__FILE__) + '/../../../data/GeoLiteCity.dat'
10
+ config_param :geoip2_database, :string, default: File.dirname(__FILE__) + '/../../../data/GeoLite2-City.mmdb'
11
+ config_param :geoip_lookup_key, :string, default: 'host'
12
+ config_param :tag, :string, default: nil
13
+ config_param :skip_adding_null_record, :bool, default: false
16
14
 
17
- include Fluent::Mixin::RewriteTagName
18
- config_param :hostname_command, :string, :default => 'hostname'
15
+ config_param :flush_interval, :time, default: 0
16
+ config_param :log_level, :string, default: 'warn'
19
17
 
20
- config_param :flush_interval, :time, :default => 0
21
- config_param :log_level, :string, :default => 'warn'
22
-
23
- config_param :backend_library, :enum, :list => Fluent::GeoIP::BACKEND_LIBRARIES, :default => :geoip
18
+ config_param :backend_library, :enum, list: Fluent::GeoIP::BACKEND_LIBRARIES, default: :geoip2_c
19
+ config_section :buffer do
20
+ config_set_default :@type, :memory
21
+ config_set_default :chunk_keys, ['tag']
22
+ end
24
23
 
25
24
  def configure(conf)
25
+ compat_parameters_convert(conf, :buffer, default_chunk_key: 'tag')
26
26
  super
27
- Fluent::GeoIP.class_eval do
28
- include Fluent::Mixin::RewriteTagName
29
- end
27
+ raise Fluetn::ConfigError, "chunk key must include 'tag'" unless @chunk_key_tag
28
+ placeholder_validate!(:tag, @tag) if @tag
30
29
  @geoip = Fluent::GeoIP.new(self, conf)
31
30
  end
32
31
 
33
- def start
34
- super
35
- end
36
-
37
32
  def format(tag, time, record)
33
+ record = inject_values_to_record(tag, time, record)
38
34
  [tag, time, record].to_msgpack
39
35
  end
40
36
 
41
- def shutdown
42
- super
37
+ def formatted_to_msgpack_binary
38
+ true
43
39
  end
44
40
 
45
41
  def write(chunk)
46
42
  es = Fluent::MultiEventStream.new
47
43
  tag = ""
48
- chunk.msgpack_each do |_tag, time, record|
44
+ chunk.each do |_tag, time, record|
49
45
  tag = _tag
50
46
  es.add(time, @geoip.add_geoip_field(record))
51
47
  end
48
+ tag = extract_placeholders(@tag, chunk.metadata) if @tag
52
49
  router.emit_stream(tag, es)
53
50
  end
54
51
  end