bpaquet / node-logstash

Simple logstash implmentation in nodejs : file log collection, sent with zeromq
Other
517 stars 141 forks source link

Added a new geoip filter #42

Closed subutux closed 10 years ago

subutux commented 11 years ago

Hi,

I've created a geoip filter for node-logstash. haven't tested it yet, but should work.

It uses the geoip-lite (npm install geoip-lite) library, from https://github.com/bluesmoon/node-geoip and is able to lookup an ip's location and could add the following data:

Usage filter://geoip://?use_attr=postfix_source&save_city=false&save_region=false&save_latlon=false&save_country=true

vid commented 11 years ago

can you merge this? I had already written one but this one looks fine too. thanks!

vid commented 11 years ago

ok, there are a couple of changes that should be made;

this.save_latlon = this.save_latlon == 'false'; 

should be true

and it would be much more useful to save the coordinates in an array called lonlat (in that order) so Kibana's bettermap can display them.

data[this.use_attr + '_geo_lonlat'] = [geo['ll'][1],geo['ll'][0]];

I have made these modifications locally (renaming latlon to lonlat with the above difference) and it works great.

bpaquet commented 11 years ago

Can you add documentation and tests ?

At least docs ?

subutux commented 11 years ago

I'll try to write some documentation tonight. Never written tests for NodeJS in my life...

bpaquet commented 10 years ago

@subutux I have renamed config fields for geoip filter to be more compliant with other filter. I have added some tests.