Saturday, January 07, 2017

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:
  1. download, unpack and cd into the logstash version you are using or planning to use
  2. install development tools: ./bin/logstash-plugin install --development
  3. check if the bin directory contains an rspec file. If not create it and make it executable using this source
  4. 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
  5. in spec drop a test specification, like the one below
  6. test your specs with the following command:

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.

No comments: