Class: Fluent::Plugin::CloudwatchLogsInput

Inherits:
Input
  • Object
show all
Defined in:
lib/fluent/plugin/in_cloudwatch_logs.rb

Instance Method Summary collapse

Constructor Details

#initializeCloudwatchLogsInput

Returns a new instance of CloudwatchLogsInput.



31
32
33
34
35
# File 'lib/fluent/plugin/in_cloudwatch_logs.rb', line 31

def initialize
  super

  require 'aws-sdk-cloudwatchlogs'
end

Instance Method Details

#configure(conf) ⇒ Object



37
38
39
40
41
# File 'lib/fluent/plugin/in_cloudwatch_logs.rb', line 37

def configure(conf)
  compat_parameters_convert(conf, :parser)
  super
  configure_parser(conf)
end

#shutdownObject



73
74
75
76
# File 'lib/fluent/plugin/in_cloudwatch_logs.rb', line 73

def shutdown
  @finished = true
  super
end

#startObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/fluent/plugin/in_cloudwatch_logs.rb', line 43

def start
  super
  options = {}
  options[:region] = @region if @region
  options[:endpoint] = @endpoint if @endpoint
  options[:http_proxy] = @http_proxy if @http_proxy

  if @aws_use_sts
    Aws.config[:region] = options[:region]
    options[:credentials] = Aws::AssumeRoleCredentials.new(
      role_arn: @aws_sts_role_arn,
      role_session_name: @aws_sts_session_name
    )
  else
    options[:credentials] = Aws::Credentials.new(@aws_key_id, @aws_sec_key) if @aws_key_id && @aws_sec_key
  end

  @logs = Aws::CloudWatchLogs::Client.new(options)

  @finished = false
  thread_create(:in_cloudwatch_logs_runner, &method(:run))

  @json_handler = case @json_handler
                  when :yajl
                    Yajl
                  when :json
                    JSON
                  end
end