You know how there is a Ruby filter for Logstash which enables me to write code in Ruby and it is usually included in the config file as follows
filter { r
So to answer this, I found this wonderful tutorial from Elastc.co:
Shows the steps to create a new gem and use it as a filter for Logstash later on.
https://www.elastic.co/guide/en/logstash/current/_how_to_write_a_logstash_filter_plugin.html