Testing logstash filters
There are many posts on techniques for testing your logstash config, but I found most of them to lack in the exact details of getting it working and others are just obsolete, so here are my dumbed down notes:
Enjoy :-)
Edited on Jan 29th 2017 as I missed the plugin step. Apparently I had an older version lying around which filled the missing gems. Got bitten reproducing on new laptop.
- download, unpack and cd into the logstash version you are using or planning to use
- install development tools: ./bin/logstash-plugin install --development
- check if the bin directory contains an rspec file. If not create it and make it executable using this source
- now cd into the project holding your logstash configs. I'll assume your logstash config lives in a conf.d directory: create a spec directory at the same level or run ${LOGSTASH_HOME}/bin/rspec --init for rspec to create its directory structure. You should now have conf.d and spec at the same level
- in spec drop a test specification, like the one below
- test your specs with the following command:
${LOGSTASH_HOME}/bin/rspec
Enjoy :-)
Edited on Jan 29th 2017 as I missed the plugin step. Apparently I had an older version lying around which filled the missing gems. Got bitten reproducing on new laptop.