I am attempting to create a new output plugin. The conf is pretty simple
input {
stdin{}
}
filter {
mutate {
add_field => {
"[some_new_field]" => "some_new_field_value"
}
}
}
output {
mynewplugin{
value_to_plugin => "%{[some_new_field]}"
}
stdout { codec => rubydebug { metadata => true }}
}
Then in my plugin I simply have:
# encoding: utf-8
require "logstash/outputs/base"
require "logstash/namespace"
class LogStash::Outputs::MyNewPlugin < LogStash::Outputs::Base
config_name "mynewplugin"
default :codec, 'plain'
# Replace the message with this value.
config :value_to_plugin, :validate => :string, :default => "default_value"
concurrency :single
public
def register
# Add instance variables
end # def register
public
def receive(event)
File.open("/tmp/log.txt", "w") { |f| f.write @value_to_plugin }
return "Event received"
end # def filter
end # class LogStash::Outputs::MyNewPlugin
The plugin is getting called correctly but the string written to /tmp/log.txt is:
%{[some_new_field]}
but I expect it to be:
some_new_field_value
I have checked many other plugins as this is a pretty common operation, but can not find my mistake.