Class: Fluent::Plugin::CloudwatchLogsInput
- Inherits:
-
Input
- Object
- Input
- Fluent::Plugin::CloudwatchLogsInput
- Defined in:
- lib/fluent/plugin/in_cloudwatch_logs.rb
Constant Summary collapse
- DEFAULT_STORAGE_TYPE =
'local'
Instance Method Summary collapse
- #configure(conf) ⇒ Object
-
#initialize ⇒ CloudwatchLogsInput
constructor
A new instance of CloudwatchLogsInput.
- #shutdown ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize ⇒ CloudwatchLogsInput
Returns a new instance of CloudwatchLogsInput.
57 58 59 60 61 62 |
# File 'lib/fluent/plugin/in_cloudwatch_logs.rb', line 57 def initialize super @parser = nil require 'aws-sdk-cloudwatchlogs' end |
Instance Method Details
#configure(conf) ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/fluent/plugin/in_cloudwatch_logs.rb', line 64 def configure(conf) compat_parameters_convert(conf, :parser) super configure_parser(conf) @start_time = (Time.strptime(@start_time, @time_range_format).to_f * 1000).floor if @start_time @end_time = (Time.strptime(@end_time, @time_range_format).to_f * 1000).floor if @end_time if @start_time && @end_time && (@end_time < @start_time) raise Fluent::ConfigError, "end_time(#{@end_time}) should be greater than start_time(#{@start_time})." end @next_token_storage = storage_create(usage: 'store_next_tokens', conf: config, default_type: DEFAULT_STORAGE_TYPE) end |
#shutdown ⇒ Object
126 127 128 129 |
# File 'lib/fluent/plugin/in_cloudwatch_logs.rb', line 126 def shutdown @finished = true super end |
#start ⇒ Object
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/fluent/plugin/in_cloudwatch_logs.rb', line 77 def start super = {} [:region] = @region if @region [:endpoint] = @endpoint if @endpoint [:http_proxy] = @http_proxy if @http_proxy if @aws_use_sts Aws.config[:region] = [:region] = { role_arn: @aws_sts_role_arn, role_session_name: @aws_sts_session_name } [:sts_endpoint_url] = @aws_sts_endpoint_url if @aws_sts_endpoint_url if @region and @aws_sts_endpoint_url [:client] = Aws::STS::Client.new(:region => @region, endpoint: @aws_sts_endpoint_url) elsif @region [:client] = Aws::STS::Client.new(:region => @region) end [:credentials] = Aws::AssumeRoleCredentials.new() elsif @web_identity_credentials c = @web_identity_credentials = {} [:role_arn] = c.role_arn [:role_session_name] = c.role_session_name [:web_identity_token_file] = c.web_identity_token_file [:policy] = c.policy if c.policy [:duration_seconds] = c.duration_seconds if c.duration_seconds if @region [:client] = Aws::STS::Client.new(:region => @region) end [:credentials] = Aws::AssumeRoleWebIdentityCredentials.new() else [:credentials] = Aws::Credentials.new(@aws_key_id, @aws_sec_key) if @aws_key_id && @aws_sec_key end @logs = Aws::CloudWatchLogs::Client.new() @finished = false thread_create(:in_cloudwatch_logs_runner, &method(:run)) @json_handler = case @json_handler when :yajl Yajl when :json JSON end end |