logstash-filter-ip2location 1.0.2 → 1.0.3

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: e14af9fe1c77455ad3edbc6d0408f663b4f7db50
4
- data.tar.gz: ee905119c82b65ed05f0c7ffdcf471ba41a53207
3
+ metadata.gz: eb5215e6f1580d59313b0525104e612219c879fc
4
+ data.tar.gz: f5a116257db7d3d6e48c7daeb6f445276ee665f4
5
5
  SHA512:
6
- metadata.gz: 8169aea768367e1178a5edceb76501726deff71fd7466ebcb3959e6a721287cbb7f66443d66e390f29db221210cf5d2d693a999e520b29c2fe1f914e80a15e11
7
- data.tar.gz: 5cdc1daf13e891c3d9fff485b0af278cb3ced3817227146836027bef563f2670cf416f6dc9271bdda4624b5ebec6f6e3e301a278f038728db3580d6499d77256
6
+ metadata.gz: a1ec379054e4e326e81a2054f52c7b49d7af830f328641d1a2579605caa10059ae5e6ee3d5eebb2a62b1cc620cb64d37c5aae42462c4ed738ea83e5ed456f7f6
7
+ data.tar.gz: 306966e50bbc68397d5ebfae0b8c422694dad97a3e5fa821717422e2fbd44d4b1fcbcedfb3ec6b41dd44ee7123ef9137292ebd1caaec119a04fa517b1236438e
data/Gemfile CHANGED
@@ -1,11 +1,11 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
4
-
5
- logstash_path = ENV["LOGSTASH_PATH"] || "../../logstash"
6
- use_logstash_source = ENV["LOGSTASH_SOURCE"] && ENV["LOGSTASH_SOURCE"].to_s == "1"
7
-
8
- if Dir.exist?(logstash_path) && use_logstash_source
9
- gem 'logstash-core', :path => "#{logstash_path}/logstash-core"
10
- gem 'logstash-core-plugin-api', :path => "#{logstash_path}/logstash-core-plugin-api"
11
- end
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ logstash_path = ENV["LOGSTASH_PATH"] || "../../logstash"
6
+ use_logstash_source = ENV["LOGSTASH_SOURCE"] && ENV["LOGSTASH_SOURCE"].to_s == "1"
7
+
8
+ if Dir.exist?(logstash_path) && use_logstash_source
9
+ gem 'logstash-core', :path => "#{logstash_path}/logstash-core"
10
+ gem 'logstash-core-plugin-api', :path => "#{logstash_path}/logstash-core-plugin-api"
11
+ end
data/LICENSE CHANGED
@@ -1,13 +1,13 @@
1
- Copyright (c) 2017 IP2Location.com
2
-
3
- Licensed under the Apache License, Version 2.0 (the "License");
4
- you may not use this file except in compliance with the License.
5
- You may obtain a copy of the License at
6
-
7
- http://www.apache.org/licenses/LICENSE-2.0
8
-
9
- Unless required by applicable law or agreed to in writing, software
10
- distributed under the License is distributed on an "AS IS" BASIS,
11
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
- See the License for the specific language governing permissions and
1
+ Copyright (c) 2017 IP2Location.com
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
13
  limitations under the License.
