Skip to content

Commit

Permalink
format in_tail path with the specified timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsu-yam committed Dec 9, 2019
1 parent bfc39b5 commit 5955c0d
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/fluent/plugin/in_tail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,8 @@ def initialize
config_param :skip_refresh_on_startup, :bool, default: false
desc 'Ignore repeated permission error logs'
config_param :ignore_repeated_permission_error, :bool, default: false
desc 'Format path with the specified timezone'
config_param :timezone, :string, default: nil

config_section :parse, required: false, multi: true, init: true, param_name: :parser_configs do
config_argument :usage, :string, default: 'in_tail_parser'
Expand Down Expand Up @@ -129,6 +131,10 @@ def configure(conf)
if @paths.empty?
raise Fluent::ConfigError, "tail: 'path' parameter is required on tail input"
end
if @timezone
Fluent::Timezone.validate!(@timezone)
@path_formatters = @paths.map{|path| [path, Fluent::Timezone.formatter(@timezone, path)]}.to_h
end

# TODO: Use plugin_root_dir and storage plugin to store positions if available
if @pos_file
Expand Down Expand Up @@ -229,7 +235,11 @@ def expand_paths
paths = []

@paths.each { |path|
path = date.strftime(path)
path = if @timezone
@path_formatters[path].call(date)
else
date.strftime(path)
end
if path.include?('*')
paths += Dir.glob(path).select { |p|
begin
Expand Down

0 comments on commit 5955c0d

Please sign in to comment.