fluent-plugin-filter-geoip 0.2.4 → 0.2.5

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: cde3b38a6cf1ea9399cb57f3ee6a9eb55605b076
4
- data.tar.gz: ed00a25b45352a8cb794a1fff40652032b1a696e
3
+ metadata.gz: 9ed42a070dbbdd79fe1ebbbc200ed6575c73d5b9
4
+ data.tar.gz: e4494a384ecb2a16d9207ebef62f7811d69c6630
5
5
  SHA512:
6
- metadata.gz: 61bc3096df8b34e6cb7dcf231585d6f05156661308a93a81ec9ff8bfbbf6507c48d95915c9a23f90ea7ea83365e5a9e844805dc06dc0cf71c7428257c732af97
7
- data.tar.gz: a368fc420027c2a042abe628abab572d7fc9874e3befbc1bdbb09577cbb8baacd8892fcfde4266a6fa5e3e72960feceb9eda31d290f0121edcdf5b5897729934
6
+ metadata.gz: cae6f7761e4806d00d1d18be4a287ce28187fb4881f902d08e4433b00e121ba5a460ffe138235fd24f5bfec446032a9417d4457e2b6c539a714d35895f368d2b
7
+ data.tar.gz: f789f5e7c1e7c73983c95952038b33c459807056b0abf345c8de96b4c2183b12adcef05bc6012e221cadd6339daf3c8b506d94175d4cd1bff690cf2500c6d949
data/README.md CHANGED
@@ -44,6 +44,12 @@ database_path ./geoip/database/GeoLite2-City.mmdb
44
44
  md5_path ./geoip/database/GeoLite2-City.md5
45
45
  ```
46
46
 
47
+ ### enable_auto_download
48
+
49
+ ```
50
+ enable_auto_download true
51
+ ```
52
+
47
53
  ### lookup_field
48
54
 
49
55
  ```
@@ -68,6 +74,12 @@ field_delimiter _
68
74
  flatten true
69
75
  ```
70
76
 
77
+ ### languages
78
+
79
+ ```
80
+ languages ["en"]
81
+ ```
82
+
71
83
  ### continent
72
84
 
73
85
  ```
@@ -134,16 +146,19 @@ connection_type true
134
146
  <filter tail.log>
135
147
  @type geoip
136
148
 
137
- download_url http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz
149
+ enable_auto_download true
138
150
  md5_url http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.md5
139
- database_path ./geoip/database/GeoLite2-City.mmdb
151
+ download_url http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz
140
152
  md5_path ./geoip/database/GeoLite2-City.md5
153
+ database_path ./geoip/database/GeoLite2-City.mmdb
141
154
 
142
155
  lookup_field host
143
156
  field_prefix geoip
144
- field_delimiter _
157
+ field_delimiter .
145
158
  flatten true
146
159
 
160
+ locale en
161
+
147
162
  continent true
148
163
  country true
149
164
  city true
@@ -161,14 +176,14 @@ Assuming following inputs are coming:
161
176
 
162
177
  ```javascript
163
178
  {
164
- "host":"212.99.123.25",
179
+ "host":"180.195.25.228",
165
180
  "user":"-",
166
181
  "method":"GET",
167
- "path":"/item/sports/4981",
182
+ "path":"/category/giftcards?from=20",
168
183
  "code":"200",
169
- "size":"94",
170
- "referer":"/category/electronics",
171
- "agent":"Mozilla/5.0 (Windows NT 6.0; rv:10.0.1) Gecko/20100101 Firefox/10.0.1"
184
+ "size":"63",
185
+ "referer":"-",
186
+ "agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:9.0.1) Gecko/20100101 Firefox/9.0.1"
172
187
  }
173
188
  ```
174
189
 
@@ -176,75 +191,51 @@ then output bocomes as belows:
176
191
 
