-
Notifications
You must be signed in to change notification settings - Fork 214
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Geoip database update implementation #4105
Merged
asifsmohammed
merged 12 commits into
opensearch-project:main
from
asifsmohammed:geoip-database-update
Feb 21, 2024
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
8cdb559
Add when condition to each entry
asifsmohammed d2b991f
Addressed feedback by updating metric names
asifsmohammed 063505c
Updated metric logic and Added new test
asifsmohammed 6c2d2a7
Reverted when condition to processor level
asifsmohammed fcfb3bd
Update database updater logic and added some boilerplate code
asifsmohammed 3b6dadf
Geoip database readers update
asifsmohammed 9d5ae91
Geoip processor implementation
asifsmohammed 2064cca
Add tests to CDN download service
asifsmohammed 5bc1419
Rebased from main
asifsmohammed 9776fa2
Fixed geoip filed to database relation
asifsmohammed 0cdbdad
Addressed feedback
asifsmohammed 3493565
Addressed feedback
asifsmohammed File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...p-processor/src/main/java/org/opensearch/dataprepper/plugins/processor/GeoIPDatabase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.dataprepper.plugins.processor; | ||
|
||
public enum GeoIPDatabase { | ||
CITY, | ||
COUNTRY, | ||
ASN, | ||
ENTERPRISE; | ||
} |
72 changes: 72 additions & 0 deletions
72
...eoip-processor/src/main/java/org/opensearch/dataprepper/plugins/processor/GeoIPField.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* Copyright OpenSearch Contributors | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package org.opensearch.dataprepper.plugins.processor; | ||
|
||
import java.util.Arrays; | ||
import java.util.HashSet; | ||
import java.util.Set; | ||
|
||
public enum GeoIPField { | ||
CONTINENT_CODE("continent_code", GeoIPDatabase.COUNTRY, GeoIPDatabase.ENTERPRISE), | ||
CONTINENT_NAME("continent_name", GeoIPDatabase.COUNTRY, GeoIPDatabase.ENTERPRISE), | ||
COUNTRY_NAME("country_name", GeoIPDatabase.COUNTRY, GeoIPDatabase.ENTERPRISE), | ||
IS_COUNTRY_IN_EUROPEAN_UNION("is_country_in_european_union", GeoIPDatabase.COUNTRY, GeoIPDatabase.ENTERPRISE), | ||
COUNTRY_ISO_CODE("country_iso_code", GeoIPDatabase.COUNTRY, GeoIPDatabase.ENTERPRISE), | ||
COUNTRY_CONFIDENCE("country_confidence", GeoIPDatabase.ENTERPRISE), | ||
REGISTERED_COUNTRY_NAME("registered_country_name", GeoIPDatabase.COUNTRY, GeoIPDatabase.ENTERPRISE), | ||
REGISTERED_COUNTRY_ISO_CODE("registered_country_iso_code", GeoIPDatabase.COUNTRY, GeoIPDatabase.ENTERPRISE), | ||
REPRESENTED_COUNTRY_NAME("represented_country_name", GeoIPDatabase.COUNTRY, GeoIPDatabase.ENTERPRISE), | ||
REPRESENTED_COUNTRY_ISO_CODE("represented_country_iso_code", GeoIPDatabase.COUNTRY, GeoIPDatabase.ENTERPRISE), | ||
REPRESENTED_COUNTRY_TYPE("represented_country_type", GeoIPDatabase.COUNTRY, GeoIPDatabase.ENTERPRISE), | ||
CITY_NAME("city_name", GeoIPDatabase.CITY, GeoIPDatabase.ENTERPRISE), | ||
CITY_CONFIDENCE("city_confidence", GeoIPDatabase.ENTERPRISE), | ||
LOCATION("location", GeoIPDatabase.CITY, GeoIPDatabase.ENTERPRISE), | ||
LATITUDE("latitude", GeoIPDatabase.CITY, GeoIPDatabase.ENTERPRISE), | ||
LONGITUDE("longitude", GeoIPDatabase.CITY, GeoIPDatabase.ENTERPRISE), | ||
LOCATION_ACCURACY_RADIUS("location_accuracy_radius", GeoIPDatabase.CITY, GeoIPDatabase.ENTERPRISE), | ||
METRO_CODE("metro_code", GeoIPDatabase.CITY, GeoIPDatabase.ENTERPRISE), | ||
TIME_ZONE("time_zone", GeoIPDatabase.CITY, GeoIPDatabase.ENTERPRISE), | ||
POSTAL_CODE("postal_code", GeoIPDatabase.CITY, GeoIPDatabase.ENTERPRISE), | ||
POSTAL_CODE_CONFIDENCE("postal_code_confidence", GeoIPDatabase.ENTERPRISE), | ||
MOST_SPECIFIED_SUBDIVISION_NAME("most_specified_subdivision_name", GeoIPDatabase.CITY, GeoIPDatabase.ENTERPRISE), | ||
MOST_SPECIFIED_SUBDIVISION_ISO_CODE("most_specified_subdivision_iso_code", GeoIPDatabase.CITY, GeoIPDatabase.ENTERPRISE), | ||
MOST_SPECIFIED_SUBDIVISION_CONFIDENCE("most_specified_subdivision_confidence", GeoIPDatabase.ENTERPRISE), | ||
LEAST_SPECIFIED_SUBDIVISION_NAME("least_specified_subdivision_name", GeoIPDatabase.CITY, GeoIPDatabase.ENTERPRISE), | ||
LEAST_SPECIFIED_SUBDIVISION_ISO_CODE("least_specified_subdivision_iso_code", GeoIPDatabase.CITY, GeoIPDatabase.ENTERPRISE), | ||
LEAST_SPECIFIED_SUBDIVISION_CONFIDENCE("least_specified_subdivision_confidence", GeoIPDatabase.ENTERPRISE), | ||
|
||
ASN("asn", GeoIPDatabase.ASN), | ||
ASN_ORGANIZATION("asn_organization", GeoIPDatabase.ASN), | ||
NETWORK("network", GeoIPDatabase.ASN), | ||
IP("ip", GeoIPDatabase.ASN); | ||
|
||
private final HashSet<GeoIPDatabase> geoIPDatabases; | ||
private final String fieldName; | ||
|
||
GeoIPField(final String fieldName, final GeoIPDatabase... geoIPDatabases) { | ||
this.fieldName = fieldName; | ||
this.geoIPDatabases = new HashSet<>(Arrays.asList(geoIPDatabases)); | ||
} | ||
|
||
public static GeoIPField findByName(final String name) { | ||
GeoIPField result = null; | ||
for (GeoIPField geoIPField : values()) { | ||
if (geoIPField.getFieldName().equalsIgnoreCase(name)) { | ||
result = geoIPField; | ||
break; | ||
} | ||
} | ||
return result; | ||
} | ||
|
||
public String getFieldName() { | ||
return fieldName; | ||
} | ||
|
||
public Set<GeoIPDatabase> getGeoIPDatabases() { | ||
return geoIPDatabases; | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this meant to be commented out?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I haven't fixed these integ tests yet, I need to change this because the constructor changed.