fluent-plugin-geoip 1.1.0 → 1.2.0
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/.github/ISSUE_TEMPLATE.md +19 -0
- data/.travis.yml +1 -1
- data/README.md +25 -12
- data/docker-compose.yml +12 -5
- data/dockerfiles/Dockerfile-ruby2.1 +1 -1
- data/dockerfiles/Dockerfile-ruby2.2 +1 -1
- data/dockerfiles/Dockerfile-ruby2.3 +1 -1
- data/dockerfiles/Dockerfile-ruby2.4 +1 -1
- data/dockerfiles/Dockerfile-ruby2.5 +8 -0
- data/fluent-plugin-geoip.gemspec +1 -1
- data/lib/fluent/plugin/filter_geoip.rb +2 -1
- data/lib/fluent/plugin/geoip.rb +7 -17
- data/lib/fluent/plugin/out_geoip.rb +2 -1
- data/test/plugin/test_filter_geoip.rb +62 -62
- data/test/plugin/test_out_geoip.rb +60 -88
- metadata +4 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3a88a41e91e927825689d485148e6d1369532f01f2bc3395d76204c98f02366f
|
|
4
|
+
data.tar.gz: 984c8db424d319565862de808844432366f38d00b2cd1c6b617d4ead0d77af8f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0f48ad83f7b2ed7d47bd7822042e546cd1f0b6503d71c3175c07ccdc84fbfa21fdafc960187a40b5cd39d85636e256b09ba69ff69972ef5806bf3aa746d6ef82
|
|
7
|
+
data.tar.gz: 1ee9ce806e3bf90c1fac1657bc09ad1abfac5033ce6ac1f79b78fe6d374caab45b2fcb3eb3812ccae34124da2e861bd9e65f19dbac4574ae4d3db637bff3e567
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
#### Problem
|
|
2
|
+
|
|
3
|
+
...
|
|
4
|
+
|
|
5
|
+
#### Steps to replicate
|
|
6
|
+
|
|
7
|
+
Provide example config and message
|
|
8
|
+
|
|
9
|
+
#### Expected Behavior
|
|
10
|
+
|
|
11
|
+
...
|
|
12
|
+
|
|
13
|
+
#### Your environment
|
|
14
|
+
|
|
15
|
+
* OS version
|
|
16
|
+
* paste result of ``fluentd --version`` or ``td-agent --version``
|
|
17
|
+
* plugin version
|
|
18
|
+
* paste boot log of fluentd or td-agent
|
|
19
|
+
* paste result of ``fluent-gem list``, ``td-agent-gem list`` or your Gemfile.lock
|
data/.travis.yml
CHANGED
|
@@ -4,7 +4,7 @@ services:
|
|
|
4
4
|
|
|
5
5
|
env:
|
|
6
6
|
global:
|
|
7
|
-
DOCKER_COMPOSE_VERSION: 1.
|
|
7
|
+
DOCKER_COMPOSE_VERSION: 1.18.0
|
|
8
8
|
matrix:
|
|
9
9
|
- TARGET_RUBY_VERSION=2.1 BUNDLE_GEMFILE=/app/gemfiles/fluentd_v1.0_with_backport_dig.gemfile
|
|
10
10
|
- TARGET_RUBY_VERSION=2.2 BUNDLE_GEMFILE=/app/gemfiles/fluentd_v1.0_with_backport_dig.gemfile
|
data/README.md
CHANGED
|
@@ -78,7 +78,7 @@ before use, install dependent library as:
|
|
|
78
78
|
|
|
79
79
|
```bash
|
|
80
80
|
# for RHEL/CentOS
|
|
81
|
-
$ sudo yum
|
|
81
|
+
$ sudo yum groupinstall "Development Tools"
|
|
82
82
|
$ sudo yum install geoip-devel --enablerepo=epel
|
|
83
83
|
|
|
84
84
|
# for Ubuntu/Debian
|
|
@@ -117,7 +117,7 @@ Note that filter version of geoip plugin does not have handling tag feature.
|
|
|
117
117
|
|
|
118
118
|
# Specify one or more geoip lookup field which has ip address (default: host)
|
|
119
119
|
# in the case of accessing nested value, delimit keys by dot like 'host.ip'.
|
|
120
|
-
|
|
120
|
+
geoip_lookup_keys host
|
|
121
121
|
|
|
122
122
|
# Specify optional geoip database (using bundled GeoLiteCity databse by default)
|
|
123
123
|
# geoip_database "/path/to/your/GeoIPCity.dat"
|
|
@@ -149,7 +149,7 @@ Note that filter version of geoip plugin does not have handling tag feature.
|
|
|
149
149
|
```xml
|
|
150
150
|
<filter access.apache>
|
|
151
151
|
@type geoip
|
|
152
|
-
|
|
152
|
+
geoip_lookup_keys user1_host, user2_host
|
|
153
153
|
<record>
|
|
154
154
|
user1_city ${city.names.en["user1_host"]}
|
|
155
155
|
user2_city ${city.names.en["user2_host"]}
|
|
@@ -164,7 +164,7 @@ It is a sample to get friendly geo point recdords for elasticsearch with Yajl (J
|
|
|
164
164
|
```
|
|
165
165
|
<filter access.apache>
|
|
166
166
|
@type geoip
|
|
167
|
-
|
|
167
|
+
geoip_lookup_keys host
|
|
168
168
|
<record>
|
|
169
169
|
# lat lon as properties
|
|
170
170
|
# ex. {"lat" => 37.4192008972168, "lon" => -122.05740356445312 }
|
|
@@ -189,7 +189,7 @@ On the case of using td-agent3 (v1-config), it have to quote `{ ... }` or `[ ...
|
|
|
189
189
|
```
|
|
190
190
|
<filter access.apache>
|
|
191
191
|
@type geoip
|
|
192
|
-
|
|
192
|
+
geoip_lookup_keys host
|
|
193
193
|
<record>
|
|
194
194
|
location_properties '{ "lat" : ${location.latitude["host"]}, "lon" : ${location.longitude["host"]} }'
|
|
195
195
|
location_string ${location.latitude["host"]},${location.longitude["host"]}
|
|
@@ -207,7 +207,7 @@ On the case of using td-agent3 (v1-config), it have to quote `{ ... }` or `[ ...
|
|
|
207
207
|
|
|
208
208
|
# Specify one or more geoip lookup field which has ip address (default: host)
|
|
209
209
|
# in the case of accessing nested value, delimit keys by dot like 'host.ip'.
|
|
210
|
-
|
|
210
|
+
geoip_lookup_keys host
|
|
211
211
|
|
|
212
212
|
# Specify optional geoip database (using bundled GeoLiteCity databse by default)
|
|
213
213
|
geoip_database "/path/to/your/GeoIPCity.dat"
|
|
@@ -255,9 +255,10 @@ On the case of using td-agent3 (v1-config), it have to quote `{ ... }` or `[ ...
|
|
|
255
255
|
@type forward
|
|
256
256
|
</source>
|
|
257
257
|
|
|
258
|
+
|
|
258
259
|
<filter test.geoip>
|
|
259
260
|
@type geoip
|
|
260
|
-
|
|
261
|
+
geoip_lookup_keys host
|
|
261
262
|
<record>
|
|
262
263
|
city ${city.names.en["host"]}
|
|
263
264
|
lat ${location.latitude["host"]}
|
|
@@ -305,7 +306,7 @@ $ bundle exec ruby urils/dump.rb geoip 66.102.3.80
|
|
|
305
306
|
</store>
|
|
306
307
|
<store>
|
|
307
308
|
@type geoip
|
|
308
|
-
|
|
309
|
+
geoip_lookup_keys host
|
|
309
310
|
<record>
|
|
310
311
|
lat ${location.latitude["host"]}
|
|
311
312
|
lon ${location.longitude["host"]}
|
|
@@ -438,12 +439,18 @@ Path to GeoIP database file.
|
|
|
438
439
|
|
|
439
440
|
Path to GeoIP2 database file.
|
|
440
441
|
|
|
441
|
-
**
|
|
442
|
+
**geoip_lookup_keys** (array) (optional)
|
|
442
443
|
|
|
443
|
-
*
|
|
444
|
+
* Default_value: `["host"]`
|
|
444
445
|
|
|
445
446
|
Specify one or more geoip lookup field which has IP address.
|
|
446
447
|
|
|
448
|
+
**geoip_lookup_key** (string) (optional) (deprecated)
|
|
449
|
+
|
|
450
|
+
* Default value: `nil`.
|
|
451
|
+
|
|
452
|
+
Use geoip_lookup_keys instead.
|
|
453
|
+
|
|
447
454
|
**skip_adding_null_record** (bool) (optional)
|
|
448
455
|
|
|
449
456
|
* Default value: `nil`
|
|
@@ -489,12 +496,18 @@ Path to GeoIP database file.
|
|
|
489
496
|
|
|
490
497
|
Path to GeoIP2 database file.
|
|
491
498
|
|
|
492
|
-
**
|
|
499
|
+
**geoip_lookup_keys** (array) (optional)
|
|
493
500
|
|
|
494
|
-
* Default value: `host
|
|
501
|
+
* Default value: `["host"]`
|
|
495
502
|
|
|
496
503
|
Specify one or more geoip lookup field which has IP address.
|
|
497
504
|
|
|
505
|
+
**geoip_lookup_key** (string) (optional) (deprecated)
|
|
506
|
+
|
|
507
|
+
* Default value: `nil`.
|
|
508
|
+
|
|
509
|
+
Use geoip_lookup_keys instead.
|
|
510
|
+
|
|
498
511
|
**skip_adding_null_record** (bool) (optional)
|
|
499
512
|
|
|
500
513
|
* Default value: `nil`
|
data/docker-compose.yml
CHANGED
|
@@ -1,31 +1,38 @@
|
|
|
1
|
-
version: "
|
|
1
|
+
version: "3"
|
|
2
2
|
services:
|
|
3
|
+
test-ruby2.5:
|
|
4
|
+
build:
|
|
5
|
+
context: .
|
|
6
|
+
dockerfile: dockerfiles/Dockerfile-ruby2.5
|
|
7
|
+
env_file:
|
|
8
|
+
- env
|
|
9
|
+
command: tail -f /dev/null
|
|
3
10
|
test-ruby2.4:
|
|
4
11
|
build:
|
|
5
12
|
context: .
|
|
6
13
|
dockerfile: dockerfiles/Dockerfile-ruby2.4
|
|
7
14
|
env_file:
|
|
8
15
|
- env
|
|
9
|
-
command:
|
|
16
|
+
command: tail -f /dev/null
|
|
10
17
|
test-ruby2.3:
|
|
11
18
|
build:
|
|
12
19
|
context: .
|
|
13
20
|
dockerfile: dockerfiles/Dockerfile-ruby2.3
|
|
14
21
|
env_file:
|
|
15
22
|
- env
|
|
16
|
-
command:
|
|
23
|
+
command: tail -f /dev/null
|
|
17
24
|
test-ruby2.2:
|
|
18
25
|
build:
|
|
19
26
|
context: .
|
|
20
27
|
dockerfile: dockerfiles/Dockerfile-ruby2.2
|
|
21
28
|
env_file:
|
|
22
29
|
- env
|
|
23
|
-
command:
|
|
30
|
+
command: tail -f /dev/null
|
|
24
31
|
test-ruby2.1:
|
|
25
32
|
build:
|
|
26
33
|
context: .
|
|
27
34
|
dockerfile: dockerfiles/Dockerfile-ruby2.1
|
|
28
35
|
env_file:
|
|
29
36
|
- env
|
|
30
|
-
command:
|
|
37
|
+
command: tail -f /dev/null
|
|
31
38
|
|
|
@@ -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 ruby-dev libc6-compat
|
|
5
|
+
RUN apk --no-cache --update add build-base automake autoconf libtool ruby-dev libc6-compat 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 ruby-dev libc6-compat
|
|
5
|
+
RUN apk --no-cache --update add build-base automake autoconf libtool ruby-dev libc6-compat 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 ruby-dev libc6-compat
|
|
5
|
+
RUN apk --no-cache --update add build-base automake autoconf libtool ruby-dev libc6-compat 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 ruby-dev libc6-compat
|
|
5
|
+
RUN apk --no-cache --update add build-base automake autoconf libtool ruby-dev libc6-compat geoip-dev git
|
|
6
6
|
|
|
7
7
|
WORKDIR /app
|
|
8
8
|
COPY . .
|
data/fluent-plugin-geoip.gemspec
CHANGED
|
@@ -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 = "1.
|
|
7
|
+
spec.version = "1.2.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.}
|
|
@@ -9,7 +9,8 @@ module Fluent::Plugin
|
|
|
9
9
|
|
|
10
10
|
config_param :geoip_database, :string, default: File.expand_path('../../../data/GeoLiteCity.dat', __dir__)
|
|
11
11
|
config_param :geoip2_database, :string, default: File.expand_path('../../../data/GeoLite2-City.mmdb', __dir__)
|
|
12
|
-
config_param :
|
|
12
|
+
config_param :geoip_lookup_keys, :array, value_type: :string, default: ["host"]
|
|
13
|
+
config_param :geoip_lookup_key, :string, default: nil, deprecated: "Use geoip_lookup_keys instead"
|
|
13
14
|
config_param :skip_adding_null_record, :bool, default: false
|
|
14
15
|
|
|
15
16
|
config_set_default :@log_level, "warn"
|
data/lib/fluent/plugin/geoip.rb
CHANGED
|
@@ -24,25 +24,15 @@ module Fluent
|
|
|
24
24
|
|
|
25
25
|
def initialize(plugin, conf)
|
|
26
26
|
@map = {}
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
@geoip_lookup_keys = plugin.geoip_lookup_keys
|
|
28
|
+
if plugin.geoip_lookup_key
|
|
29
|
+
@geoip_lookup_keys = plugin.geoip_lookup_key.split(/\s*,\s*/)
|
|
30
|
+
end
|
|
29
31
|
@skip_adding_null_record = plugin.skip_adding_null_record
|
|
30
32
|
@log = plugin.log
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
geoip_key = key.sub('enable_key_','')
|
|
35
|
-
raise Fluent::ConfigError, "geoip: unsupported key #{geoip_key}" unless GEOIP_KEYS.include?(geoip_key)
|
|
36
|
-
@geoip_lookup_key.zip(conf[key].split(/\s*,\s*/)).each do |lookup_field,record_key|
|
|
37
|
-
if record_key.nil?
|
|
38
|
-
raise Fluent::ConfigError, "geoip: missing value found at '#{key} #{lookup_field}'"
|
|
39
|
-
end
|
|
40
|
-
@map[record_key] = "${#{geoip_key}['#{lookup_field}']}"
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
if conf.keys.select{|k| k =~ /^enable_key_/}.size > 0
|
|
44
|
-
log.warn "geoip: 'enable_key_*' config format is obsoleted. use <record></record> directive for now."
|
|
45
|
-
log.warn "geoip: for further details referable to https://github.com/y-ken/fluent-plugin-geoip"
|
|
34
|
+
if conf.keys.any? {|k| k =~ /^enable_key_/ }
|
|
35
|
+
raise Fluent::ConfigError, "geoip: 'enable_key_*' config format is obsoleted. use <record></record> directive instead."
|
|
46
36
|
end
|
|
47
37
|
|
|
48
38
|
# <record></record> directive
|
|
@@ -124,7 +114,7 @@ module Fluent
|
|
|
124
114
|
|
|
125
115
|
def get_address(record)
|
|
126
116
|
address = {}
|
|
127
|
-
@
|
|
117
|
+
@geoip_lookup_keys.each do |field|
|
|
128
118
|
address[field] = record[field] || record.dig(*field.split('.'))
|
|
129
119
|
end
|
|
130
120
|
address
|
|
@@ -8,7 +8,8 @@ class Fluent::Plugin::GeoipOutput < Fluent::Plugin::Output
|
|
|
8
8
|
|
|
9
9
|
config_param :geoip_database, :string, default: File.expand_path('../../../data/GeoLiteCity.dat', __dir__)
|
|
10
10
|
config_param :geoip2_database, :string, default: File.expand_path('../../../data/GeoLite2-City.mmdb', __dir__)
|
|
11
|
-
config_param :
|
|
11
|
+
config_param :geoip_lookup_keys, :array, value_type: :string, default: ["host"]
|
|
12
|
+
config_param :geoip_lookup_key, :string, default: nil, deprecated: "Use geoip_lookup_keys instead"
|
|
12
13
|
config_param :tag, :string, default: nil
|
|
13
14
|
config_param :skip_adding_null_record, :bool, default: false
|
|
14
15
|
|
|
@@ -9,8 +9,10 @@ class GeoipFilterTest < Test::Unit::TestCase
|
|
|
9
9
|
end
|
|
10
10
|
|
|
11
11
|
CONFIG = %[
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
geoip_lookup_keys host
|
|
13
|
+
<record>
|
|
14
|
+
geoip_city ${city.names.en['host']}
|
|
15
|
+
</record>
|
|
14
16
|
]
|
|
15
17
|
|
|
16
18
|
def create_driver(conf = CONFIG, syntax: :v1)
|
|
@@ -44,42 +46,29 @@ class GeoipFilterTest < Test::Unit::TestCase
|
|
|
44
46
|
}
|
|
45
47
|
end
|
|
46
48
|
|
|
47
|
-
test "
|
|
49
|
+
test "obsoleted configuration" do
|
|
48
50
|
assert_raise(Fluent::ConfigError) {
|
|
49
|
-
create_driver('
|
|
51
|
+
create_driver('enable_key_city geoip_city')
|
|
50
52
|
}
|
|
51
53
|
end
|
|
52
54
|
|
|
53
|
-
test "
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
test "multiple key config" do
|
|
61
|
-
d = create_driver %[
|
|
62
|
-
geoip_lookup_key from.ip, to.ip
|
|
63
|
-
enable_key_city from_city, to_city
|
|
55
|
+
test "deprecated configuration geoip_lookup_key" do
|
|
56
|
+
conf = %[
|
|
57
|
+
geoip_lookup_key host,ip
|
|
58
|
+
<record>
|
|
59
|
+
geoip_city ${city['host']}
|
|
60
|
+
</record>
|
|
61
|
+
tag geoip.${tag[1]}
|
|
64
62
|
]
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
test "multiple key config (bad configure)" do
|
|
69
|
-
assert_raise(Fluent::ConfigError) {
|
|
70
|
-
create_driver %[
|
|
71
|
-
geoip_lookup_key from.ip, to.ip
|
|
72
|
-
enable_key_city from_city
|
|
73
|
-
enable_key_region from_region
|
|
74
|
-
]
|
|
75
|
-
}
|
|
63
|
+
d = create_driver(conf)
|
|
64
|
+
assert_equal(["host", "ip"],
|
|
65
|
+
d.instance.instance_variable_get(:@geoip).instance_variable_get(:@geoip_lookup_keys))
|
|
76
66
|
end
|
|
77
67
|
|
|
78
68
|
test "invalid json structure w/ Ruby hash like" do
|
|
79
|
-
|
|
80
69
|
assert_raise(Fluent::ConfigParseError) {
|
|
81
70
|
create_driver %[
|
|
82
|
-
|
|
71
|
+
geoip_lookup_keys host
|
|
83
72
|
<record>
|
|
84
73
|
invalid_json {"foo" => 123}
|
|
85
74
|
</record>
|
|
@@ -90,7 +79,7 @@ class GeoipFilterTest < Test::Unit::TestCase
|
|
|
90
79
|
test "invalid json structure w/ unquoted string literal" do
|
|
91
80
|
assert_raise(Fluent::ConfigParseError) {
|
|
92
81
|
create_driver %[
|
|
93
|
-
|
|
82
|
+
geoip_lookup_keys host
|
|
94
83
|
<record>
|
|
95
84
|
invalid_json {"foo" : string, "bar" : 123}
|
|
96
85
|
</record>
|
|
@@ -139,7 +128,7 @@ class GeoipFilterTest < Test::Unit::TestCase
|
|
|
139
128
|
def test_filter_with_dot_key
|
|
140
129
|
config = %[
|
|
141
130
|
backend_library geoip2_c
|
|
142
|
-
|
|
131
|
+
geoip_lookup_keys ip.origin, ip.dest
|
|
143
132
|
<record>
|
|
144
133
|
origin_country ${country.iso_code['ip.origin']}
|
|
145
134
|
dest_country ${country.iso_code['ip.dest']}
|
|
@@ -159,7 +148,7 @@ class GeoipFilterTest < Test::Unit::TestCase
|
|
|
159
148
|
def test_filter_with_unknown_address
|
|
160
149
|
config = %[
|
|
161
150
|
backend_library geoip2_c
|
|
162
|
-
|
|
151
|
+
geoip_lookup_keys host
|
|
163
152
|
<record>
|
|
164
153
|
geoip_city ${city.names.en['host']}
|
|
165
154
|
geopoint [${location.longitude['host']}, ${location.latitude['host']}]
|
|
@@ -182,7 +171,7 @@ class GeoipFilterTest < Test::Unit::TestCase
|
|
|
182
171
|
def test_filter_with_skip_unknown_address
|
|
183
172
|
config = %[
|
|
184
173
|
backend_library geoip2_c
|
|
185
|
-
|
|
174
|
+
geoip_lookup_keys host
|
|
186
175
|
<record>
|
|
187
176
|
geoip_city ${city.names.en['host']}
|
|
188
177
|
geopoint [${location.longitude['host']}, ${location.latitude['host']}]
|
|
@@ -208,7 +197,7 @@ class GeoipFilterTest < Test::Unit::TestCase
|
|
|
208
197
|
def test_filter_record_directive
|
|
209
198
|
config = %[
|
|
210
199
|
backend_library geoip2_c
|
|
211
|
-
|
|
200
|
+
geoip_lookup_keys from.ip
|
|
212
201
|
<record>
|
|
213
202
|
from_city ${city.names.en['from.ip']}
|
|
214
203
|
from_country ${country.names.en['from.ip']}
|
|
@@ -275,7 +264,7 @@ class GeoipFilterTest < Test::Unit::TestCase
|
|
|
275
264
|
def test_filter_record_directive_multiple_record
|
|
276
265
|
config = %[
|
|
277
266
|
backend_library geoip2_c
|
|
278
|
-
|
|
267
|
+
geoip_lookup_keys from.ip, to.ip
|
|
279
268
|
<record>
|
|
280
269
|
from_city ${city.names.en['from.ip']}
|
|
281
270
|
to_city ${city.names.en['to.ip']}
|
|
@@ -314,7 +303,7 @@ class GeoipFilterTest < Test::Unit::TestCase
|
|
|
314
303
|
def config_quoted_record
|
|
315
304
|
%[
|
|
316
305
|
backend_library geoip2_c
|
|
317
|
-
|
|
306
|
+
geoip_lookup_keys host
|
|
318
307
|
<record>
|
|
319
308
|
location_properties '{ "country_code" : "${country.iso_code["host"]}", "lat": ${location.latitude["host"]}, "lon": ${location.longitude["host"]} }'
|
|
320
309
|
location_string ${location.latitude['host']},${location.longitude['host']}
|
|
@@ -375,7 +364,7 @@ class GeoipFilterTest < Test::Unit::TestCase
|
|
|
375
364
|
def test_filter_multiline_v1_config
|
|
376
365
|
config = %[
|
|
377
366
|
backend_library geoip2_c
|
|
378
|
-
|
|
367
|
+
geoip_lookup_keys host
|
|
379
368
|
<record>
|
|
380
369
|
location_properties {
|
|
381
370
|
"city": "${city.names.en['host']}",
|
|
@@ -406,7 +395,7 @@ class GeoipFilterTest < Test::Unit::TestCase
|
|
|
406
395
|
def test_filter_when_latitude_longitude_is_nil
|
|
407
396
|
config = %[
|
|
408
397
|
backend_library geoip2_c
|
|
409
|
-
|
|
398
|
+
geoip_lookup_keys host
|
|
410
399
|
<record>
|
|
411
400
|
latitude ${location.latitude['host']}
|
|
412
401
|
longitude ${location.longitude['host']}
|
|
@@ -434,7 +423,7 @@ class GeoipFilterTest < Test::Unit::TestCase
|
|
|
434
423
|
def test_filter_with_dot_key
|
|
435
424
|
config = %[
|
|
436
425
|
backend_library geoip2_compat
|
|
437
|
-
|
|
426
|
+
geoip_lookup_keys ip.origin, ip.dest
|
|
438
427
|
<record>
|
|
439
428
|
origin_country ${country_code['ip.origin']}
|
|
440
429
|
dest_country ${country_code['ip.dest']}
|
|
@@ -454,7 +443,7 @@ class GeoipFilterTest < Test::Unit::TestCase
|
|
|
454
443
|
def test_filter_with_unknown_address
|
|
455
444
|
config = %[
|
|
456
445
|
backend_library geoip2_compat
|
|
457
|
-
|
|
446
|
+
geoip_lookup_keys host
|
|
458
447
|
<record>
|
|
459
448
|
geoip_city ${city['host']}
|
|
460
449
|
geopoint [${longitude['host']}, ${latitude['host']}]
|
|
@@ -477,7 +466,7 @@ class GeoipFilterTest < Test::Unit::TestCase
|
|
|
477
466
|
def test_filter_with_skip_unknown_address
|
|
478
467
|
config = %[
|
|
479
468
|
backend_library geoip2_compat
|
|
480
|
-
|
|
469
|
+
geoip_lookup_keys host
|
|
481
470
|
<record>
|
|
482
471
|
geoip_city ${city['host']}
|
|
483
472
|
geopoint [${longitude['host']}, ${latitude['host']}]
|
|
@@ -503,7 +492,7 @@ class GeoipFilterTest < Test::Unit::TestCase
|
|
|
503
492
|
def test_filter_record_directive
|
|
504
493
|
config = %[
|
|
505
494
|
backend_library geoip2_compat
|
|
506
|
-
|
|
495
|
+
geoip_lookup_keys from.ip
|
|
507
496
|
<record>
|
|
508
497
|
from_city ${city['from.ip']}
|
|
509
498
|
from_country ${country_name['from.ip']}
|
|
@@ -570,7 +559,7 @@ class GeoipFilterTest < Test::Unit::TestCase
|
|
|
570
559
|
def test_filter_record_directive_multiple_record
|
|
571
560
|
config = %[
|
|
572
561
|
backend_library geoip2_compat
|
|
573
|
-
|
|
562
|
+
geoip_lookup_keys from.ip, to.ip
|
|
574
563
|
<record>
|
|
575
564
|
from_city ${city['from.ip']}
|
|
576
565
|
to_city ${city['to.ip']}
|
|
@@ -609,7 +598,7 @@ class GeoipFilterTest < Test::Unit::TestCase
|
|
|
609
598
|
def config_quoted_record
|
|
610
599
|
%[
|
|
611
600
|
backend_library geoip2_compat
|
|
612
|
-
|
|
601
|
+
geoip_lookup_keys host
|
|
613
602
|
<record>
|
|
614
603
|
location_properties '{ "country_code" : "${country_code["host"]}", "lat": ${latitude["host"]}, "lon": ${longitude["host"]} }'
|
|
615
604
|
location_string ${latitude['host']},${longitude['host']}
|
|
@@ -670,7 +659,7 @@ class GeoipFilterTest < Test::Unit::TestCase
|
|
|
670
659
|
def test_filter_multiline_v1_config
|
|
671
660
|
config = %[
|
|
672
661
|
backend_library geoip2_compat
|
|
673
|
-
|
|
662
|
+
geoip_lookup_keys host
|
|
674
663
|
<record>
|
|
675
664
|
location_properties {
|
|
676
665
|
"city": "${city['host']}",
|
|
@@ -701,7 +690,7 @@ class GeoipFilterTest < Test::Unit::TestCase
|
|
|
701
690
|
def test_filter_when_latitude_longitude_is_nil
|
|
702
691
|
config = %[
|
|
703
692
|
backend_library geoip2_compat
|
|
704
|
-
|
|
693
|
+
geoip_lookup_keys host
|
|
705
694
|
<record>
|
|
706
695
|
latitude ${latitude['host']}
|
|
707
696
|
longitude ${longitude['host']}
|
|
@@ -729,8 +718,10 @@ class GeoipFilterTest < Test::Unit::TestCase
|
|
|
729
718
|
def test_filter
|
|
730
719
|
config = %[
|
|
731
720
|
backend_library geoip
|
|
732
|
-
|
|
733
|
-
|
|
721
|
+
geoip_lookup_keys host
|
|
722
|
+
<record>
|
|
723
|
+
geoip_city ${city['host']}
|
|
724
|
+
</record>
|
|
734
725
|
]
|
|
735
726
|
messages = [
|
|
736
727
|
{'host' => '66.102.3.80', 'message' => 'valid ip'},
|
|
@@ -747,7 +738,7 @@ class GeoipFilterTest < Test::Unit::TestCase
|
|
|
747
738
|
def test_filter_with_dot_key
|
|
748
739
|
config = %[
|
|
749
740
|
backend_library geoip
|
|
750
|
-
|
|
741
|
+
geoip_lookup_keys ip.origin, ip.dest
|
|
751
742
|
<record>
|
|
752
743
|
origin_country ${country_code['ip.origin']}
|
|
753
744
|
dest_country ${country_code['ip.dest']}
|
|
@@ -767,8 +758,10 @@ class GeoipFilterTest < Test::Unit::TestCase
|
|
|
767
758
|
def test_filter_nested_attr
|
|
768
759
|
config = %[
|
|
769
760
|
backend_library geoip
|
|
770
|
-
|
|
771
|
-
|
|
761
|
+
geoip_lookup_keys host.ip
|
|
762
|
+
<record>
|
|
763
|
+
geoip_city ${city['host.ip']}
|
|
764
|
+
</record>
|
|
772
765
|
]
|
|
773
766
|
messages = [
|
|
774
767
|
{'host' => {'ip' => '66.102.3.80'}, 'message' => 'valid ip'},
|
|
@@ -785,7 +778,7 @@ class GeoipFilterTest < Test::Unit::TestCase
|
|
|
785
778
|
def test_filter_with_unknown_address
|
|
786
779
|
config = %[
|
|
787
780
|
backend_library geoip
|
|
788
|
-
|
|
781
|
+
geoip_lookup_keys host
|
|
789
782
|
<record>
|
|
790
783
|
geoip_city ${city['host']}
|
|
791
784
|
geopoint [${longitude['host']}, ${latitude['host']}]
|
|
@@ -808,7 +801,7 @@ class GeoipFilterTest < Test::Unit::TestCase
|
|
|
808
801
|
def test_filter_with_skip_unknown_address
|
|
809
802
|
config = %[
|
|
810
803
|
backend_library geoip
|
|
811
|
-
|
|
804
|
+
geoip_lookup_keys host
|
|
812
805
|
<record>
|
|
813
806
|
geoip_city ${city['host']}
|
|
814
807
|
geopoint [${longitude['host']}, ${latitude['host']}]
|
|
@@ -834,8 +827,11 @@ class GeoipFilterTest < Test::Unit::TestCase
|
|
|
834
827
|
def test_filter_multiple_key
|
|
835
828
|
config = %[
|
|
836
829
|
backend_library geoip
|
|
837
|
-
|
|
838
|
-
|
|
830
|
+
geoip_lookup_keys from.ip, to.ip
|
|
831
|
+
<record>
|
|
832
|
+
from_city ${city['from.ip']}
|
|
833
|
+
to_city ${city['to.ip']}
|
|
834
|
+
</record>
|
|
839
835
|
]
|
|
840
836
|
messages = [
|
|
841
837
|
{'from' => {'ip' => '66.102.3.80'}, 'to' => {'ip' => '125.54.15.42'}},
|
|
@@ -853,9 +849,13 @@ class GeoipFilterTest < Test::Unit::TestCase
|
|
|
853
849
|
def test_filter_multiple_key_multiple_record
|
|
854
850
|
config = %[
|
|
855
851
|
backend_library geoip
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
852
|
+
geoip_lookup_keys from.ip, to.ip
|
|
853
|
+
<record>
|
|
854
|
+
from_city ${city['from.ip']}
|
|
855
|
+
from_country ${country_name['from.ip']}
|
|
856
|
+
to_city ${city['to.ip']}
|
|
857
|
+
to_country ${country_name['to.ip']}
|
|
858
|
+
</record>
|
|
859
859
|
]
|
|
860
860
|
messages = [
|
|
861
861
|
{'from' => {'ip' => '66.102.3.80'}, 'to' => {'ip' => '125.54.15.42'}},
|
|
@@ -893,7 +893,7 @@ class GeoipFilterTest < Test::Unit::TestCase
|
|
|
893
893
|
def test_filter_record_directive
|
|
894
894
|
config = %[
|
|
895
895
|
backend_library geoip
|
|
896
|
-
|
|
896
|
+
geoip_lookup_keys from.ip
|
|
897
897
|
<record>
|
|
898
898
|
from_city ${city['from.ip']}
|
|
899
899
|
from_country ${country_name['from.ip']}
|
|
@@ -960,7 +960,7 @@ class GeoipFilterTest < Test::Unit::TestCase
|
|
|
960
960
|
def test_filter_record_directive_multiple_record
|
|
961
961
|
config = %[
|
|
962
962
|
backend_library geoip
|
|
963
|
-
|
|
963
|
+
geoip_lookup_keys from.ip, to.ip
|
|
964
964
|
<record>
|
|
965
965
|
from_city ${city['from.ip']}
|
|
966
966
|
to_city ${city['to.ip']}
|
|
@@ -999,7 +999,7 @@ class GeoipFilterTest < Test::Unit::TestCase
|
|
|
999
999
|
def config_quoted_record
|
|
1000
1000
|
%[
|
|
1001
1001
|
backend_library geoip
|
|
1002
|
-
|
|
1002
|
+
geoip_lookup_keys host
|
|
1003
1003
|
<record>
|
|
1004
1004
|
location_properties '{ "country_code" : "${country_code["host"]}", "lat": ${latitude["host"]}, "lon": ${longitude["host"]} }'
|
|
1005
1005
|
location_string ${latitude['host']},${longitude['host']}
|
|
@@ -1060,7 +1060,7 @@ class GeoipFilterTest < Test::Unit::TestCase
|
|
|
1060
1060
|
def test_filter_multiline_v1_config
|
|
1061
1061
|
config = %[
|
|
1062
1062
|
backend_library geoip
|
|
1063
|
-
|
|
1063
|
+
geoip_lookup_keys host
|
|
1064
1064
|
<record>
|
|
1065
1065
|
location_properties {
|
|
1066
1066
|
"city": "${city['host']}",
|
|
@@ -1091,7 +1091,7 @@ class GeoipFilterTest < Test::Unit::TestCase
|
|
|
1091
1091
|
def test_filter_when_latitude_longitude_is_nil
|
|
1092
1092
|
config = %[
|
|
1093
1093
|
backend_library geoip
|
|
1094
|
-
|
|
1094
|
+
geoip_lookup_keys host
|
|
1095
1095
|
<record>
|
|
1096
1096
|
latitude ${latitude['host']}
|
|
1097
1097
|
longitude ${longitude['host']}
|
|
@@ -8,8 +8,10 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
CONFIG = %[
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
geoip_lookup_keys host
|
|
12
|
+
<record>
|
|
13
|
+
geoip_city ${city['host']}
|
|
14
|
+
</record>
|
|
13
15
|
tag geoip.${tag[1]}
|
|
14
16
|
]
|
|
15
17
|
|
|
@@ -24,50 +26,29 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
24
26
|
end
|
|
25
27
|
end
|
|
26
28
|
|
|
27
|
-
test "
|
|
29
|
+
test "obsoleted configuration" do
|
|
28
30
|
assert_raise(Fluent::ConfigError) {
|
|
29
|
-
create_driver('
|
|
31
|
+
create_driver('enable_key_city geoip_city')
|
|
30
32
|
}
|
|
31
33
|
end
|
|
32
34
|
|
|
33
|
-
test "
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
test "invalid key name" do
|
|
42
|
-
assert_raise(Fluent::ConfigError.new("geoip: unsupported key cities")) do
|
|
43
|
-
create_driver('enable_key_cities')
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
test "multiple key config" do
|
|
48
|
-
d = create_driver %[
|
|
49
|
-
geoip_lookup_key from.ip, to.ip
|
|
50
|
-
enable_key_city from_city, to_city
|
|
35
|
+
test "deprecated configuration geoip_lookup_key" do
|
|
36
|
+
conf = %[
|
|
37
|
+
geoip_lookup_key host,ip
|
|
38
|
+
<record>
|
|
39
|
+
geoip_city ${city['host']}
|
|
40
|
+
</record>
|
|
51
41
|
tag geoip.${tag[1]}
|
|
52
42
|
]
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
test "multiple key config (bad configure)" do
|
|
57
|
-
assert_raise(Fluent::ConfigError) do
|
|
58
|
-
create_driver %[
|
|
59
|
-
geoip_lookup_key from.ip, to.ip
|
|
60
|
-
enable_key_city from_city
|
|
61
|
-
enable_key_region from_region
|
|
62
|
-
tag geoip.${tag[1]}
|
|
63
|
-
]
|
|
64
|
-
end
|
|
43
|
+
d = create_driver(conf)
|
|
44
|
+
assert_equal(["host", "ip"],
|
|
45
|
+
d.instance.instance_variable_get(:@geoip).instance_variable_get(:@geoip_lookup_keys))
|
|
65
46
|
end
|
|
66
47
|
|
|
67
48
|
test "invalid json structure w/ Ruby hash like" do
|
|
68
49
|
assert_raise(Fluent::ConfigParseError) do
|
|
69
50
|
create_driver %[
|
|
70
|
-
|
|
51
|
+
geoip_lookup_keys host
|
|
71
52
|
<record>
|
|
72
53
|
invalid_json {"foo" => 123}
|
|
73
54
|
</record>
|
|
@@ -79,7 +60,7 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
79
60
|
test "invalid json structure w/ unquoted string literal" do
|
|
80
61
|
assert_raise(Fluent::ConfigParseError) do
|
|
81
62
|
create_driver %[
|
|
82
|
-
|
|
63
|
+
geoip_lookup_keys host
|
|
83
64
|
<record>
|
|
84
65
|
invalid_json {"foo" : string, "bar" : 123}
|
|
85
66
|
</record>
|
|
@@ -132,7 +113,7 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
132
113
|
def test_emit_tag_option
|
|
133
114
|
d1 = create_driver(%[
|
|
134
115
|
backend_library geoip2_c
|
|
135
|
-
|
|
116
|
+
geoip_lookup_keys host
|
|
136
117
|
<record>
|
|
137
118
|
geoip_city ${city.names.en['host']}
|
|
138
119
|
</record>
|
|
@@ -152,7 +133,7 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
152
133
|
def test_emit_tag_parts
|
|
153
134
|
d1 = create_driver(%[
|
|
154
135
|
backend_library geoip2_c
|
|
155
|
-
|
|
136
|
+
geoip_lookup_keys host
|
|
156
137
|
<record>
|
|
157
138
|
geoip_city ${city.names.en['host']}
|
|
158
139
|
</record>
|
|
@@ -170,7 +151,7 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
170
151
|
def test_emit_with_dot_key
|
|
171
152
|
d1 = create_driver(%[
|
|
172
153
|
backend_library geoip2_c
|
|
173
|
-
|
|
154
|
+
geoip_lookup_keys ip.origin, ip.dest
|
|
174
155
|
<record>
|
|
175
156
|
origin_country ${country.iso_code['ip.origin']}
|
|
176
157
|
dest_country ${country.iso_code['ip.dest']}
|
|
@@ -190,7 +171,7 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
190
171
|
def test_emit_with_unknown_address
|
|
191
172
|
d1 = create_driver(%[
|
|
192
173
|
backend_library geoip2_c
|
|
193
|
-
|
|
174
|
+
geoip_lookup_keys host
|
|
194
175
|
<record>
|
|
195
176
|
geoip_city ${city.names.en['host']}
|
|
196
177
|
geopoint [${location.longitude['host']}, ${location.latitude['host']}]
|
|
@@ -214,7 +195,7 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
214
195
|
def test_emit_with_skip_unknown_address
|
|
215
196
|
d1 = create_driver(%[
|
|
216
197
|
backend_library geoip2_c
|
|
217
|
-
|
|
198
|
+
geoip_lookup_keys host
|
|
218
199
|
<record>
|
|
219
200
|
geoip_city ${city.names.en['host']}
|
|
220
201
|
geopoint [${location.longitude['host']}, ${location.latitude['host']}]
|
|
@@ -243,7 +224,7 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
243
224
|
def test_emit_record_directive
|
|
244
225
|
d1 = create_driver(%[
|
|
245
226
|
backend_library geoip2_c
|
|
246
|
-
|
|
227
|
+
geoip_lookup_keys from.ip
|
|
247
228
|
<record>
|
|
248
229
|
from_city ${city.names.en['from.ip']}
|
|
249
230
|
from_country ${country.names.en['from.ip']}
|
|
@@ -308,7 +289,7 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
308
289
|
def test_emit_record_directive_multiple_record
|
|
309
290
|
d1 = create_driver(%[
|
|
310
291
|
backend_library geoip2_c
|
|
311
|
-
|
|
292
|
+
geoip_lookup_keys from.ip, to.ip
|
|
312
293
|
<record>
|
|
313
294
|
from_city ${city.names.en['from.ip']}
|
|
314
295
|
to_city ${city.names.en['to.ip']}
|
|
@@ -342,7 +323,7 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
342
323
|
def config_quoted_record
|
|
343
324
|
%[
|
|
344
325
|
backend_library geoip2_c
|
|
345
|
-
|
|
326
|
+
geoip_lookup_keys host
|
|
346
327
|
<record>
|
|
347
328
|
location_properties '{ "country_code" : "${country.iso_code["host"]}", "lat": ${location.latitude["host"]}, "lon": ${location.longitude["host"]} }'
|
|
348
329
|
location_string ${location.latitude['host']},${location.longitude['host']}
|
|
@@ -392,7 +373,7 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
392
373
|
def test_emit_multiline_v1_config
|
|
393
374
|
d1 = create_driver(%[
|
|
394
375
|
backend_library geoip2_c
|
|
395
|
-
|
|
376
|
+
geoip_lookup_keys host
|
|
396
377
|
<record>
|
|
397
378
|
location_properties {
|
|
398
379
|
"city": "${city.names.en['host']}",
|
|
@@ -418,7 +399,7 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
418
399
|
def test_emit_tag_option
|
|
419
400
|
d1 = create_driver(%[
|
|
420
401
|
backend_library geoip2_compat
|
|
421
|
-
|
|
402
|
+
geoip_lookup_keys host
|
|
422
403
|
<record>
|
|
423
404
|
geoip_city ${city['host']}
|
|
424
405
|
</record>
|
|
@@ -438,7 +419,7 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
438
419
|
def test_emit_tag_parts
|
|
439
420
|
d1 = create_driver(%[
|
|
440
421
|
backend_library geoip2_compat
|
|
441
|
-
|
|
422
|
+
geoip_lookup_keys host
|
|
442
423
|
<record>
|
|
443
424
|
geoip_city ${city['host']}
|
|
444
425
|
</record>
|
|
@@ -456,7 +437,7 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
456
437
|
def test_emit_with_dot_key
|
|
457
438
|
d1 = create_driver(%[
|
|
458
439
|
backend_library geoip2_compat
|
|
459
|
-
|
|
440
|
+
geoip_lookup_keys ip.origin, ip.dest
|
|
460
441
|
<record>
|
|
461
442
|
origin_country ${country_code['ip.origin']}
|
|
462
443
|
dest_country ${country_code['ip.dest']}
|
|
@@ -476,7 +457,7 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
476
457
|
def test_emit_with_unknown_address
|
|
477
458
|
d1 = create_driver(%[
|
|
478
459
|
backend_library geoip2_compat
|
|
479
|
-
|
|
460
|
+
geoip_lookup_keys host
|
|
480
461
|
<record>
|
|
481
462
|
geoip_city ${city['host']}
|
|
482
463
|
geopoint [${longitude['host']}, ${latitude['host']}]
|
|
@@ -500,7 +481,7 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
500
481
|
def test_emit_with_skip_unknown_address
|
|
501
482
|
d1 = create_driver(%[
|
|
502
483
|
backend_library geoip2_compat
|
|
503
|
-
|
|
484
|
+
geoip_lookup_keys host
|
|
504
485
|
<record>
|
|
505
486
|
geoip_city ${city['host']}
|
|
506
487
|
geopoint [${longitude['host']}, ${latitude['host']}]
|
|
@@ -529,7 +510,7 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
529
510
|
def test_emit_record_directive
|
|
530
511
|
d1 = create_driver(%[
|
|
531
512
|
backend_library geoip2_compat
|
|
532
|
-
|
|
513
|
+
geoip_lookup_keys from.ip
|
|
533
514
|
<record>
|
|
534
515
|
from_city ${city['from.ip']}
|
|
535
516
|
from_country ${country_name['from.ip']}
|
|
@@ -594,7 +575,7 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
594
575
|
def test_emit_record_directive_multiple_record
|
|
595
576
|
d1 = create_driver(%[
|
|
596
577
|
backend_library geoip2_compat
|
|
597
|
-
|
|
578
|
+
geoip_lookup_keys from.ip, to.ip
|
|
598
579
|
<record>
|
|
599
580
|
from_city ${city['from.ip']}
|
|
600
581
|
to_city ${city['to.ip']}
|
|
@@ -628,7 +609,7 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
628
609
|
def config_quoted_record
|
|
629
610
|
%[
|
|
630
611
|
backend_library geoip2_compat
|
|
631
|
-
|
|
612
|
+
geoip_lookup_keys host
|
|
632
613
|
<record>
|
|
633
614
|
location_properties '{ "country_code" : "${country_code["host"]}", "lat": ${latitude["host"]}, "lon": ${longitude["host"]} }'
|
|
634
615
|
location_string ${latitude['host']},${longitude['host']}
|
|
@@ -678,7 +659,7 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
678
659
|
def test_emit_multiline_v1_config
|
|
679
660
|
d1 = create_driver(%[
|
|
680
661
|
backend_library geoip2_compat
|
|
681
|
-
|
|
662
|
+
geoip_lookup_keys host
|
|
682
663
|
<record>
|
|
683
664
|
location_properties {
|
|
684
665
|
"city": "${city['host']}",
|
|
@@ -701,28 +682,10 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
701
682
|
end
|
|
702
683
|
|
|
703
684
|
sub_test_case "geoip legacy" do
|
|
704
|
-
def test_emit
|
|
705
|
-
d1 = create_driver(%[
|
|
706
|
-
backend_library geoip
|
|
707
|
-
geoip_lookup_key host
|
|
708
|
-
enable_key_city geoip_city
|
|
709
|
-
tag geoip.${tag[1]}
|
|
710
|
-
])
|
|
711
|
-
d1.run(default_tag: 'input.access') do
|
|
712
|
-
d1.feed({'host' => '66.102.3.80', 'message' => 'valid ip'})
|
|
713
|
-
d1.feed({'message' => 'missing field'})
|
|
714
|
-
end
|
|
715
|
-
events = d1.events
|
|
716
|
-
assert_equal 2, events.length
|
|
717
|
-
assert_equal 'geoip.access', events[0][0] # tag
|
|
718
|
-
assert_equal 'Mountain View', events[0][2]['geoip_city']
|
|
719
|
-
assert_equal nil, events[1][2]['geoip_city']
|
|
720
|
-
end
|
|
721
|
-
|
|
722
685
|
def test_emit_tag_option
|
|
723
686
|
d1 = create_driver(%[
|
|
724
687
|
backend_library geoip
|
|
725
|
-
|
|
688
|
+
geoip_lookup_keys host
|
|
726
689
|
<record>
|
|
727
690
|
geoip_city ${city['host']}
|
|
728
691
|
</record>
|
|
@@ -742,7 +705,7 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
742
705
|
def test_emit_tag_parts
|
|
743
706
|
d1 = create_driver(%[
|
|
744
707
|
backend_library geoip
|
|
745
|
-
|
|
708
|
+
geoip_lookup_keys host
|
|
746
709
|
<record>
|
|
747
710
|
geoip_city ${city['host']}
|
|
748
711
|
</record>
|
|
@@ -760,7 +723,7 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
760
723
|
def test_emit_with_dot_key
|
|
761
724
|
d1 = create_driver(%[
|
|
762
725
|
backend_library geoip
|
|
763
|
-
|
|
726
|
+
geoip_lookup_keys ip.origin, ip.dest
|
|
764
727
|
<record>
|
|
765
728
|
origin_country ${country_code['ip.origin']}
|
|
766
729
|
dest_country ${country_code['ip.dest']}
|
|
@@ -780,8 +743,10 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
780
743
|
def test_emit_nested_attr
|
|
781
744
|
d1 = create_driver(%[
|
|
782
745
|
backend_library geoip
|
|
783
|
-
|
|
784
|
-
|
|
746
|
+
geoip_lookup_keys host.ip
|
|
747
|
+
<record>
|
|
748
|
+
geoip_city ${city['host.ip']}
|
|
749
|
+
</record>
|
|
785
750
|
tag geoip.${tag[1]}
|
|
786
751
|
])
|
|
787
752
|
d1.run(default_tag: 'input.access') do
|
|
@@ -798,7 +763,7 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
798
763
|
def test_emit_with_unknown_address
|
|
799
764
|
d1 = create_driver(%[
|
|
800
765
|
backend_library geoip
|
|
801
|
-
|
|
766
|
+
geoip_lookup_keys host
|
|
802
767
|
<record>
|
|
803
768
|
geoip_city ${city['host']}
|
|
804
769
|
geopoint [${longitude['host']}, ${latitude['host']}]
|
|
@@ -822,7 +787,7 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
822
787
|
def test_emit_with_skip_unknown_address
|
|
823
788
|
d1 = create_driver(%[
|
|
824
789
|
backend_library geoip
|
|
825
|
-
|
|
790
|
+
geoip_lookup_keys host
|
|
826
791
|
<record>
|
|
827
792
|
geoip_city ${city['host']}
|
|
828
793
|
geopoint [${longitude['host']}, ${latitude['host']}]
|
|
@@ -851,8 +816,11 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
851
816
|
def test_emit_multiple_key
|
|
852
817
|
d1 = create_driver(%[
|
|
853
818
|
backend_library geoip
|
|
854
|
-
|
|
855
|
-
|
|
819
|
+
geoip_lookup_keys from.ip, to.ip
|
|
820
|
+
<record>
|
|
821
|
+
from_city ${city['from.ip']}
|
|
822
|
+
to_city ${city['to.ip']}
|
|
823
|
+
</record>
|
|
856
824
|
tag geoip.${tag[1]}
|
|
857
825
|
])
|
|
858
826
|
d1.run(default_tag: 'input.access') do
|
|
@@ -871,9 +839,13 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
871
839
|
def test_emit_multiple_key_multiple_record
|
|
872
840
|
d1 = create_driver(%[
|
|
873
841
|
backend_library geoip
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
842
|
+
geoip_lookup_keys from.ip, to.ip
|
|
843
|
+
<record>
|
|
844
|
+
from_city ${city['from.ip']}
|
|
845
|
+
from_country ${country_name['from.ip']}
|
|
846
|
+
to_city ${city['to.ip']}
|
|
847
|
+
to_country ${country_name['to.ip']}
|
|
848
|
+
</record>
|
|
877
849
|
tag geoip.${tag[1]}
|
|
878
850
|
])
|
|
879
851
|
d1.run(default_tag: 'input.access') do
|
|
@@ -903,7 +875,7 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
903
875
|
def test_emit_record_directive
|
|
904
876
|
d1 = create_driver(%[
|
|
905
877
|
backend_library geoip
|
|
906
|
-
|
|
878
|
+
geoip_lookup_keys from.ip
|
|
907
879
|
<record>
|
|
908
880
|
from_city ${city['from.ip']}
|
|
909
881
|
from_country ${country_name['from.ip']}
|
|
@@ -968,7 +940,7 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
968
940
|
def test_emit_record_directive_multiple_record
|
|
969
941
|
d1 = create_driver(%[
|
|
970
942
|
backend_library geoip
|
|
971
|
-
|
|
943
|
+
geoip_lookup_keys from.ip, to.ip
|
|
972
944
|
<record>
|
|
973
945
|
from_city ${city['from.ip']}
|
|
974
946
|
to_city ${city['to.ip']}
|
|
@@ -1002,7 +974,7 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
1002
974
|
def config_quoted_record
|
|
1003
975
|
%[
|
|
1004
976
|
backend_library geoip
|
|
1005
|
-
|
|
977
|
+
geoip_lookup_keys host
|
|
1006
978
|
<record>
|
|
1007
979
|
location_properties '{ "country_code" : "${country_code["host"]}", "lat": ${latitude["host"]}, "lon": ${longitude["host"]} }'
|
|
1008
980
|
location_string ${latitude['host']},${longitude['host']}
|
|
@@ -1052,7 +1024,7 @@ class GeoipOutputTest < Test::Unit::TestCase
|
|
|
1052
1024
|
def test_emit_multiline_v1_config
|
|
1053
1025
|
d1 = create_driver(%[
|
|
1054
1026
|
backend_library geoip
|
|
1055
|
-
|
|
1027
|
+
geoip_lookup_keys host
|
|
1056
1028
|
<record>
|
|
1057
1029
|
location_properties {
|
|
1058
1030
|
"city": "${city['host']}",
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fluent-plugin-geoip
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kentaro Yoshida
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2018-02-01 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -149,6 +149,7 @@ executables: []
|
|
|
149
149
|
extensions: []
|
|
150
150
|
extra_rdoc_files: []
|
|
151
151
|
files:
|
|
152
|
+
- ".github/ISSUE_TEMPLATE.md"
|
|
152
153
|
- ".gitignore"
|
|
153
154
|
- ".travis.yml"
|
|
154
155
|
- Appraisals
|
|
@@ -166,6 +167,7 @@ files:
|
|
|
166
167
|
- dockerfiles/Dockerfile-ruby2.2
|
|
167
168
|
- dockerfiles/Dockerfile-ruby2.3
|
|
168
169
|
- dockerfiles/Dockerfile-ruby2.4
|
|
170
|
+
- dockerfiles/Dockerfile-ruby2.5
|
|
169
171
|
- fluent-plugin-geoip.gemspec
|
|
170
172
|
- gemfiles/fluentd_v1.0_with_backport_dig.gemfile
|
|
171
173
|
- gemfiles/fluentd_v1.0_without_backport_dig.gemfile
|