177
192
  ```javascript
178
193
  {
179
- "host":"212.99.123.25",
194
+ "host":"180.195.25.228",
180
195
  "user":"-",
181
196
  "method":"GET",
182
- "path":"/item/sports/4981",
197
+ "path":"/category/giftcards?from=20",
183
198
  "code":"200",
184
- "size":"94",
185
- "referer":"/category/electronics",
186
- "agent":"Mozilla/5.0 (Windows NT 6.0; rv:10.0.1) Gecko/20100101 Firefox/10.0.1",
187
- "geoip_continent_code":"EU",
188
- "geoip_continent_geoname_id":6255148,
189
- "geoip_continent_names_de":"Europa",
190
- "geoip_continent_names_en":"Europe",
191
- "geoip_continent_names_es":"Europa",
192
- "geoip_continent_names_fr":"Europe",
193
- "geoip_continent_names_ja":"ヨーロッパ",
194
- "geoip_continent_names_pt-BR":"Europa",
195
- "geoip_continent_names_ru":"Европа",
196
- "geoip_continent_names_zh-CN":"欧洲",
197
- "geoip_country_geoname_id":3017382,
198
- "geoip_country_iso_code":"FR",
199
- "geoip_country_names_de":"Frankreich",
200
- "geoip_country_names_en":"France",
201
- "geoip_country_names_es":"Francia",
202
- "geoip_country_names_fr":"France",
203
- "geoip_country_names_ja":"フランス共和国",
204
- "geoip_country_names_pt-BR":"França",
205
- "geoip_country_names_ru":"Франция",
206
- "geoip_country_names_zh-CN":"法国",
207
- "geoip_city_geoname_id":3038354,
208
- "geoip_city_names_de":"Aix-en-Provence",
209
- "geoip_city_names_en":"Aix-en-Provence",
210
- "geoip_city_names_es":"Aix-en-Provence",
211
- "geoip_city_names_fr":"Aix-en-Provence",
212
- "geoip_city_names_ja":"エクス=アン=プロヴァンス",
213
- "geoip_city_names_pt-BR":"Aix-en-Provence",
214
- "geoip_city_names_ru":"Экс-ан-Прованс",
215
- "geoip_city_names_zh-CN":"普罗旺斯地区艾克斯",
216
- "geoip_location_latitude":43.5283,
217
- "geoip_location_longitude":5.4497,
218
- "geoip_location_time_zone":"Europe/Paris",
219
- "geoip_postal_code":"13090",
220
- "geoip_registered_country_geoname_id":3017382,
221
- "geoip_registered_country_iso_code":"FR",
222
- "geoip_registered_country_names_de":"Frankreich",
223
- "geoip_registered_country_names_en":"France",
224
- "geoip_registered_country_names_es":"Francia",
225
- "geoip_registered_country_names_fr":"France",
226
- "geoip_registered_country_names_ja":"フランス共和国",
227
- "geoip_registered_country_names_pt-BR":"França",
228
- "geoip_registered_country_names_ru":"Франция",
229
- "geoip_registered_country_names_zh-CN":"法国",
230
- "geoip_subdivisions_0_geoname_id":2985244,
231
- "geoip_subdivisions_0_iso_code":"U",
232
- "geoip_subdivisions_0_names_de":"Provence-Alpes-Côte d’Azur",
233
- "geoip_subdivisions_0_names_en":"Provence-Alpes-Côte d'Azur",
234
- "geoip_subdivisions_0_names_es":"Provenza-Alpes-Costa Azul",
235
- "geoip_subdivisions_0_names_fr":"Provence-Alpes-Côte d'Azur",
236
- "geoip_subdivisions_0_names_ja":"プロヴァンス=アルプ=コート・ダジュール地域圏",
237
- "geoip_subdivisions_0_names_pt-BR":"Provença-Alpes-Costa Azul",
238
- "geoip_subdivisions_0_names_ru":"Прованс — Альпы — Лазурный Берег",
239
- "geoip_subdivisions_0_names_zh-CN":"普罗旺斯-阿尔卑斯-蓝色海岸",
240
- "geoip_subdivisions_1_geoname_id":3031359,
241
- "geoip_subdivisions_1_iso_code":"13",
242
- "geoip_subdivisions_1_names_de":"Bouches-du-Rhône",
243
- "geoip_subdivisions_1_names_en":"Bouches-du-Rhône",
244
- "geoip_subdivisions_1_names_es":"Bocas del Ródano",
245
- "geoip_subdivisions_1_names_fr":"Bouches-du-Rhône",
246
- "geoip_subdivisions_1_names_pt-BR":"Bocas do Ródano",
247
- "geoip_localtion_latlon":"43.5283,5.4497"
199
+ "size":"63",
200
+ "referer":"-",
201
+ "agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:9.0.1) Gecko/20100101 Firefox/9.0.1",
202
+ "geoip.continent.code":"AS",
203
+ "geoip.continent.geoname_id":6255147,
204
+ "geoip.continent.iso_code":null,
205
+ "geoip.continent.name":"Asia",
206
+ "geoip.country.code":null,
207
+ "geoip.country.geoname_id":1694008,
208
+ "geoip.country.iso_code":"PH",
209
+ "geoip.country.name":"Philippines",
210
+ "geoip.city.code":null,
211
+ "geoip.city.geoname_id":1728893,
212
+ "geoip.city.iso_code":null,
213
+ "geoip.city.name":"Bagumbayan",
214
+ "geoip.location.latitude":13.45,
215
+ "geoip.location.longitude":123.6667,
216
+ "geoip.location.metro_code":null,
217
+ "geoip.location.time_zone":"Asia/Manila",
218
+ "geoip.postal.code":"4513",
219
+ "geoip.registered_country.code":null,
220
+ "geoip.registered_country.geoname_id":1694008,
221
+ "geoip.registered_country.iso_code":"PH",
222
+ "geoip.registered_country.name":"Philippines",
223
+ "geoip.represented_country.code":null,
224
+ "geoip.represented_country.geoname_id":null,
225
+ "geoip.represented_country.iso_code":null,
226
+ "geoip.represented_country.name":null,
227
+ "geoip.subdivisions.0.code":null,
228
+ "geoip.subdivisions.0.geoname_id":7521310,
229
+ "geoip.subdivisions.0.iso_code":"05",
230
+ "geoip.subdivisions.0.name":"Bicol",
231
+ "geoip.subdivisions.1.code":null,
232
+ "geoip.subdivisions.1.geoname_id":1731616,
233
+ "geoip.subdivisions.1.iso_code":"ALB",
234
+ "geoip.subdivisions.1.name":"Province of Albay",
235
+ "geoip.traits.is_anonymous_proxy":null,
236
+ "geoip.traits.is_satellite_provider":null,
237
+ "geoip.connection_type":null,
238
+ "geoip_localtion_latlon":""
248
239
  }
249
240
  ```
