Skip to content

Instantly share code, notes, and snippets.

@amitu
Created September 10, 2013 22:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amitu/6516581 to your computer and use it in GitHub Desktop.
Save amitu/6516581 to your computer and use it in GitHub Desktop.
Dummy plugin for logstash.
input {
stdin {
type => "foo"
}
}
filter {
if [type] == "foo" {
foo {
message => "Hello world!"
}
}
}
output {
stdout {
codec => "json"
}
}
# 'logstash/filters/foo.rb'
require "logstash/filters/base"
require "logstash/namespace"
class LogStash::Filters::Foo < LogStash::Filters::Base
config_name "foo"
milestone 1
config :message, :validate => :string
public
def register
end
public
def filter(event)
return unless filter?(event)
if @message
event["message"] = "werwer"
event["bar"] = "123123"
end
filter_matched(event)
end
end
➜ ops java -jar logstash-1.2.1-flatjar.jar agent --config debug.conf --pluginpath .
Using milestone 1 filter plugin 'foo'. This plugin should work, but would benefit from use by folks like you. Please let us know if you find bugs or have suggestions on how to improve this plugin. For more information on plugin milestones, see http://logstash.net/docs/1.2.1/plugin-milestones {:level=>:warn}
Using milestone 1 codec plugin 'json'. This plugin should work, but would benefit from use by folks like you. Please let us know if you find bugs or have suggestions on how to improve this plugin. For more information on plugin milestones, see http://logstash.net/docs/1.2.1/plugin-milestones {:level=>:warn}
foo
{"message":"werwer","@timestamp":"2013-09-10T22:20:16.478Z","@version":"1","type":"foo","host":"pakichika.local","bar":"123123"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment