geoip-stream
Maxmind GeoIP Stream. Transforms a JSON string stream of objects by looking for an ip
field (as defined) and appending maxmind data to the stream if it is found. Uses readable-stream for node < 0.10 to ensure stream2+ sanity.
Install
npm install geoip-stream
Maxmind data installed, ex: free Maxmind GeoLiteCity stored in ./GeoLiteCity.dat
Usage
Sample logfile.json
line:
"ip": "198.55.125.23" "timestamp":"2014-02-24 10:29:42" "url": "http:\/\/somedomain.com"
var fs = ;var logstream = fs;var split = 'split';var geoipStream = ;var geoip = dataPath: './GeoLiteCity.dat' // default memoryCache: true // default checkForUpdates: true // default ipField: 'ip' // default dropIpField: true // default is false; logstream // { "timestamp": ..., "countryCode": "US", "city":"Dallas", ...}