Convert logstash config to template, and minor bug fix.