fluent-plugin-geoip 0.8.1 → 0.8.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b35da517cb09039e887c3c2a4fc65878ea5c5de9
4
- data.tar.gz: 69cd94d72b73b04b1f7344815c0b1aa96d98ba30
3
+ metadata.gz: cd066ccaec269f0423567cb6b67fb2f740bd75bf
4
+ data.tar.gz: 59ceed4885348c00333ae21b859311474ed1a01e
5
5
  SHA512:
6
- metadata.gz: b7083fe1c2cde0d12ed5da0954c3749d914ec0a78f26d4570cb8a3e62c7623d76e4711ea33788ddded0190dfc43a9dd7bd8f6c88329fd56022adc153cf651cd4
7
- data.tar.gz: c4834cea64a1fbc55ea8b01cda60b3b7cc38f1a1daaaee66b2333e3c770a02f3cbaa04096e710406b221a890702ddf2b098b5f8f4f8cda238125a771c1781112
6
+ metadata.gz: 7e1c15b06c1916d28656c6607e0d31c716622a0c1436a45d15eeab7d4cea049b9a728a87af7603693305399fa98180a63b43f954298feff9a7cbfa439bccf93d
7
+ data.tar.gz: 1699358cd3e9841ba975d07853a05a5af2ead21c42469fa892f1cce9917f08baabc711905011d6547d8bd10da00616e53b437ff4adb64dd0baddb99f0276c57b
data/README.md CHANGED
@@ -16,7 +16,7 @@ before use, install dependent library as:
16
16
 
17
17
  ```bash
18
18
  # for RHEL/CentOS
19
- $ sudo yum group install "Development Tools"
19
+ $ sudo yum groupinstall "Development Tools"
20
20
  $ sudo yum install geoip-devel --enablerepo=epel
21
21
  $ sudo yum install libmaxminddb-devel --enablerepo=epel
22
22
 
@@ -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 libmaxminddb-dev geoip-dev git
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 libmaxminddb-dev geoip-dev git
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 libmaxminddb-dev geoip-dev git
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 libmaxminddb-dev geoip-dev git
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 . .
@@ -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.1"
7
+ spec.version = "0.8.2"
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,11 +9,11 @@ module Fluent
9
9
  config_param :geoip_lookup_key, :string, :default => 'host'
10
10
  config_param :skip_adding_null_record, :bool, :default => false
11
11
 
12
+ include Fluent::SetTagKeyMixin
12
13
  config_set_default :include_tag_key, false
13
14
 
14
15
  config_param :hostname_command, :string, :default => 'hostname'
15
16
 
16
- config_param :flush_interval, :time, :default => 0
17
17
  config_param :log_level, :string, :default => 'warn'
18
18
 
19
19
  config_param :backend_library, :enum, :list => Fluent::GeoIP::BACKEND_LIBRARIES, :default => :geoip
@@ -27,6 +27,7 @@ module Fluent
27
27
  new_es = MultiEventStream.new
28
28
  es.each do |time, record|
29
29
  begin
30
+ filter_record(tag, time, record)
30
31
  filtered_record = @geoip.add_geoip_field(record)
31
32
  new_es.add(time, filtered_record) if filtered_record
32
33
  rescue => e
@@ -130,6 +130,27 @@ class GeoipFilterTest < Test::Unit::TestCase
130
130
  end
131
131
 
132
132
  sub_test_case "geoip2_c" do
133
+ def test_filter_with_include_tag_key
134
+ config = %[
135
+ backend_library geoip2_c
136
+ geoip_lookup_key ip.origin, ip.dest
137
+ <record>
138
+ origin_country ${country.iso_code['ip.origin']}
139
+ dest_country ${country.iso_code['ip.dest']}
140
+ </record>
141
+ include_tag_key true
142
+ ]
143
+ messages = [
144
+ {'ip.origin' => '66.102.3.80', 'ip.dest' => '8.8.8.8'}
145
+ ]
146
+ expected = [
147
+ {'ip.origin' => '66.102.3.80', 'ip.dest' => '8.8.8.8',
148
+ 'origin_country' => 'US', 'dest_country' => 'US', 'tag' => 'test' }
149
+ ]
150
+ filtered = filter(config, messages)
151
+ assert_equal(expected, filtered)
152
+ end
153
+
133
154
  def test_filter_with_dot_key
134
155
  config = %[
135
156
  backend_library geoip2_c
@@ -717,6 +738,25 @@ class GeoipFilterTest < Test::Unit::TestCase
717
738
  end
718
739
  assert_equal(expected, filtered)
719
740
  end
741
+
742
+ def test_filter_with_include_tag_key
743
+ config = %[
744
+ backend_library geoip2_compat
745
+ geoip_lookup_key host
746
+ enable_key_city geoip_city
747
+ include_tag_key true
748
+ ]
749
+ messages = [
750
+ {'host' => '66.102.3.80', 'message' => 'valid ip'},
751
+ {'message' => 'missing field'},
752
+ ]
753
+ expected = [
754
+ {'host' => '66.102.3.80', 'message' => 'valid ip', 'geoip_city' => 'Mountain View', 'tag' => 'test'},
755
+ {'message' => 'missing field', 'geoip_city' => nil, 'tag' => 'test'},
756
+ ]
757
+ filtered = filter(config, messages)
758
+ assert_equal(expected, filtered)
759
+ end
720
760
  end
721
761
 
722
762
  sub_test_case "geoip legacy" do
@@ -1096,6 +1136,24 @@ class GeoipFilterTest < Test::Unit::TestCase
1096
1136
  end
1097
1137
  assert_equal(expected, filtered)
1098
1138
  end
1139
+
1140
+ def test_filter_with_include_tag_key
1141
+ config = %[
1142
+ geoip_lookup_key host
1143
+ enable_key_city geoip_city
1144
+ include_tag_key true
1145
+ ]
1146
+ messages = [
1147
+ {'host' => '66.102.3.80', 'message' => 'valid ip'},
1148
+ {'message' => 'missing field'},
1149
+ ]
1150
+ expected = [
1151
+ {'host' => '66.102.3.80', 'message' => 'valid ip', 'geoip_city' => 'Mountain View', 'tag' => 'test'},
1152
+ {'message' => 'missing field', 'geoip_city' => nil, 'tag' => 'test'},
1153
+ ]
1154
+ filtered = filter(config, messages)
1155
+ assert_equal(expected, filtered)
1156
+ end
1099
1157
  end
1100
1158
  end
1101
1159
 
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: 0.8.1
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kentaro Yoshida
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-12-26 00:00:00.000000000 Z
11
+ date: 2017-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler