-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Update GeoIP processor documentation #71211
Merged
Merged
Changes from 4 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4b14147
docs + setting name
probakowski db87d13
line length
probakowski 8febf90
Merge branch 'master' into geoip-docs
elasticmachine af26345
Add API docs. Edits and reorg.
jrodewig 3b8b472
Merge branch 'master' into geoip-docs
elasticmachine b54add8
Remove redirect
jrodewig 9fcea3c
Wording cleanup
jrodewig bb1002b
Wording cleanup
jrodewig 79b4257
reword
jrodewig 99c0d56
Edit
jrodewig 0cbefad
Edit
jrodewig f335b34
Merge branch 'master' into geoip-docs
elasticmachine 4986da6
Merge remote-tracking branch 'origin/master' into geoip-docs
probakowski 4a926a8
fix setting/property name
probakowski 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
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,94 @@ | ||
[[geoip-stats-api]] | ||
=== GeoIP stats API | ||
++++ | ||
<titleabbrev>GeoIP stats</titleabbrev> | ||
++++ | ||
|
||
Gets download statistics for GeoIP2 databases used with the | ||
<<geoip-processor,`geoip` processor>>. | ||
|
||
[source,console] | ||
---- | ||
GET _ingest/geoip/stats | ||
---- | ||
|
||
[[geoip-stats-api-request]] | ||
==== {api-request-title} | ||
|
||
`GET _ingest/geoip/stats` | ||
|
||
[[geoip-stats-api-prereqs]] | ||
==== {api-prereq-title} | ||
|
||
* If the {es} {security-features} are enabled, you must have the `monitor` or | ||
`manage` <<privileges-list-cluster,cluster privilege>> to use this API. | ||
|
||
* If <<ingest-geoip-downloader-enabled,`ingest.geoip.downloader.enabled`>> is | ||
disabled, this API returns zero values and an empty `nodes` object. | ||
|
||
[role="child_attributes"] | ||
[[geoip-stats-api-response-body]] | ||
==== {api-response-body-title} | ||
|
||
`stats`:: | ||
(object) | ||
Download statistics for all GeoIP2 databases. | ||
+ | ||
.Properties of `stats` | ||
[%collapsible%open] | ||
==== | ||
`successful_downloads`:: | ||
(integer) | ||
Total number of successful database downloads. | ||
|
||
`failed_downloads`:: | ||
(integer) | ||
Total number of failed database downloads. | ||
|
||
`total_download_time`:: | ||
(integer) | ||
Total milliseconds spent downloading databases. | ||
|
||
`database_count`:: | ||
(integer) | ||
Current number of GeoIP2 databases available for use. | ||
|
||
`skipped_updates`:: | ||
(integer) | ||
Total number of database updates skipped. | ||
==== | ||
|
||
`nodes`:: | ||
(object) | ||
Current downloaded GeoIP2 databases and related files for each node. | ||
+ | ||
.Properties of `nodes` | ||
[%collapsible%open] | ||
==== | ||
`<node_id>`:: | ||
(object) | ||
Current downloaded databases and related files for the node. The field key is | ||
the node ID. | ||
+ | ||
.Properties of `<node_id>` | ||
[%collapsible%open] | ||
===== | ||
`databases`:: | ||
(array of objects) | ||
Current databases downloaded for the node. | ||
+ | ||
.Properties of `databases` objects | ||
[%collapsible%open] | ||
====== | ||
`name`:: | ||
(string) | ||
Name of the database. | ||
====== | ||
|
||
`files_in_temp`:: | ||
(array of strings) | ||
Current databases files, including related license files. {es} stores | ||
these files in the node's <<es-tmpdir,temporary directory>>: | ||
`$ES_TMPDIR/geoip-databases/<node_id>`. | ||
===== | ||
==== |
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 |
---|---|---|
@@ -1,15 +1,29 @@ | ||
[[ingest-apis]] | ||
== Ingest APIs | ||
|
||
The following ingest APIs are available for managing pipelines: | ||
Use ingest APIs to manage tasks and resources related to <<ingest,ingest | ||
pipelines>> and processors. | ||
|
||
* <<put-pipeline-api>> to add or update a pipeline | ||
* <<get-pipeline-api>> to return a specific pipeline | ||
[[ingest-pipeline-apis]] | ||
=== Ingest pipeline APIs | ||
|
||
Use the following APIs to create, manage, and test ingest pipelines: | ||
|
||
* <<put-pipeline-api>> to create or update a pipeline | ||
* <<get-pipeline-api>> to retrieve a pipeline configuration | ||
* <<delete-pipeline-api>> to delete a pipeline | ||
* <<simulate-pipeline-api>> to simulate a call to a pipeline | ||
* <<simulate-pipeline-api>> to test a pipeline | ||
|
||
[[ingest-stat-apis]] | ||
=== Stat APIs | ||
|
||
Use the following APIs to get statistics about ingest processing: | ||
|
||
* <<geoip-stats-api>> to get download statistics for GeoIP2 databases used with | ||
the <<geoip-processor,`geoip` processor>>. | ||
|
||
include::put-pipeline.asciidoc[] | ||
include::get-pipeline.asciidoc[] | ||
include::delete-pipeline.asciidoc[] | ||
include::get-pipeline.asciidoc[] | ||
include::geoip-stats-api.asciidoc[] | ||
include::simulate-pipeline.asciidoc[] |
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 |
---|---|---|
|
@@ -4,21 +4,20 @@ | |
<titleabbrev>GeoIP</titleabbrev> | ||
++++ | ||
|
||
The `geoip` processor adds information about the geographical location of IP addresses, based on data from the Maxmind databases. | ||
This processor adds this information by default under the `geoip` field. The `geoip` processor can resolve both IPv4 and | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I removed the sentence about the |
||
IPv6 addresses. | ||
|
||
The `ingest-geoip` module ships by default with the GeoLite2 City, GeoLite2 Country and GeoLite2 ASN GeoIP2 databases from Maxmind made available | ||
under the CCA-ShareAlike 4.0 license. For more details see, http://dev.maxmind.com/geoip/geoip2/geolite2/ | ||
|
||
The `geoip` processor can run with other city, country and ASN GeoIP2 databases | ||
from Maxmind. The database files must be copied into the `ingest-geoip` config | ||
directory located at `$ES_CONFIG/ingest-geoip`. Custom database files must be | ||
stored uncompressed and the extension must be `-City.mmdb`, `-Country.mmdb`, or | ||
`-ASN.mmdb` to indicate the type of the database. These database files can not | ||
have the same filename as any of the built-in database names. The | ||
`database_file` processor option is used to specify the filename of the custom | ||
database to use for the processor. | ||
The `geoip` processor adds information about the geographical location of an | ||
IPv4 or IPv6 address. | ||
|
||
[[geoip-automatic-updates]] | ||
By default, the processor uses the GeoLite2 City, GeoLite2 Country, and GeoLite2 | ||
ASN GeoIP2 databases from | ||
http://dev.maxmind.com/geoip/geoip2/geolite2/[MaxMind], shared under the | ||
CCA-ShareAlike 4.0 license. {es} automatically downloads and manages updates for | ||
these databases from the Elastic GeoIP endpoint: | ||
https://geoip.elastic.co/v1/database. To get download statistics for these | ||
updates, use the <<geoip-stats-api,GeoIP stats API>>. | ||
|
||
If your cluster can't connect to the Elastic GeoIP endpoint or you want to | ||
manage your own updates, see <<manage-geoip-database-updates>>. | ||
|
||
[[using-ingest-geoip]] | ||
==== Using the `geoip` Processor in a Pipeline | ||
|
@@ -29,7 +28,7 @@ database to use for the processor. | |
|====== | ||
| Name | Required | Default | Description | ||
| `field` | yes | - | The field to get the ip address from for the geographical lookup. | ||
| `target_field` | no | geoip | The field that will hold the geographical information looked up from the Maxmind database. | ||
| `target_field` | no | geoip | The field that will hold the geographical information looked up from the MaxMind database. | ||
| `database_file` | no | GeoLite2-City.mmdb | The database filename referring to a database the module ships with (GeoLite2-City.mmdb, GeoLite2-Country.mmdb, or GeoLite2-ASN.mmdb) or a custom database in the `ingest-geoip` config directory. | ||
| `properties` | no | [`continent_name`, `country_iso_code`, `country_name`, `region_iso_code`, `region_name`, `city_name`, `location`] * | Controls what properties are added to the `target_field` based on the geoip lookup. | ||
| `ignore_missing` | no | `false` | If `true` and `field` does not exist, the processor quietly exits without modifying the document | ||
|
@@ -300,6 +299,83 @@ GET /my_ip_locations/_search | |
// TESTRESPONSE[s/"took" : 3/"took" : $body.took/] | ||
//// | ||
|
||
[[manage-geoip-database-updates]] | ||
==== Manage your own GeoIP2 database updates | ||
|
||
If you can't <<geoip-automatic-updates,automatically update>> your GeoIP2 | ||
databases from the Elastic endpoint, you have a few options: | ||
|
||
* <<use-proxy-geoip-endpoint,Use a proxy endpoint>> | ||
* <<use-custom-geoip-endpoint,Use a custom endpoint>> | ||
* <<manually-update-geoip-databases,Manually update your GeoIP2 databases>> | ||
|
||
To disable automatic database updates entirely, use the | ||
<<cluster-update-settings,update cluster settings API>> to set | ||
<<ingest-geoip-downloader-enabled,`ingest.geoip.downloader.enabled`>> to | ||
`false`. | ||
|
||
[[use-proxy-geoip-endpoint]] | ||
**Use a proxy endpoint** | ||
|
||
If you can't connect directly to the Elastic GeoIP endpoint, consider setting up | ||
a secure proxy. You can then specify the proxy endpoint URL in the | ||
<<ingest-geoip-downloader-endpoint,`ingest.geoip.downloader.endpoint`>> setting | ||
of each node’s `elasticsearch.yml` file. | ||
|
||
[[use-custom-geoip-endpoint]] | ||
**Use a custom endpoint** | ||
|
||
You can create a service that mimics the Elastic GeoIP endpoint. You can then | ||
get automatic updates from this service. | ||
|
||
. Download your `.mmdb` database files from the | ||
http://dev.maxmind.com/geoip/geoip2/geolite2[MaxMind site]. | ||
|
||
. Copy your database files to a single directory. | ||
|
||
. From your {es} directory, run: | ||
+ | ||
[source,sh] | ||
---- | ||
./bin/elasticsearch-geoip -s my/source/dir [-t target/directory] | ||
---- | ||
|
||
. Serve the static database files from your directory. For example, you can use | ||
Docker to serve the files from an nginx server: | ||
+ | ||
[source,sh] | ||
---- | ||
docker run -v my/source/dir:/usr/share/nginx/html:ro nginx | ||
---- | ||
|
||
. Specify the service's endpoint URL in the | ||
<<ingest-geoip-downloader-endpoint,`ingest.geoip.downloader.endpoint`>> setting | ||
of each node’s `elasticsearch.yml` file. | ||
+ | ||
By default, {es} checks the endpoint for updates every three days. To use | ||
another polling interval, use the <<cluster-update-settings,update cluster | ||
settings API>> to set | ||
<<ingest-geoip-downloader-poll-interval,`ingest.geoip.downloader.poll.interval`>>. | ||
|
||
[[manually-update-geoip-databases]] | ||
**Manually update your GeoIP2 databases** | ||
|
||
. Use the <<cluster-update-settings,update cluster settings API>> to set | ||
`ingest.geoip.downloader.enabled` to `false`. This disables automatic updates | ||
that may overwrite your database changes. | ||
|
||
. Download your `.mmdb` database files from the | ||
http://dev.maxmind.com/geoip/geoip2/geolite2[MaxMind site]. | ||
+ | ||
You can also use custom city, country, and ASN `.mmdb` files. These files must | ||
be uncompressed and use the respective `-City.mmdb`, `-Country.mmdb`, or | ||
`-ASN.mmdb` extensions. | ||
|
||
. Copy the database files to `$ES_CONFIG/ingest-geoip`. | ||
|
||
. In your `geoip` processors, configure the `database_file` parameter to use a | ||
custom database file. | ||
|
||
[[ingest-geoip-settings]] | ||
===== Node Settings | ||
|
||
|
@@ -310,3 +386,28 @@ The `geoip` processor supports the following setting: | |
The maximum number of results that should be cached. Defaults to `1000`. | ||
|
||
Note that these settings are node settings and apply to all `geoip` processors, i.e. there is one cache for all defined `geoip` processors. | ||
|
||
[[geoip-cluster-settings]] | ||
===== Cluster settings | ||
|
||
[[ingest-geoip-downloader-enabled]] | ||
`ingest.geoip.downloader.enabled`:: | ||
(<<dynamic-cluster-setting,Dynamic>>, Boolean) | ||
If `true`, {es} downloads automatic updates for GeoIP2 databases from the | ||
`ingest.geoip.downloader.endpoint`. If `false`, {es} does not download updates | ||
and deletes all downloaded databases. Defaults to `true`. | ||
|
||
[[ingest-geoip-downloader-endpoint]] | ||
`ingest.geoip.downloader.endpoint`:: | ||
(<<static-cluster-setting,Static>>, string) | ||
Endpoint URL used to download updates for GeoIP2 databases. Defaults to | ||
`https://geoip.elastic.co/v1/database`. {es} stores downloaded database files in | ||
each node's <<es-tmpdir,temporary directory>> at | ||
`$ES_TMPDIR/geoip-databases/<node_id>`. | ||
|
||
[[ingest-geoip-downloader-poll-interval]] | ||
`ingest.geoip.downloader.poll.interval`:: | ||
(<<dynamic-cluster-setting,Dynamic>>, <<time-units,time value>>) | ||
How often {es} checks for GeoIP2 database updates at the | ||
`ingest.geoip.downloader.endpoint`. Must be greater than `1d` (one day). Defaults | ||
to `3d` (three days). |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -60,9 +60,9 @@ public class GeoIpDownloader extends AllocatedPersistentTask { | |
|
||
public static final boolean GEOIP_V2_FEATURE_FLAG_ENABLED = "true".equals(System.getProperty("es.geoip_v2_feature_flag_enabled")); | ||
|
||
public static final Setting<TimeValue> POLL_INTERVAL_SETTING = Setting.timeSetting("geoip.downloader.poll.interval", | ||
public static final Setting<TimeValue> POLL_INTERVAL_SETTING = Setting.timeSetting("ingest.geoip.downloader.poll.interval", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
TimeValue.timeValueDays(3), TimeValue.timeValueDays(1), Property.Dynamic, Property.NodeScope); | ||
public static final Setting<String> ENDPOINT_SETTING = Setting.simpleString("geoip.downloader.endpoint", | ||
public static final Setting<String> ENDPOINT_SETTING = Setting.simpleString("ingest.geoip.downloader.endpoint", | ||
"https://geoip.elastic.co/v1/database", Property.NodeScope); | ||
|
||
public static final String GEOIP_DOWNLOADER = "geoip-downloader"; | ||
|
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
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.
@probakowski Can you confirm this is milliseconds? It looks like it in the source, but I had a hard time teasing it out. Thanks!
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.
Yes, this is in milliseconds.