Self-Hosted Geolocation
Sentry can use MaxMind's free GeoLite2-City
database to geolocate IP addresses, providing additional context for error events where the end user's IP address is known and for the session history of users logging into your Sentry installation. We bundle MaxMind's geoipupdate
tool for this purpose. To enable IP address geolocation, sign up for a free MaxMind account, then tell Sentry about your credentials by placing your MaxMind configuration file at geoip/GeoIP.conf
.
AccountID 012345
LicenseKey foobarbazbuz
EditionIDs GeoLite2-City
With this configuration file in place, subsequent runs of Sentry's install.sh
will refresh the IP address geolocation database. The next time you restart your self-hosted Sentry instance (the relay
and web
services, in particular), you should start seeing the latest data. Here's how to confirm that it's working:
For the
relay
service: Dashboards > Errors by Country should have some purple on it.For the
web
service: User Settings > Security > Session History should display country code and region (for example, "US (CA)") underneath the IP addresses in the table.
Upgrading
The services that consume the GeoLite2-City.mmdb
file need to know where to find it. New installs will have this set automatically, but if you are upgrading you will need to manually set the following before restarting Sentry.
In relay/config.yml
(example):
processing:
geoip_path: "/geoip/GeoLite2-City.mmdb"
In sentry/sentry.conf.py
(example):
GEOIP_PATH_MMDB = '/geoip/GeoLite2-City.mmdb'