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.
Warning
In order to take advantage of server-side IP address geolocation, you must send IP addresses to Sentry in the first place. Newer SDKs do not do this by default.
To enable server-side 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.
It's normal to see the sentry_self_hosted_geoipupdate_1
container exit soon after startup, since updating the geolocation database is a one-off batch process and not a long-running job.
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'
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").