fluent-plugin-filter-geoip 0.2.5 → 0.2.6
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.
- checksums.yaml +4 -4
- data/README.md +51 -11
- data/fluent-plugin-filter-geoip.gemspec +1 -1
- data/lib/fluent/plugin/filter_geoip.rb +22 -22
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8edef2e0b807f33865469e4657a8c41f130cc7d
|
4
|
+
data.tar.gz: 12aed486300080cec3457636590e6e3696118e02
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92ac13af10007c3ef2c767186c7008b11d5c6b93755b065ffce48e5a8b1642877a0a64736642f8cf5f7c81ef26018f10864ce2ff6ea310b35199f255cd0ef271
|
7
|
+
data.tar.gz: 7105c836eb52cce4bdcf6c3dacd7c91579ea8a8a5c19feee8aabd0bb90042f14fc25bbafd0d63b90713cde97d8a524b80aa928149391717098117ccb278ea6b0
|
data/README.md
CHANGED
@@ -20,122 +20,162 @@ Or install it yourself as:
|
|
20
20
|
|
21
21
|
## Config parameters
|
22
22
|
|
23
|
-
###
|
23
|
+
### enable_auto_download
|
24
|
+
|
25
|
+
If true, enable to download GeoIP2 database autometically (default: true).
|
24
26
|
|
25
27
|
```
|
26
|
-
|
28
|
+
enable_auto_download true
|
27
29
|
```
|
28
30
|
|
29
31
|
### md5_url
|
30
32
|
|
33
|
+
GeoIP2 MD5 checksum URL (default: http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.md5)
|
34
|
+
|
31
35
|
```
|
32
36
|
md5_url http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.md5
|
33
37
|
```
|
34
38
|
|
35
|
-
###
|
39
|
+
### download_url
|
40
|
+
|
41
|
+
GeoIP2 database download URL (default: http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz).
|
36
42
|
|
37
43
|
```
|
38
|
-
|
44
|
+
download_url http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.mmdb.gz
|
39
45
|
```
|
40
46
|
|
41
47
|
### md5_path
|
42
48
|
|
49
|
+
GeoIP2 MD5 checksum path. (default: ./geoip/database/GeoLite2-City.md5)
|
50
|
+
|
43
51
|
```
|
44
52
|
md5_path ./geoip/database/GeoLite2-City.md5
|
45
53
|
```
|
46
54
|
|
47
|
-
###
|
55
|
+
### database_path
|
56
|
+
|
57
|
+
GeoIP2 database path. (default: ./geoip/database/GeoLite2-City.md5)
|
48
58
|
|
49
59
|
```
|
50
|
-
|
60
|
+
database_path ./geoip/database/GeoLite2-City.mmdb
|
51
61
|
```
|
52
62
|
|
53
63
|
### lookup_field
|
54
64
|
|
65
|
+
Specify the field name that IP address is stored (default: ip).
|
66
|
+
|
55
67
|
```
|
56
68
|
lookup_field host
|
57
69
|
```
|
58
70
|
|
59
|
-
###
|
71
|
+
### output_field
|
72
|
+
|
73
|
+
Specify the field name that store the result (default: geoip).
|
60
74
|
|
61
75
|
```
|
62
|
-
|
76
|
+
output_field geoip
|
63
77
|
```
|
64
78
|
|
65
79
|
### field_delimiter
|
66
80
|
|
81
|
+
Specify the field delimiter (default .).
|
82
|
+
|
67
83
|
```
|
68
|
-
field_delimiter
|
84
|
+
field_delimiter .
|
69
85
|
```
|
70
86
|
|
71
87
|
### flatten
|
72
88
|
|
89
|
+
If true, to flatten the result using field_delimiter (default: true).
|
90
|
+
|
73
91
|
```
|
74
92
|
flatten true
|
75
93
|
```
|
76
94
|
|
77
|
-
###
|
95
|
+
### locale
|
96
|
+
|
97
|
+
Get the data for the specified locale (default: en).
|
78
98
|
|
79
99
|
```
|
80
|
-
|
100
|
+
locale en
|
81
101
|
```
|
82
102
|
|
83
103
|
### continent
|
84
104
|
|
105
|
+
If true, to get continent information (default: true).
|
106
|
+
|
85
107
|
```
|
86
108
|
continent true
|
87
109
|
```
|
88
110
|
|
89
111
|
### country
|
90
112
|
|
113
|
+
If true, to get country information (default: true).
|
114
|
+
|
91
115
|
```
|
92
116
|
country true
|
93
117
|
```
|
94
118
|
|
95
119
|
### city
|
96
120
|
|
121
|
+
If true, to get city information (default: true).
|
122
|
+
|
97
123
|
```
|
98
124
|
city true
|
99
125
|
```
|
100
126
|
|
101
127
|
### location
|
102
128
|
|
129
|
+
If true, to get location information (default: true).
|
130
|
+
|
103
131
|
```
|
104
132
|
location true
|
105
133
|
```
|
106
134
|
|
107
135
|
### postal
|
108
136
|
|
137
|
+
If true, to get postal information (default: true).
|
138
|
+
|
109
139
|
```
|
110
140
|
postal true
|
111
141
|
```
|
112
142
|
|
113
143
|
### registered_country
|
114
144
|
|
145
|
+
If true, to get registered country information (default: true).
|
146
|
+
|
115
147
|
```
|
116
148
|
registered_country true
|
117
149
|
```
|
118
150
|
|
119
151
|
### represented_country
|
120
152
|
|
153
|
+
If true, to get represented country information (default: true).
|
154
|
+
|
121
155
|
```
|
122
156
|
represented_country true
|
123
157
|
```
|
124
158
|
|
125
159
|
### subdivisions
|
126
160
|
|
161
|
+
If true, to get subdivisions information (default: true).
|
162
|
+
|
127
163
|
```
|
128
164
|
subdivisions true
|
129
165
|
```
|
130
166
|
|
131
167
|
### traits
|
132
168
|
|
169
|
+
If true, to get traits information (default: true).
|
170
|
+
|
133
171
|
```
|
134
172
|
traits true
|
135
173
|
```
|
136
174
|
|
137
175
|
### connection_type
|
138
176
|
|
177
|
+
If true, to get connection type information (default: true).
|
178
|
+
|
139
179
|
```
|
140
180
|
connection_type true
|
141
181
|
```
|
@@ -14,7 +14,7 @@ module Fluent
|
|
14
14
|
DEFAULT_DATABASE_PATH = './geoip/database/GeoLite2-City.mmdb'
|
15
15
|
|
16
16
|
DEFAULT_LOOKUP_FIELD = 'ip'
|
17
|
-
|
17
|
+
DEFAULT_OUTPU_FIELD = 'geoip'
|
18
18
|
DEFAULT_FIELD_DELIMITER = '.'
|
19
19
|
DEFAULT_FLATTEN = false
|
20
20
|
|
@@ -49,7 +49,7 @@ module Fluent
|
|
49
49
|
config_param :lookup_field, :string, :default => DEFAULT_LOOKUP_FIELD,
|
50
50
|
:desc => ''
|
51
51
|
|
52
|
-
config_param :
|
52
|
+
config_param :output_field, :string, :default => DEFAULT_OUTPU_FIELD,
|
53
53
|
:desc => ''
|
54
54
|
|
55
55
|
config_param :field_delimiter, :string, :default => DEFAULT_FIELD_DELIMITER,
|
@@ -110,7 +110,7 @@ module Fluent
|
|
110
110
|
|
111
111
|
@lookup_field = conf.has_key?('lookup_field') ? conf['lookup_field'] : DEFAULT_LOOKUP_FIELD
|
112
112
|
|
113
|
-
@
|
113
|
+
@output_field = conf.has_key?('output_field') ? conf['output_field'] : DEFAULT_OUTPU_FIELD
|
114
114
|
|
115
115
|
@field_delimiter = conf.has_key?('field_delimiter') ? conf['field_delimiter'] : DEFAULT_FIELD_DELIMITER
|
116
116
|
|
@@ -163,9 +163,9 @@ module Fluent
|
|
163
163
|
continent_hash['name'] = geoip.continent.name(@locale)
|
164
164
|
|
165
165
|
if @flatten then
|
166
|
-
record.merge!(to_flatten(continent_hash, [@
|
166
|
+
record.merge!(to_flatten(continent_hash, [@output_field, 'continent'], @field_delimiter))
|
167
167
|
else
|
168
|
-
record[[@
|
168
|
+
record[[@output_field, 'continent'].join(@field_delimiter)] = continent_hash.to_json
|
169
169
|
end
|
170
170
|
end
|
171
171
|
|
@@ -178,9 +178,9 @@ module Fluent
|
|
178
178
|
country_hash['name'] = geoip.country.name(@locale)
|
179
179
|
|
180
180
|
if @flatten then
|
181
|
-
record.merge!(to_flatten(country_hash, [@
|
181
|
+
record.merge!(to_flatten(country_hash, [@output_field, 'country'], @field_delimiter))
|
182
182
|
else
|
183
|
-
record[[@
|
183
|
+
record[[@output_field, 'country'].join(@field_delimiter)] = country_hash.to_json
|
184
184
|
end
|
185
185
|
end
|
186
186
|
|
@@ -193,9 +193,9 @@ module Fluent
|
|
193
193
|
city_hash['name'] = geoip.city.name(@locale)
|
194
194
|
|
195
195
|
if @flatten then
|
196
|
-
record.merge!(to_flatten(city_hash, [@
|
196
|
+
record.merge!(to_flatten(city_hash, [@output_field, 'city'], @field_delimiter))
|
197
197
|
else
|
198
|
-
record[[@
|
198
|
+
record[[@output_field, 'city'].join(@field_delimiter)] = city_hash.to_json
|
199
199
|
end
|
200
200
|
end
|
201
201
|
|
@@ -208,9 +208,9 @@ module Fluent
|
|
208
208
|
location_hash['time_zone'] = geoip.location.time_zone
|
209
209
|
|
210
210
|
if @flatten then
|
211
|
-
record.merge!(to_flatten(location_hash, [@
|
211
|
+
record.merge!(to_flatten(location_hash, [@output_field, 'location'], @field_delimiter))
|
212
212
|
else
|
213
|
-
record[[@
|
213
|
+
record[[@output_field, 'location'].join(@field_delimiter)] = location_hash.to_json
|
214
214
|
end
|
215
215
|
end
|
216
216
|
|
@@ -220,9 +220,9 @@ module Fluent
|
|
220
220
|
postal_hash['code'] = geoip.postal.code
|
221
221
|
|
222
222
|
if @flatten then
|
223
|
-
record.merge!(to_flatten(postal_hash, [@
|
223
|
+
record.merge!(to_flatten(postal_hash, [@output_field, 'postal'], @field_delimiter))
|
224
224
|
else
|
225
|
-
record[[@
|
225
|
+
record[[@output_field, 'postal'].join(@field_delimiter)] = postal_hash.to_json
|
226
226
|
end
|
227
227
|
end
|
228
228
|
|
@@ -235,9 +235,9 @@ module Fluent
|
|
235
235
|
registered_country_hash['name'] = geoip.registered_country.name(@locale)
|
236
236
|
|
237
237
|
if @flatten then
|
238
|
-
record.merge!(to_flatten(registered_country_hash, [@
|
238
|
+
record.merge!(to_flatten(registered_country_hash, [@output_field, 'registered_country'], @field_delimiter))
|
239
239
|
else
|
240
|
-
record[[@
|
240
|
+
record[[@output_field, 'registered_country'].join(@field_delimiter)] = registered_country_hash.to_json
|
241
241
|
end
|
242
242
|
end
|
243
243
|
|
@@ -250,9 +250,9 @@ module Fluent
|
|
250
250
|
represented_country_hash['name'] = geoip.represented_country.name(@locale)
|
251
251
|
|
252
252
|
if @flatten then
|
253
|
-
record.merge!(to_flatten(represented_country_hash, [@
|
253
|
+
record.merge!(to_flatten(represented_country_hash, [@output_field, 'represented_country'], @field_delimiter))
|
254
254
|
else
|
255
|
-
record[[@
|
255
|
+
record[[@output_field, 'represented_country'].join(@field_delimiter)] = represented_country_hash.to_json
|
256
256
|
end
|
257
257
|
end
|
258
258
|
|
@@ -276,11 +276,11 @@ module Fluent
|
|
276
276
|
if @flatten then
|
277
277
|
i = 0
|
278
278
|
subdivision_arry.each do |subdivision|
|
279
|
-
record.merge!(to_flatten(subdivision, [@
|
279
|
+
record.merge!(to_flatten(subdivision, [@output_field, 'subdivisions', i.to_s], @field_delimiter))
|
280
280
|
i = i + 1
|
281
281
|
end
|
282
282
|
else
|
283
|
-
record[[@
|
283
|
+
record[[@output_field, 'subdivisions'].join(@field_delimiter)] = subdivision_arry.to_json
|
284
284
|
end
|
285
285
|
end
|
286
286
|
|
@@ -291,14 +291,14 @@ module Fluent
|
|
291
291
|
traits_hash['is_satellite_provider'] = geoip.traits.is_satellite_provider
|
292
292
|
|
293
293
|
if @flatten then
|
294
|
-
record.merge!(to_flatten(traits_hash, [@
|
294
|
+
record.merge!(to_flatten(traits_hash, [@output_field, 'traits'], @field_delimiter))
|
295
295
|
else
|
296
|
-
record[[@
|
296
|
+
record[[@output_field, 'traits'].join(@field_delimiter)] = traits_hash.to_json
|
297
297
|
end
|
298
298
|
end
|
299
299
|
|
300
300
|
if @connection_type then
|
301
|
-
record[[@
|
301
|
+
record[[@output_field, 'connection_type'].join(@field_delimiter)] = geoip.connection_type
|
302
302
|
end
|
303
303
|
|
304
304
|
log.info "Record: %s" % record.inspect
|