Summary: Use a filter in logstash that will read a value from event field, lookup this value in external file (e.g. csv) and retrieve value from external file that match. Use value from external file to add as an extra field in the event.
More info:
I have a log file with events. The events look like:
{"@timestamp":"2014-06-18T11:52:45.370636+02:00","location":{"MainId":3,"SubId":"5"},"EndRequest":{"Duration":{"Main":0,"Page":6720}}}
I have a static csv file like:
1,left
2,right
3,top
When an event is processed in logstash I want to be able to use a filter which will check value of MainId (in example event = 3) and find this value in the csv file. If found then the event must get a tag: "top".
It's kind of a similar way of the filter "GeoIP". The event has a field value, match value in a "database" and return values back which can be added to the event.
I was not able to find a current filter that could to above process. Do I need to make a custom filter myself? If so can some one give a hint how to approach this?
There is the Translate filter.
Instead of a CSV, you have a YAML file, and for single key-value pairs, that should be an easy sed yaml conversion
Latest doc at time of writing: http://logstash.net/docs/1.4.2/filters/translate
I've never seen a plugin written for it, so I went ahead and wrote a very basic one:
There is further work that could be done on it -- for example if the src_field was an array, it could iterate over it, but it should work as is for your case.