250
241
 
@@ -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-filter-geoip"
7
- spec.version = "0.2.4"
7
+ spec.version = "0.2.5"
8
8
  spec.authors = ["Minoru Osuka"]
9
9
  spec.email = ["minoru.osuka@gmail.com"]
10
10
 
@@ -7,16 +7,19 @@ module Fluent
7
7
  class GeoIPFilter < Filter
8
8
  Fluent::Plugin.register_filter('geoip', self)
9
9
 
10
- DEFAULT_DOWNLOAD_URL = 'http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz'
10
+ DEFAULT_ENABLE_DOWNLOAD = true
11
11
  DEFAULT_MD5_URL = 'http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.md5'
12
- DEFAULT_DATABASE_PATH = './geoip/database/GeoLite2-City.mmdb'
12
+ DEFAULT_DOWNLOAD_URL = 'http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz'
13
13
  DEFAULT_MD5_PATH = './geoip/database/GeoLite2-City.md5'
14
+ DEFAULT_DATABASE_PATH = './geoip/database/GeoLite2-City.mmdb'
14
15
 
15
16
  DEFAULT_LOOKUP_FIELD = 'ip'
16
17
  DEFAULT_FIELD_PREFIX = 'geoip'
17
- DEFAULT_FIELD_DELIMITER = '_'
18
+ DEFAULT_FIELD_DELIMITER = '.'
18
19
  DEFAULT_FLATTEN = false
19
20
 
21
+ DEFAULT_LOCALE = 'en'
22
+
20
23
  DEFAULT_CITY = true
21
24
  DEFAULT_CONTINENT = true
22
25
  DEFAULT_COUNTRY = true
@@ -28,16 +31,19 @@ module Fluent
28
31
  DEFAULT_TRAITS = true
29
32
  DEFAULT_CONNECTION_TYPE = true
30
33
 
31
- config_param :download_url, :string, :default => DEFAULT_DOWNLOAD_URL,
34
+ config_param :enable_auto_download, :string, :default => DEFAULT_ENABLE_DOWNLOAD,
35
+ :desc => ''
36
+
37
+ config_param :md5_path, :string, :default => DEFAULT_MD5_PATH,
32
38
  :desc => ''
33
39
 
34
40
  config_param :md5_url, :string, :default => DEFAULT_MD5_URL,
35
41
  :desc => ''
36
42
 
37
- config_param :database_path, :string, :default => DEFAULT_DATABASE_PATH,
43
+ config_param :download_url, :string, :default => DEFAULT_DOWNLOAD_URL,
38
44
  :desc => ''
