Last active
August 29, 2015 14:01
-
-
Save kiyoto/bd23ef1e38272f36aa1a to your computer and use it in GitHub Desktop.
Selecting a particular field for Fluentd to process further
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<source> | |
type forward | |
</source> | |
<match test.**> | |
type select_fields | |
add_tag_prefix fields_selected | |
selected_field foo | |
</match> | |
<match fields_selected.**> | |
type stdout | |
</match> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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