lib/fluent/plugin/out_elasticsearch_dynamic.rb in fluent-plugin-elasticsearch-1.10.1 vs lib/fluent/plugin/out_elasticsearch_dynamic.rb in fluent-plugin-elasticsearch-1.10.2

- old
+ new

@@ -5,11 +5,11 @@ Fluent::Plugin.register_output('elasticsearch_dynamic', self) config_param :delimiter, :string, :default => "." - DYNAMIC_PARAM_NAMES = %W[hosts host port logstash_format logstash_prefix logstash_dateformat time_key utc_index index_name tag_key type_name id_key parent_key routing_key write_operation] + DYNAMIC_PARAM_NAMES = %W[hosts host port include_timestamp logstash_format logstash_prefix logstash_dateformat time_key utc_index index_name tag_key type_name id_key parent_key routing_key write_operation] DYNAMIC_PARAM_SYMBOLS = DYNAMIC_PARAM_NAMES.map { |n| "@#{n}".to_sym } attr_reader :dynamic_config def configure(conf) @@ -137,19 +137,21 @@ # handle dynamic parameters misconfigurations router.emit_error_event(tag, time, record, e) next end - if eval_or_val(dynamic_conf['logstash_format']) + if eval_or_val(dynamic_conf['logstash_format']) || eval_or_val(dynamic_conf['include_timestamp']) if record.has_key?("@timestamp") time = Time.parse record["@timestamp"] elsif record.has_key?(dynamic_conf['time_key']) time = Time.parse record[dynamic_conf['time_key']] record['@timestamp'] = record[dynamic_conf['time_key']] unless time_key_exclude_timestamp else record.merge!({"@timestamp" => Time.at(time).to_datetime.to_s}) end + end + if eval_or_val(dynamic_conf['logstash_format']) if eval_or_val(dynamic_conf['utc_index']) target_index = "#{dynamic_conf['logstash_prefix']}-#{Time.at(time).getutc.strftime("#{dynamic_conf['logstash_dateformat']}")}" else target_index = "#{dynamic_conf['logstash_prefix']}-#{Time.at(time).strftime("#{dynamic_conf['logstash_dateformat']}")}" end