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.



34
35
36
37
38
# File 'lib/fluent/plugin/in_cloudwatch_logs.rb', line 34

def initialize
  super

  require 'aws-sdk-cloudwatchlogs'
end

Instance Method Details

#configure(conf) ⇒ Object



40
41
42
43
44
# File 'lib/fluent/plugin/in_cloudwatch_logs.rb', line 40

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

#shutdownObject



76
77
78
79
# File 'lib/fluent/plugin/in_cloudwatch_logs.rb', line 76

def shutdown
  @finished = true
  super
end

#startObject



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
72
73
74
# File 'lib/fluent/plugin/in_cloudwatch_logs.rb', line 46

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