39
45
 
40
- config_param :md5_path, :string, :default => DEFAULT_MD5_PATH,
46
+ config_param :database_path, :string, :default => DEFAULT_DATABASE_PATH,
41
47
  :desc => ''
42
48
 
43
49
  config_param :lookup_field, :string, :default => DEFAULT_LOOKUP_FIELD,
@@ -52,6 +58,9 @@ module Fluent
52
58
  config_param :flatten, :bool, :default => DEFAULT_FLATTEN,
53
59
  :desc => ''
54
60
 
61
+ config_param :locale, :string, :default => DEFAULT_LOCALE,
62
+ :desc => ''
63
+
55
64
  config_param :continent, :bool, :default => DEFAULT_CONTINENT,
56
65
  :desc => ''
57
66
 
@@ -89,14 +98,16 @@ module Fluent
89
98
  def configure(conf)
90
99
  super
91
100
 
92
- @download_url = conf.has_key?('download_url') ? conf['download_url'] : DEFAULT_DOWNLOAD_URL
101
+ @enable_auto_download = conf.has_key?('enable_auto_download') ? conf['enable_auto_download'] : DEFAULT_ENABLE_DOWNLOAD
93
102
 
94
103
  @md5_url = conf.has_key?('md5_url') ? conf['md5_url'] : DEFAULT_MD5_URL
95
104
 
96
- @database_path = conf.has_key?('database_path') ? conf['database_path'] : DEFAULT_DATABASE_PATH
105
+ @download_url = conf.has_key?('download_url') ? conf['download_url'] : DEFAULT_DOWNLOAD_URL
97
106
 
98
107
  @md5_path = conf.has_key?('md5_path') ? conf['md5_path'] : DEFAULT_MD5_PATH
99
108
 
109
+ @database_path = conf.has_key?('database_path') ? conf['database_path'] : DEFAULT_DATABASE_PATH
110
+
100
111
  @lookup_field = conf.has_key?('lookup_field') ? conf['lookup_field'] : DEFAULT_LOOKUP_FIELD
101
112
 
102
113
  @field_prefix = conf.has_key?('field_prefix') ? conf['field_prefix'] : DEFAULT_FIELD_PREFIX
@@ -105,6 +116,8 @@ module Fluent
105
116
 
106
117
  @flatten = conf.has_key?('flatten') ? to_boolean(conf['flatten']) : DEFAULT_FLATTEN
107
118
 
119
+ @locale = conf.has_key?('locale') ? conf['locale'] : DEFAULT_LOCALE
120
+
108
121
  @continent = conf.has_key?('continent') ? to_boolean(conf['continent']) : DEFAULT_CONTINENT
109
122
 
110
123
  @country = conf.has_key?('country') ? to_boolean(conf['country']) : DEFAULT_COUNTRY
@@ -125,7 +138,9 @@ module Fluent
125
138
 
126
139
  @connection_type = conf.has_key?('connection_type') ? to_boolean(conf['connection_type']) : DEFAULT_CONNECTION_TYPE
127
140
 
128
- download_database @download_url, @md5_url, @database_path, @md5_path
141
+ if enable_auto_download then
142
+ download_database @download_url, @md5_url, @database_path, @md5_path
143
+ end
129
144
 
130
145
  @database = MaxMindDB.new(@database_path)
131
146
  end
@@ -137,90 +152,153 @@ module Fluent
137
152
  geoip = @database.lookup(ip)
138
153
 
139
154
  if geoip.found? then
140
- geoip_hash = geoip.to_hash
155
+ #geoip_hash = geoip.to_hash
156
+
157
+ if @continent then
158
+ continent_hash = {}
159
+
160
+ continent_hash['code'] = geoip.continent.code
161
+ continent_hash['geoname_id'] = geoip.continent.geoname_id
162
+ continent_hash['iso_code'] = geoip.continent.iso_code
163
+ continent_hash['name'] = geoip.continent.name(@locale)
141
164
 
142
- if @continent && geoip_hash.has_key?('continent') then
143
165
  if @flatten then
144
- record.merge!(to_flatten(geoip_hash['continent'], [@field_prefix, 'continent'], @field_delimiter))
166
+ record.merge!(to_flatten(continent_hash, [@field_prefix, 'continent'], @field_delimiter))
145
167
  else
146
- record[[@field_prefix, 'continent'].join(@field_delimiter)] = geoip_hash['continent'].to_json
168
+ record[[@field_prefix, 'continent'].join(@field_delimiter)] = continent_hash.to_json
147
169
  end
