Overview
GeoIP enrichment is optional. If no database is configured:- Sparklytics continues to run normally
- Geo fields (country, city, region) are stored as
NULL - All other analytics features work unchanged
Docker images bundle a free DB-IP City Lite database — no setup needed for Docker users.
Quick Start (Docker)
Pre-Bundled Database
Official Sparklytics Docker images include DB-IP City Lite at/geoip/dbip-city-lite.mmdb.
The bundled database is updated monthly. To use the latest version, follow the “Bare-Metal Install” steps below and mount it as a volume.
Bare-Metal Install
Option 1: DB-IP City Lite (Free, Recommended)
DB-IP City Lite is free, requires no registration, and is compatible with the MMDB format.Download the database
Sparklytics includes a download script:This downloads the latest DB-IP City Lite MMDB to
./dbip-city-lite.mmdb (~50 MB).The script tries the current month first, falling back to the previous month if not yet published.
Attribution Requirement
Manual Download
Alternatively, download directly:Option 2: MaxMind GeoLite2 City
MaxMind GeoLite2 is also free but requires account registration.Create MaxMind account
- Sign up at maxmind.com/en/geolite2/signup
- Generate a license key in your account dashboard
MaxMind License Terms
MaxMind GeoLite2 requires attribution and has usage restrictions. See MaxMind’s license terms.
Configuration Reference
Path to MaxMind MMDB-format GeoIP database file.Supported databases:
- DB-IP City Lite (free, no registration)
- MaxMind GeoLite2 City (free, requires account)
- MaxMind GeoIP2 City (commercial)
What Happens if the File is Missing?
- Sparklytics continues to run normally
- A warning is logged at startup
- Geo fields in events are set to
NULL:countrycityregion
- All other analytics features (pageviews, sessions, referrers, etc.) work unchanged
Docker Volume Mounting
To use a custom GeoIP database with Docker::ro) since Sparklytics only reads the file.
Updating the Database
GeoIP databases should be updated monthly for accurate data.Docker (Bundled Database)
Pull the latest Sparklytics image:Bare-Metal
You do not need to restart Sparklytics immediately after updating the file. The old database remains in memory until the next restart.
Automated Updates
For production deployments, set up a monthly cron job:Data Fields Enriched
When GeoIP is configured, these fields are populated on every event:| Field | Type | Example |
|---|---|---|
country | ISO 3166-1 alpha-2 | US, GB, DE |
city | String | San Francisco, London |
region | String | California, England |
Accuracy depends on the database. City-level data is ~70-80% accurate. Country-level is ~95%+.
Privacy Considerations
Sparklytics does not store IP addresses. The GeoIP lookup happens in-memory during event ingestion:- Event arrives at
/api/collectwith IP from request headers - IP is hashed to generate a
visitor_id(salted SHA-256) - IP is looked up in the MMDB to extract geo data
- Geo fields are stored; IP is discarded
- IP never touches the database
Troubleshooting
”GeoIP database not found” Warning
SPARKLYTICS_GEOIP_PATH.
Geo Fields Are NULL Despite Configured Path
-
Check file permissions:
-
Verify path is correct:
-
Test the MMDB file:
Docker Container Can’t Find Mounted Database
docker-compose.yml or docker run command.
Database Comparison
| Database | License | Registration | Size | Accuracy |
|---|---|---|---|---|
| DB-IP City Lite | CC BY 4.0 | No | ~50 MB | Good |
| MaxMind GeoLite2 | Custom | Yes (free) | ~70 MB | Very Good |
| MaxMind GeoIP2 City | Commercial | Yes (paid) | ~100 MB | Excellent |
See Also
- Environment Variables — Full configuration reference
- DB-IP Attribution Requirements
- MaxMind GeoLite2 EULA