data/README.md CHANGED
@@ -1,89 +1,90 @@
1
- # IP2Location Filter Plugin
2
- This is IP2Location filter plugin for Logstash that enables Logstash's users to add geolocation information such as country, region, city, latitude, longitude, ZIP code, time zone, Internet Service Provider (ISP), domain name, connection speed, IDD code, area code, weather station code, weather station name, mobile country code (MCC), mobile network code (MNC), mobile brand, elevation, and usage type by IP address. The library reads the geo location information from **IP2Location BIN data** file.
3
-
4
- Supported IPv4 and IPv6 address.
5
-
6
- For the methods to use IP2Location filter plugin with ELK (Elasticsearch, Logstash, and Kibana), please take a look on this [tutorial](https://www.ip2location.com/tutorials/how-to-use-ip2location-filter-plugin-with-elk).
7
-
8
-
9
- ## Sample Output
10
- ![Example of data](https://www.ip2location.com/images/tutorial/logstash-filter-ip2location-screenshot2.png)
11
-
12
- |Field|Description|
13
- |---|---|
14
- |ip2location.area_code|the varying length number assigned to geographic areas for call between cities|
15
- |ip2location.city|the city name|
16
- |ip2location.country_long|the country name based on ISO 3166|
17
- |ip2location.country_short|the two-character country code based on ISO 3166|
18
- |ip2location.domain|the Internet domain name associated to IP address range|
19
- |ip2location.elevation|the elevation|
20
- |ip2location.idd_code|the IDD prefix to call the city from another country|
21
- |ip2location.ip_address|the IP address|
22
- |ip2location.isp|the Internet Service Provider (ISP) name|
23
- |ip2location.latitude|the city latitude|
24
- |ip2location.longitude|the city longitude|
25
- |ip2location.mcc|the mobile country code|
26
- |ip2location.mnc|mobile network code|
27
- |ip2location.mobile_brand|the mobile brand|
28
- |ip2location.net_speed|the Internet Connection Speed (DIAL) DIAL-UP,(DSL) DSL/CABLE or(COMP) COMPANY|
29
- |ip2location.region|the region or state name|
30
- |ip2location.time_zone|the Time zone in UTC (Coordinated Universal Time)|
31
- |ip2location.usage_type|the usage type|
32
- |ip2location.weather_station_code|the special code to identify the nearest weather observation station|
33
- |ip2location.weather_station_name|the name of the nearest weather observation station|
34
- |ip2location.zip_code|the ZIP code|
35
-
36
-
37
- ## Dependencies (IP2LOCATION BIN DATA FILE)
38
- This plugin requires IP2Location BIN data file to function. You may download the BIN data file at
39
- * IP2Location LITE BIN Data (Free): https://lite.ip2location.com
40
- * IP2Location Commercial BIN Data (Commercial): https://www.ip2location.com
41
-
42
-
43
- ## Installation
44
- Install this plugin by the following code:
45
- ```
46
- bin/logstash-plugin install logstash-filter-ip2location
47
- ```
48
-
49
-
50
- ## Config File Example
51
- ```
52
- input {
53
- beats {
54
- port => "5043"
55
- }
56
- }
57
-
58
- filter {
59
- grok {
60
- match => { "message" => "%{COMBINEDAPACHELOG}"}
61
- }
62
- ip2location {
63
- source => "clientip"
64
- }
65
- }
66
-
67
-
68
- output {
69
- elasticsearch {
70
- hosts => [ "localhost:9200" ]
71
- }
72
- }
73
- ```
74
-
75
-
76
- ## IP2Location Filter Configuration
77
- |Setting|Input type|Required|
78
- |---|---|---|
79
- |source|string|Yes|
80
- |database|a valid filesystem path|No|
81
-
82
- * **source** field is a required setting that containing the IP address or hostname to get the ip information.
83
- * **database** field is an optional setting that containing the path to the IP2Location BIN database file.
84
-
85
-
86
- ## Support
87
- Email: support@ip2location.com
88
-
89
- URL: [https://www.ip2location.com](https://www.ip2location.com)
1
+ # IP2Location Filter Plugin
2
+ This is IP2Location filter plugin for Logstash that enables Logstash's users to add geolocation information such as country, region, city, latitude, longitude, ZIP code, time zone, Internet Service Provider (ISP), domain name, connection speed, IDD code, area code, weather station code, weather station name, mobile country code (MCC), mobile network code (MNC), mobile brand, elevation, and usage type by IP address. The library reads the geo location information from **IP2Location BIN data** file.
3
+
4
+ Supported IPv4 and IPv6 address.
5
+
6
+ For the methods to use IP2Location filter plugin with Elastic Stack (Elasticsearch, Filebeat, Logstash, and Kibana), please take a look on this [tutorial](https://www.ip2location.com/tutorials/how-to-use-ip2location-filter-plugin-with-elastic-stack).
7
+
8
+
9
+ ## Dependencies (IP2LOCATION BIN DATA FILE)
10
+ This plugin requires IP2Location BIN data file to function. You may download the BIN data file at
11
+ * IP2Location LITE BIN Data (Free): https://lite.ip2location.com
12
+ * IP2Location Commercial BIN Data (Commercial): https://www.ip2location.com
13
+
14
+
15
+ ## Installation
16
+ Install this plugin by the following code:
17
+ ```
18
+ bin/logstash-plugin install logstash-filter-ip2location
19
+ ```
20
+
21
+
22
+ ## Config File Example
23
+ ```
24
+ input {
25
+ beats {
26
+ port => "5043"
27
+ }
28
+ }
29
+
30
+ filter {
31
+ grok {
32
+ match => { "message" => "%{COMBINEDAPACHELOG}"}
33
+ }
34
+ ip2location {
35
+ source => "clientip"
36
+ }
37
+ }
38
+
39
+
40
+ output {
41
+ elasticsearch {
42
+ hosts => [ "localhost:9200" ]
43
+ }
44
+ }
45
+ ```
46
+
47
+
48
+ ## IP2Location Filter Configuration
49
+ |Setting|Input type|Required|
50
+ |---|---|---|
51
+ |source|string|Yes|
52
+ |database|a valid filesystem path|No|
53
+
54
+ * **source** field is a required setting that containing the IP address or hostname to get the ip information.
55
+ * **database** field is an optional setting that containing the path to the IP2Location BIN database file.
56
+
57
+
58
+ ## Sample Output
59
+ |Field|Description|
60
+ |---|---|
61
+ |ip2location.area_code|the varying length number assigned to geographic areas for call between cities|
62
+ |ip2location.city|the city name|
63
+ |ip2location.country_long|the country name based on ISO 3166|
64
+ |ip2location.country_short|the two-character country code based on ISO 3166|
65
+ |ip2location.domain|the Internet domain name associated to IP address range|
66
+ |ip2location.elevation|the elevation|
67
+ |ip2location.idd_code|the IDD prefix to call the city from another country|
68
+ |ip2location.ip_address|the IP address|
69
+ |ip2location.isp|the Internet Service Provider (ISP) name|
70
+ |ip2location.latitude|the city latitude|
71
+ |ip2location.longitude|the city longitude|
72
+ |ip2location.location|the location of city|
73
+ |ip2location.mcc|the mobile country code|
74
+ |ip2location.mnc|mobile network code|
75
+ |ip2location.mobile_brand|the mobile brand|
76
+ |ip2location.net_speed|the Internet Connection Speed (DIAL) DIAL-UP,(DSL) DSL/CABLE or(COMP) COMPANY|
77
+ |ip2location.region|the region or state name|
78
+ |ip2location.time_zone|the Time zone in UTC (Coordinated Universal Time)|
79
+ |ip2location.usage_type|the usage type|
80
+ |ip2location.weather_station_code|the special code to identify the nearest weather observation station|
81
+ |ip2location.weather_station_name|the name of the nearest weather observation station|
82
+ |ip2location.zip_code|the ZIP code|
83
+
84
+ ![Example of data](https://www.ip2location.com/images/tutorial/logstash-filter-ip2location-screenshot2.png?)
85
+
86
+
87
+ ## Support
88
+ Email: support@ip2location.com
89
+
90
+ URL: [https://www.ip2location.com](https://www.ip2location.com)
@@ -1,3 +1,3 @@
1
- require 'jar_dependencies'
2
- require_jar('com.ip2location.ip2location', 'ip2location', '8.0.3')
3
- require_jar('org.logstash.filters', 'logstash-filter-ip2location', '1.0.2')
1
+ require 'jar_dependencies'
2
+ require_jar('com.ip2location.ip2location', 'ip2location', '8.0.3')
3
+ require_jar('org.logstash.filters', 'logstash-filter-ip2location', '1.0.3')
@@ -1,50 +1,50 @@
1
- # encoding: utf-8
2
- require "logstash/filters/base"
3
- require "logstash/namespace"
4
-
5
- require "logstash-filter-ip2location_jars"
6
-
7
- class LogStash::Filters::IP2Location < LogStash::Filters::Base
8
- config_name "ip2location"
9
-
10
- # The path to the IP2Location.BIN database file which Logstash should use.
11
- # If not specified, this will default to the IP2LOCATION-LITE-DB3.IPV6.BIN database that embedded in the plugin.
12
- config :database, :validate => :path
13
-
14
- # The field containing the IP address.
15
- # If this field is an array, only the first value will be used.
16
- config :source, :validate => :string, :required => true
17
-
18
- # The field used to define iplocation as target.
19
- config :target, :validate => :string, :default => 'ip2location'
20
-
21
- public
22
- def register
23
- if @database.nil?
24
- @database = ::Dir.glob(::File.join(::File.expand_path("../../../vendor/", ::File.dirname(__FILE__)),"IP2LOCATION-LITE-DB3.IPV6.BIN")).first
25
-
26
- if @database.nil? || !File.exists?(@database)
27
- raise "You must specify 'database => ...' in your ip2location filter (I looked for '#{@database}')"
28
- end
29
- end
30
-
31
- @logger.info("Using ip2location database", :path => @database)
32
-
33
- @ip2locationfilter = org.logstash.filters.IP2LocationFilter.new(@source, @target, @database)
34
- end
35
-
36
- public
37
- def filter(event)
38
- return unless filter?(event)
39
- if @ip2locationfilter.handleEvent(event)
40
- filter_matched(event)
41
- else
42
- tag_iplookup_unsuccessful(event)
43
- end
44
- end
45
-
46
- def tag_iplookup_unsuccessful(event)
47
- @logger.debug? && @logger.debug("IP #{event.get(@source)} was not found in the database", :event => event)
48
- end
49
-
50
- end # class LogStash::Filters::IP2Location
1
+ # encoding: utf-8
2
+ require "logstash/filters/base"
3
+ require "logstash/namespace"
4
+
5
+ require "logstash-filter-ip2location_jars"
6
+
7
+ class LogStash::Filters::IP2Location < LogStash::Filters::Base
8
+ config_name "ip2location"
9
+
10
+ # The path to the IP2Location.BIN database file which Logstash should use.
11
+ # If not specified, this will default to the IP2LOCATION-LITE-DB3.IPV6.BIN database that embedded in the plugin.
12
+ config :database, :validate => :path
13
+
14
+ # The field containing the IP address.
15
+ # If this field is an array, only the first value will be used.
16
+ config :source, :validate => :string, :required => true
17
+
18
+ # The field used to define iplocation as target.
19
+ config :target, :validate => :string, :default => 'ip2location'
20
+
21
+ public
22
+ def register
23
+ if @database.nil?
24
+ @database = ::Dir.glob(::File.join(::File.expand_path("../../../vendor/", ::File.dirname(__FILE__)),"IP2LOCATION-LITE-DB3.IPV6.BIN")).first
25
+
26
+ if @database.nil? || !File.exists?(@database)
27
+ raise "You must specify 'database => ...' in your ip2location filter (I looked for '#{@database}')"
28
+ end
29
+ end
30
+
31
+ @logger.info("Using ip2location database", :path => @database)
32
+
33
+ @ip2locationfilter = org.logstash.filters.IP2LocationFilter.new(@source, @target, @database)
34
+ end
35
+
36
+ public
37
+ def filter(event)
38
+ return unless filter?(event)
39
+ if @ip2locationfilter.handleEvent(event)
40
+ filter_matched(event)
41
+ else
42
+ tag_iplookup_unsuccessful(event)
43
+ end
44
+ end
45
+
46
+ def tag_iplookup_unsuccessful(event)
47
+ @logger.debug? && @logger.debug("IP #{event.get(@source)} was not found in the database", :event => event)
48
+ end
49
+
50
+ end # class LogStash::Filters::IP2Location
@@ -1,25 +1,25 @@
1
- Gem::Specification.new do |s|
2
-
3
- s.name = 'logstash-filter-ip2location'
4
- s.version = '1.0.2'
5
- s.licenses = ['Apache License (2.0)']
6
- s.summary = "Logstash filter IP2Location"
7
- s.description = "IP2Location filter plugin for Logstash enables Logstash's users to add geolocation information such as country, state, city, latitude, longitude, ZIP code, time zone, ISP, domain name, connection speed, IDD code, area code, weather station code, weather station name, MNC, MCC, mobile brand, elevation and usage type by IP address."
8
- s.authors = ["IP2Location"]
9
- s.email = 'support@ip2location.com'
10
- s.homepage = "https://www.ip2location.com"
11
- s.require_paths = ["lib", "vendor/jar-dependencies"]
12
-
13
- # Files
14
- s.files = Dir["lib/**/*",'spec/**/*',"vendor/**/*","vendor/jar-dependencies/**/*.jar","*.gemspec","*.md","Gemfile","LICENSE"]
15
-
16
- # Tests
17
- s.test_files = s.files.grep(%r{^(test|spec|features)/})
18
-
19
- # Special flag to let us know this is actually a logstash plugin
20
- s.metadata = { "logstash_plugin" => "true", "logstash_group" => "filter" }
21
-
22
- # Gem dependencies
23
- s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"
24
- s.add_development_dependency "logstash-devutils"
25
- end
1
+ Gem::Specification.new do |s|
2
+
3
+ s.name = 'logstash-filter-ip2location'
4
+ s.version = '1.0.3'
5
+ s.licenses = ['Apache License (2.0)']
6
+ s.summary = "Logstash filter IP2Location"
7
+ s.description = "IP2Location filter plugin for Logstash enables Logstash's users to add geolocation information such as country, state, city, latitude, longitude, ZIP code, time zone, ISP, domain name, connection speed, IDD code, area code, weather station code, weather station name, MNC, MCC, mobile brand, elevation and usage type by IP address."
8
+ s.authors = ["IP2Location"]
9
+ s.email = 'support@ip2location.com'
10
+ s.homepage = "https://www.ip2location.com"
11
+ s.require_paths = ["lib", "vendor/jar-dependencies"]
12
+
13
+ # Files
14
+ s.files = Dir["lib/**/*",'spec/**/*',"vendor/**/*","vendor/jar-dependencies/**/*.jar","*.gemspec","*.md","Gemfile","LICENSE"]
15
+
16
+ # Tests
17
+ s.test_files = s.files.grep(%r{^(test|spec|features)/})
18
+
19
+ # Special flag to let us know this is actually a logstash plugin
20
+ s.metadata = { "logstash_plugin" => "true", "logstash_group" => "filter" }
21
+
22
+ # Gem dependencies
23
+ s.add_runtime_dependency "logstash-core-plugin-api", "~> 2.0"
24
+ s.add_development_dependency "logstash-devutils"
25
+ end
@@ -1,32 +1,32 @@
1
- # encoding: utf-8
2
- require_relative '../spec_helper'
3
- require "logstash/filters/ip2location"
4
-
5
- IP2LOCATIONDB = ::Dir.glob(::File.expand_path("../../vendor/", ::File.dirname(__FILE__))+"/IP2LOCATION-LITE-DB3.IPV6.BIN").first
6
-
7
- describe LogStash::Filters::IP2Location do
8
-
9
- describe "normal test" do
10
- config <<-CONFIG
11
- filter {
12
- ip2location {
13
- source => "ip"
14
- #database => "#{IP2LOCATIONDB}"
15
- }
16
- }
17
- CONFIG
18
-
19
- sample("ip" => "8.8.8.8") do
20
- expect(subject.get("ip2location")).not_to be_empty
21
- expect(subject.get("ip2location")["country_short"]).to eq("US")
22
- end
23
- end
24
-
25
- sample("ip" => "2a01:04f8:0d16:26c2::") do
26
- expect(subject.get("ip2location")).not_to be_empty
27
- expect(subject.get("ip2location")["country_short"]).to eq("DE")
28
- end
29
- end
30
- end
31
-
1
+ # encoding: utf-8
2
+ require_relative '../spec_helper'
3
+ require "logstash/filters/ip2location"
4
+
5
+ IP2LOCATIONDB = ::Dir.glob(::File.expand_path("../../vendor/", ::File.dirname(__FILE__))+"/IP2LOCATION-LITE-DB3.IPV6.BIN").first
6
+
7
+ describe LogStash::Filters::IP2Location do
8
+
9
+ describe "normal test" do
10
+ config <<-CONFIG
11
+ filter {
12
+ ip2location {
13
+ source => "ip"
14
+ #database => "#{IP2LOCATIONDB}"
15
+ }
16
+ }
17
+ CONFIG
18
+
19
+ sample("ip" => "8.8.8.8") do
20
+ expect(subject.get("ip2location")).not_to be_empty
21
+ expect(subject.get("ip2location")["country_short"]).to eq("US")
22
+ end
23
+ end
24
+
25
+ sample("ip" => "2a01:04f8:0d16:26c2::") do
26
+ expect(subject.get("ip2location")).not_to be_empty
27
+ expect(subject.get("ip2location")["country_short"]).to eq("DE")
28
+ end
29
+ end
30
+ end
31
+
32
32
  end
@@ -1,2 +1,2 @@
1
- # encoding: utf-8
2
- require "logstash/devutils/rspec/spec_helper"
1
+ # encoding: utf-8
2
+ require "logstash/devutils/rspec/spec_helper"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-ip2location
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - IP2Location
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-10 00:00:00.000000000 Z
11
+ date: 2018-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: logstash-core-plugin-api
@@ -58,7 +58,7 @@ files:
58
58
  - spec/spec_helper.rb
59
59
  - vendor/IP2LOCATION-LITE-DB3.IPV6.BIN
60
60
  - vendor/jar-dependencies/com/ip2location/ip2location/ip2location/8.0.3/ip2location-8.0.3.jar
61
- - vendor/jar-dependencies/org/logstash/filters/logstash-filter-ip2location/1.0.2/logstash-filter-ip2location-1.0.2.jar
61
+ - vendor/jar-dependencies/org/logstash/filters/logstash-filter-ip2location/1.0.3/logstash-filter-ip2location-1.0.3.jar
62
62
  homepage: https://www.ip2location.com
63
63
  licenses:
64
64
  - Apache License (2.0)