148
170
  end
149
171
 
150
- if @country && geoip_hash.has_key?('country') then
172
+ if @country then
173
+ country_hash = {}
174
+
175
+ country_hash['code'] = geoip.country.code
176
+ country_hash['geoname_id'] = geoip.country.geoname_id
177
+ country_hash['iso_code'] = geoip.country.iso_code
178
+ country_hash['name'] = geoip.country.name(@locale)
179
+
151
180
  if @flatten then
152
- record.merge!(to_flatten(geoip_hash['country'], [@field_prefix, 'country'], @field_delimiter))
181
+ record.merge!(to_flatten(country_hash, [@field_prefix, 'country'], @field_delimiter))
153
182
  else
154
- record[[@field_prefix, 'country'].join(@field_delimiter)] = geoip_hash['country'].to_json
183
+ record[[@field_prefix, 'country'].join(@field_delimiter)] = country_hash.to_json
155
184
  end
156
185
  end
157
186
 
158
- if @city && geoip_hash.has_key?('city') then
187
+ if @city then
188
+ city_hash = {}
189
+
190
+ city_hash['code'] = geoip.city.code
191
+ city_hash['geoname_id'] = geoip.city.geoname_id
192
+ city_hash['iso_code'] = geoip.city.iso_code
193
+ city_hash['name'] = geoip.city.name(@locale)
194
+
159
195
  if @flatten then
160
- record.merge!(to_flatten(geoip_hash['city'], [@field_prefix, 'city'], @field_delimiter))
196
+ record.merge!(to_flatten(city_hash, [@field_prefix, 'city'], @field_delimiter))
161
197
  else
162
- record[[@field_prefix, 'city'].join(@field_delimiter)] = geoip_hash['city'].to_json
198
+ record[[@field_prefix, 'city'].join(@field_delimiter)] = city_hash.to_json
163
199
  end
164
200
  end
165
201
 
166
- if @location && geoip_hash.has_key?('location') then
202
+ if @location then
203
+ location_hash = {}
204
+
205
+ location_hash['latitude'] = geoip.location.latitude
206
+ location_hash['longitude'] = geoip.location.longitude
207
+ location_hash['metro_code'] = geoip.location.metro_code
208
+ location_hash['time_zone'] = geoip.location.time_zone
209
+
167
210
  if @flatten then
168
- record.merge!(to_flatten(geoip_hash['location'], [@field_prefix, 'location'], @field_delimiter))
211
+ record.merge!(to_flatten(location_hash, [@field_prefix, 'location'], @field_delimiter))
169
212
  else
170
- record[[@field_prefix, 'location'].join(@field_delimiter)] = geoip_hash['location'].to_json
213
+ record[[@field_prefix, 'location'].join(@field_delimiter)] = location_hash.to_json
171
214
  end
172
215
  end
173
216
 
174
- if @postal && geoip_hash.has_key?('postal') then
217
+ if @postal then
218
+ postal_hash = {}
219
+
220
+ postal_hash['code'] = geoip.postal.code
221
+
175
222
  if @flatten then
176
- record.merge!(to_flatten(geoip_hash['postal'], [@field_prefix, 'postal'], @field_delimiter))
223
+ record.merge!(to_flatten(postal_hash, [@field_prefix, 'postal'], @field_delimiter))
177
224
  else
178
- record[[@field_prefix, 'postal'].join(@field_delimiter)] = geoip_hash['postal'].to_json
225
+ record[[@field_prefix, 'postal'].join(@field_delimiter)] = postal_hash.to_json
179
226
  end
180
227
  end
181
228
 
182
- if @registered_country && geoip_hash.has_key?('registered_country') then
229
+ if @registered_country then
230
+ registered_country_hash = {}
231
+
232
+ registered_country_hash['code'] = geoip.registered_country.code
233
+ registered_country_hash['geoname_id'] = geoip.registered_country.geoname_id
234
+ registered_country_hash['iso_code'] = geoip.registered_country.iso_code
235
+ registered_country_hash['name'] = geoip.registered_country.name(@locale)
236
+
183
237
  if @flatten then
184
- record.merge!(to_flatten(geoip_hash['registered_country'], [@field_prefix, 'registered_country'], @field_delimiter))
238
+ record.merge!(to_flatten(registered_country_hash, [@field_prefix, 'registered_country'], @field_delimiter))
185
239
  else
