Skip to content

Instantly share code, notes, and snippets.

@kiyoto
Last active August 29, 2015 14:01
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 kiyoto/bd23ef1e38272f36aa1a to your computer and use it in GitHub Desktop.
Save kiyoto/bd23ef1e38272f36aa1a to your computer and use it in GitHub Desktop.
Selecting a particular field for Fluentd to process further
<source>
type forward
</source>
<match test.**>
type select_fields
add_tag_prefix fields_selected
selected_field foo
</match>
<match fields_selected.**>
type stdout
</match>
module Fluent
class SelectFieldsOutput < BufferedOutput
Plugin.register_output('select_fields', self)
def initialize
super
end
config_param :selected_field, :string
config_param :add_tag_prefix, :string
def configure(conf)
super
end
def emit(tag, es, chain)
new_tag = "#{@add_tag_prefix}.#{tag}"
es.each do |time, record|
if record[@selected_field].is_a?(Hash)
Engine.emit(new_tag, time, record[@selected_field])
end
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment