-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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: extract database manager to stand-alone feature #15348
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
fe909fb
geoip: extract database manager to stand-alone feature
yaauie 6ad6002
docs: link in geoip database manager docs
yaauie a90d635
docs: reorganize pending 'geoip database management' feature
yaauie 9f31beb
docs: link to geoip pages from feature index
yaauie 3d99780
geoip: add SubscriptionObserver "interface"
yaauie 4070fe2
geoip: fixup SubscriptionObserver after rename
yaauie f06b9d2
geoip: quacking like a SubscriptionObserver is enough
yaauie 5683ca0
Merge remote-tracking branch 'upstream/main' into geoip-database-mana…
yaauie 0580dfd
geoip: simplify constants of legacy geoip filter extension
yaauie 873da95
geoip: bump logging level to debug for non-actionable log
yaauie bb79f3b
geoip: refine log message to omit non-actionable info
yaauie 1a68613
re-enable invokedynamic (was disabled to avoid upstream bug)
yaauie 28f44d9
Merge remote-tracking branch 'upstream/main' into geoip-database-mana…
yaauie 6a2b50b
geoip: resolve testing fall-out from filter extension's "private" con…
yaauie 1caf6d6
geoip: consistently use `DataPath#resolve` internally, too
yaauie 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,10 @@ | ||
[[geoip-database-management]] | ||
== Managing GeoIP Databases | ||
|
||
Logstash provides GeoIP database management features to make it easier for you to | ||
use plugins that require an up-to-date database to enrich events with geographic data. | ||
|
||
- <<logstash-geoip-database-management, Feature Overview>> | ||
- <<configuring-geoip-database-management, Configuration Guide>> | ||
|
||
include::geoip-database-management/index.asciidoc[] |
68 changes: 68 additions & 0 deletions
68
docs/static/geoip-database-management/configuring.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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
[role="xpack"] | ||
[[configuring-geoip-database-management]] | ||
=== Configure GeoIP Database Management | ||
|
||
To configure | ||
<<logstash-geoip-database-management>>: | ||
|
||
. Verify that you are using a license that includes the geoip database management | ||
feature. | ||
+ | ||
-- | ||
For more information, see https://www.elastic.co/subscriptions and | ||
{kibana-ref}/managing-licenses.html[License management]. | ||
-- | ||
|
||
. Specify | ||
<<geoip-database-management-settings,geoip database management settings>> in the | ||
`logstash.yml` file to tune the configuration as-needed. | ||
|
||
include::../settings/geoip-database-management-settings.asciidoc[] | ||
|
||
[[configuring-geoip-database-management-offline]] | ||
==== Offline and air-gapped environments | ||
|
||
If Logstash does not have access to the internet, or if you want to disable the database manager, set the `xpack.geoip.downloader.enabled` value to `false` in `logstash.yml`. | ||
When the database manager is disabled, plugins that require GeoIP lookups must be configured with their own source of GeoIP databases. | ||
|
||
===== Using an HTTP proxy | ||
|
||
If you can't connect directly to the Elastic GeoIP endpoint, consider setting up an HTTP proxy server. | ||
You can then specify the proxy with `http_proxy` environment variable. | ||
|
||
[source,sh] | ||
---- | ||
export http_proxy="http://PROXY_IP:PROXY_PORT" | ||
---- | ||
|
||
===== Using a custom endpoint | ||
|
||
If you work in an air-gapped environment and can't update your databases from the Elastic endpoint, | ||
You can then download databases from MaxMind and bootstrap the service. | ||
|
||
. Download both `GeoLite2-ASN.mmdb` and `GeoLite2-City.mmdb` database files from the | ||
http://dev.maxmind.com/geoip/geoip2/geolite2[MaxMind site]. | ||
|
||
. Copy both database files to a single directory. | ||
|
||
. https://www.elastic.co/downloads/elasticsearch[Download {es}]. | ||
|
||
. From your {es} directory, run: | ||
+ | ||
[source,sh] | ||
---- | ||
./bin/elasticsearch-geoip -s my/database/dir | ||
---- | ||
|
||
. Serve the static database files from your directory. For example, you can use | ||
Docker to serve the files from nginx server: | ||
+ | ||
[source,sh] | ||
---- | ||
docker run -p 8080:80 -v my/database/dir:/usr/share/nginx/html:ro nginx | ||
---- | ||
|
||
. Specify the service's endpoint URL in Logstash using the | ||
`xpack.geoip.download.endpoint=http://localhost:8080/overview.json` setting in `logstash.yml`. | ||
|
||
Logstash gets automatic updates from this service. |
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,19 @@ | ||
[role="xpack"] | ||
[[logstash-geoip-database-management]] | ||
=== GeoIP Database Management | ||
|
||
Logstash provides a mechanism for provisioning and maintaining GeoIP databases, which plugins can use to ensure that they have access to an always-up-to-date and EULA-compliant database for geo enrichment. | ||
This mechanism requires internet access or a network route to an Elastic GeoIP database service. | ||
|
||
If the database manager is enabled in `logstash.yml` (as it is by default), a plugin may subscribe to a database, triggering a download if a valid database is not already available. | ||
Logstash checks for updates every day. | ||
When an updated database is discovered, it is downloaded in the background and made available to the plugins that rely on it. | ||
|
||
The GeoIP databases are separately-licensed from MaxMind under the terms of an End User License Agreement, which prohibits a database from being used after an update has been available for more than 30 days. | ||
When Logstash cannot reach the database service for 30 days or more to validate that a managed database is up-to-date, that database is deleted and made unavailable to the plugins that subscribed to it. | ||
|
||
NOTE: GeoIP database management is a licensed feature of Logstash, and is only available in the Elastic-licensed complete distribution of Logstash. | ||
|
||
include::metrics.asciidoc[] | ||
|
||
include::configuring.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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
|
||
[[logstash-geoip-database-management-metrics]] | ||
==== Database Metrics | ||
|
||
You can monitor the managed database's status through the <<node-stats-api,Node Stats API>>. | ||
|
||
The following request returns a JSON document containing database manager stats, | ||
including: | ||
|
||
* database status and freshness | ||
** `geoip_download_manager.database.*.status` | ||
*** `init` : initial CC database status | ||
*** `up_to_date` : using up-to-date EULA database | ||
*** `to_be_expired` : 25 days without calling service | ||
*** `expired` : 30 days without calling service | ||
** `fail_check_in_days` : number of days Logstash fails to call service since the last success | ||
* info about download successes and failures | ||
** `geoip_download_manager.download_stats.successes` number of successful checks and downloads | ||
** `geoip_download_manager.download_stats.failures` number of failed check or download | ||
** `geoip_download_manager.download_stats.status` | ||
*** `updating` : check and download at the moment | ||
*** `succeeded` : last download succeed | ||
*** `failed` : last download failed | ||
|
||
[source,js] | ||
-------------------------------------------------- | ||
curl -XGET 'localhost:9600/_node/stats/geoip_download_manager?pretty' | ||
-------------------------------------------------- | ||
|
||
Example response: | ||
|
||
[source,js] | ||
-------------------------------------------------- | ||
{ | ||
"geoip_download_manager" : { | ||
"database" : { | ||
"ASN" : { | ||
"status" : "up_to_date", | ||
"fail_check_in_days" : 0, | ||
"last_updated_at": "2021-06-21T16:06:54+02:00" | ||
}, | ||
"City" : { | ||
"status" : "up_to_date", | ||
"fail_check_in_days" : 0, | ||
"last_updated_at": "2021-06-21T16:06:54+02:00" | ||
} | ||
}, | ||
"download_stats" : { | ||
"successes" : 15, | ||
"failures" : 1, | ||
"last_checked_at" : "2021-06-21T16:07:03+02:00", | ||
"status" : "succeeded" | ||
} | ||
} | ||
} | ||
-------------------------------------------------- |
26 changes: 26 additions & 0 deletions
26
docs/static/settings/geoip-database-management-settings.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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
[role="xpack"] | ||
[[geoip-database-management-settings]] | ||
==== GeoIP database Management settings in {ls} | ||
++++ | ||
<titleabbrev>GeoIP Database Management Settings</titleabbrev> | ||
++++ | ||
|
||
You can set the following `xpack.geoip` settings in `logstash.yml` to configure the <<logstash-geoip-database-management, geoip database manager>>. | ||
For more information about configuring Logstash, see <<logstash-settings-file>>. | ||
|
||
`xpack.geoip.downloader.enabled`:: | ||
|
||
(Boolean) If `true`, Logstash automatically downloads and manages updates for GeoIP2 databases from the `xpack.geoip.downloader.endpoint`. | ||
If `false`, Logstash does not manage GeoIP2 databases and plugins that need a GeoIP2 database must be configured to provide their own. | ||
|
||
`xpack.geoip.downloader.endpoint`:: | ||
|
||
(String) Endpoint URL used to download updates for GeoIP2 databases. | ||
For example, `https://mydomain.com/overview.json`. | ||
Defaults to `https://geoip.elastic.co/v1/database`. | ||
Note that Logstash will periodically make a GET request to `${xpack.geoip.downloader.endpoint}?elastic_geoip_service_tos=agree`, expecting the list of metadata about databases typically found in `overview.json`. | ||
|
||
`xpack.geoip.downloader.poll.interval`:: | ||
(Time Value) How often Logstash checks for GeoIP2 database updates at the `xpack.geoip.downloader.endpoint`. | ||
For example, `6h` to check every six hours. | ||
Defaults to `24h` (24 hours). |
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
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.
Yes, intentionally:
To align with naming internally and with the similar feature in Elasticsearch's Geoip database manager. The deprecated pathway is included in
geoip_database_management/extension.rb
.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.
we can add poll interval here
#xpack.geoip.downloader.poll.interval: 24h
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.
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 didn't add the poll interval intentionally, and would prefer deferring that discussion until later. I found the poll interval very helpful in manual testing, but there are some very sharp edges (like our
TimeValue
setting not supporting upper/lower bounds on the total value or on granularity) that limit the value of exposing this to users.