186
- record[[@field_prefix, 'registered_country'].join(@field_delimiter)] = geoip_hash['registered_country'].to_json
240
+ record[[@field_prefix, 'registered_country'].join(@field_delimiter)] = registered_country_hash.to_json
187
241
  end
188
242
  end
189
243
 
190
- if @represented_country && geoip_hash.has_key?('represented_country') then
244
+ if @represented_country then
245
+ represented_country_hash = {}
246
+
247
+ represented_country_hash['code'] = geoip.represented_country.code
248
+ represented_country_hash['geoname_id'] = geoip.represented_country.geoname_id
249
+ represented_country_hash['iso_code'] = geoip.represented_country.iso_code
250
+ represented_country_hash['name'] = geoip.represented_country.name(@locale)
251
+
191
252
  if @flatten then
192
- record.merge!(to_flatten(geoip_hash['represented_country'], [@field_prefix, 'represented_country'], @field_delimiter))
253
+ record.merge!(to_flatten(represented_country_hash, [@field_prefix, 'represented_country'], @field_delimiter))
193
254
  else
194
- record[[@field_prefix, 'represented_country'].join(@field_delimiter)] = geoip_hash['represented_country'].to_json
255
+ record[[@field_prefix, 'represented_country'].join(@field_delimiter)] = represented_country_hash.to_json
195
256
  end
196
257
  end
197
258
 
198
- if @subdivisions && geoip_hash.has_key?('subdivisions') then
259
+ if @subdivisions then
260
+ subdivision_arry = []
261
+
262
+ i = 0
263
+ geoip.subdivisions.each do |subdivision|
264
+ subdivision_hash = {}
265
+
266
+ subdivision_hash['code'] = subdivision.code
267
+ subdivision_hash['geoname_id'] = subdivision.geoname_id
268
+ subdivision_hash['iso_code'] = subdivision.iso_code
269
+ subdivision_hash['name'] = subdivision.name(@locale)
270
+
271
+ subdivision_arry.push(subdivision_hash)
272
+
273
+ i = i + 1
274
+ end
275
+
199
276
  if @flatten then
200
277
  i = 0
201
- geoip_hash['subdivisions'].each do |subdivision|
278
+ subdivision_arry.each do |subdivision|
202
279
  record.merge!(to_flatten(subdivision, [@field_prefix, 'subdivisions', i.to_s], @field_delimiter))
203
280
  i = i + 1
204
281
  end
205
282
  else
206
- record[[@field_prefix, 'subdivisions'].join(@field_delimiter)] = geoip_hash['subdivisions'].to_json
283
+ record[[@field_prefix, 'subdivisions'].join(@field_delimiter)] = subdivision_arry.to_json
207
284
  end
208
285
  end
209
286
 
210
- if @traits && geoip_hash.has_key?('traits') then
287
+ if @traits then
288
+ traits_hash = {}
289
+
290
+ traits_hash['is_anonymous_proxy'] = geoip.traits.is_anonymous_proxy
291
+ traits_hash['is_satellite_provider'] = geoip.traits.is_satellite_provider
292
+
211
293
  if @flatten then
212
- record.merge!(to_flatten(geoip_hash['traits'], [@field_prefix, 'traits'], @field_delimiter))
294
+ record.merge!(to_flatten(traits_hash, [@field_prefix, 'traits'], @field_delimiter))
213
295
  else
214
- record[[@field_prefix, 'traits'].join(@field_delimiter)] = geoip_hash['traits'].to_json
296
+ record[[@field_prefix, 'traits'].join(@field_delimiter)] = traits_hash.to_json
215
297
  end
216
298
  end
217
299
 
218
- if @connection_type && geoip_hash.has_key?('connection_type') then
219
- if @flatten then
220
- record.merge!(to_flatten(geoip_hash['connection_type'], [@field_prefix, 'connection_type'], @field_delimiter))
221
- else
222
- record[[@field_prefix, 'connection_type'].join(@field_delimiter)] = geoip_hash['connection_type'].to_json
223
- end
300
+ if @connection_type then
301
+ record[[@field_prefix, 'connection_type'].join(@field_delimiter)] = geoip.connection_type
224
302
  end
225
303
 
226
304
  log.info "Record: %s" % record.inspect
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-filter-geoip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.4
4
+ version: 0.2.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Minoru Osuka
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-20 00:00:00.000000000 Z
11
+ date: 2016-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fluentd