This documentation is for WSO2 API Manager 2.0.0. View documentation for the latest release.
Skip to end of metadata
Go to start of metadata

Follow the procedure below in order to configure WSO2 API Manager to receive geolocation based alerts.

Note that we are using MySQL in this documentation for configuring the GEO_LOCATION_DATA database.

  1. Download the Geolocation data from here

  2. Unzip the file you downloaded.

    If you have Geo Location Dataset already dowloaded you can update that dataset by following Updating Geo Location Data Set.

  3. Create the GEO_LOCATION_DATA database by executing one of the scripts in the Geolocation Data/dbscripts directory. In this example, mysql.sql is executed.

    This can be done using the MySQL Workbench.

    For detailed instructions to run the database script, see MySQL Documentation - The Workbench Scripting Shell.

  4. Restore data to the BLOCKS and LOCATION tables by importing data from  BLOCKS.csv and LOCATION.csv in .Geolocation Data/data directory of the extracted zip using below commands.

    • Importing Geolocation Data/data/LOCATION.csv
      mysqlimport -u root -p --ignore-lines=2 --fields-terminated-by=, --fields-optionally-enclosed-by='"' --local GEO_LOCATION_DATA <path_to_folder_location>/GeolocationData/data/LOCATION.csv

    • Importing Geolocation Data/data/BLOCKS.csv
      mysqlimport -u root -p --ignore-lines=2 --fields-terminated-by=, --fields-optionally-enclosed-by='"' --local GEO_LOCATION_DATA <Extracted_location>/GeolocationData/data/BLOCKS.csv

  5. Check whether your imported dataset is properly working using executing following query in MySQL Command Line.

    SELECT loc.country_name,loc.subdivision_1_name FROM BLOCKS block , LOCATION loc WHERE block.network_blocks = '<Network_part_of_ipv4>' AND
     <Long_value_of_publilc_IP> BETWEEN AND block.broadcast AND block.geoname_id=loc.geoname_id;

    Example query

    SELECT loc.country_name,loc.subdivision_1_name FROM BLOCKS block , LOCATION loc WHERE block.network_blocks = '221.192' AND 3720398641 
    BETWEEN AND block.broadcast AND block.geoname_id=loc.geoname_id;

  6. Download a JDBC provider depending on the database you are using (MySQL in this example), and copy it to the <APIM_ANALYTICS_HOME>/repository/components/lib directory.

  7. Configure the datasource in the <APIM_ANALYTICS_HOME>/repository/conf/datasources/geolocation-datasources.xml file as follows.

    <datasources-configuration xmlns:svns="http://org.wso2.securevault/configuration">
                <description>The datasource used for Geo location database</description>
                <definition type="RDBMS">
                        <validationQuery>SELECT 1</validationQuery>

  8. Log into the WSO2 API Manager Admin Portal using the https://localhost:<SERVER_PORT>/admin URL.
  9. Under Settings => Analytics, click Configure Alerts to open the Alert Configurations page.
  10. In the Geo Location Configurations section, click Activate for APIM_GEO_LOCATION_STATS. This opens the Edit Configuration page with the default configuration for geolocation statistics as shown below.

    Modify parameter values as required.
  11. Click Save Configuration.

The script that summarizes geolocation based statistics runs every day at 2300 hours. Due to this, statistics may not be visible immediately when you enable geolocation based statistics. To update these statistics immediately, follow the steps below.

  1. In the WSO2 APIM Analytics Management Console, click the Main tab.
  2. In the Batch Analytics section, click Scripts.
  3. Click Execute for the APIMAnalytics-APIM_GEO_LOCATION_STATS-APIM_GEO_LOCATION_STATS-batch1 script.
  • No labels