Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

logstash-filter-ip2location

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

logstash-filter-ip2location

  • 2.5.0
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

IP2Location Filter Plugin

This is IP2Location filter plugin for Logstash that enables Logstash's users to add geolocation information such as country, region, district, 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, usage type, address type, IAB category and ASN by IP address. The library reads the geolocation information from IP2Location BIN data file and IP2Location.io data.

Supported IPv4 and IPv6 address.

For the methods to use IP2Location filter plugin with Elastic Stack (Elasticsearch, Filebeat, Logstash, and Kibana), please take a look on this tutorial.

Note: This plugin works in Logstash 7 and Logstash 8.

Dependencies (IP2LOCATION BIN DATA FILE)

This plugin requires IP2Location BIN data file to function. You may download the BIN data file at

Dependencies (IP2LOCATION.IO DATA)

This plugin requires API key to function. You may sign up for a free API key at https://www.ip2location.io/pricing.

Installation

Install this plugin by the following code:

bin/logstash-plugin install logstash-filter-ip2location

Config File Example 1

input {
  beats {
    port => "5043"
  }
}

filter {
  grok {
    match => { "message" => "%{COMBINEDAPACHELOG}"}
  }
  ip2location {
    source => "[source][address]"
  }
}

output {
  elasticsearch {
    hosts => [ "localhost:9200" ]
  }
}

Config File Example 2

input {
  beats {
    port => "5043"
  }
}

filter {
  grok {
    match => { "message" => "%{COMBINEDAPACHELOG}"}
  }
  ip2location {
    source => "[source][address]"
    # Set path to the database located
    database => "IP2LOCATION_BIN_DATABASE_FILESYSTEM_PATH"
    # Enable memory mapped to be used
    use_memory_mapped => true
  }
}

output {
  elasticsearch {
    hosts => [ "localhost:9200" ]
  }
}

Config File Example 3 using IP2Location.io

input {
  beats {
    port => "5043"
  }
}

filter {
  grok {
    match => { "message" => "%{COMBINEDAPACHELOG}"}
  }
  ip2location {
    source => "[source][address]"
    lookup_type => "ws"
    api_key => "YOUR_API_KEY"
  }
}


output {
  elasticsearch {
    hosts => [ "localhost:9200" ]
  }
}

IP2Location Filter Configuration

SettingInput typeRequired
sourcestringYes
databasea valid filesystem pathNo
use_memory_mappedbooleanNo
use_cachebooleanNo
lookup_typestringNo
api_keystringNo
hide_unsupported_fieldsbooleanNo
  • source field is a required setting that containing the IP address or hostname to get the ip information.
  • database field is an optional setting that containing the path to the IP2Location BIN database file.
  • use_memory_mapped field is an optional setting that used to allow user to enable the use of memory mapped file. Default value is false.
  • use_cache field is an optional setting that used to allow user to enable the use of cache. Default value is true.
  • lookup_type field is an optional setting that used to allow user to decide the lookup method either using IP2Location BIN database file(db) or IP2Location.io data(ws). Default value is db.
  • api_key field is an optional setting that used to allow user to set the API Key of the IP2Location.io lookup.
  • hide_unsupported_fields field is an optional setting that used to allow user to hide unsupported fields. Default value is false.

Sample Output

FieldDescription
ip2location.address_typethe IP address type (A-Anycast, B-Broadcast, M-Multicast & U-Unicast) of IP address or domain name
ip2location.area_codethe varying length number assigned to geographic areas for call between cities
ip2location.asAutonomous system (AS) name
ip2location.asnthe Autonomous system number (ASN)
ip2location.categorythe IAB content taxonomy category of IP address or domain name
ip2location.citythe city name
ip2location.country_longthe country name based on ISO 3166
ip2location.country_shortthe two-character country code based on ISO 3166
ip2location.districtthe district or county name
ip2location.domainthe Internet domain name associated to IP address range
ip2location.elevationthe elevation
ip2location.idd_codethe IDD prefix to call the city from another country
ip2location.ip_addressthe IP address
ip2location.ispthe Internet Service Provider (ISP) name
ip2location.latitudethe city latitude
ip2location.locationthe city location
ip2location.longitudethe city longitude
ip2location.mccthe mobile country code
ip2location.mncmobile network code
ip2location.mobile_brandthe mobile brand
ip2location.net_speedthe Internet Connection Speed (DIAL) DIAL-UP,(DSL) DSL/CABLE or(COMP) COMPANY
ip2location.regionthe region or state name
ip2location.time_zonethe Time zone in UTC (Coordinated Universal Time)
ip2location.usage_typethe usage type
ip2location.weather_station_codethe special code to identify the nearest weather observation station
ip2location.weather_station_namethe name of the nearest weather observation station
ip2location.zip_codethe ZIP code

Support

Email: support@ip2location.com
URL: https://www.ip2location.com

FAQs

Package last updated on 21 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc