fluent-plugin-cloudwatch-ingest 1.7.0.rc2 → 1.7.0.rc4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +8 -7
- data/lib/fluent/plugin/cloudwatch/ingest/version.rb +1 -1
- data/lib/fluent/plugin/in_cloudwatch_ingest.rb +45 -37
- metadata +2 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 9c42dca008805bb5f68165fb13411d8a8d6485aa
         | 
| 4 | 
            +
              data.tar.gz: 8e0ad98f42b5dde7dbdad9d7966b957a72b3754f
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 661cc11d5233d808792d5d1b9b23a740141277d45f1631a3c05edf24eeab3836d337c3c9d1a00b630c42036ba31cc92f37805ef9b71275403a57f1fb661cbe79
         | 
| 7 | 
            +
              data.tar.gz: b38414fb62cce41769e7ab52e7f762f1d1020780ec4d6d02b5afe921a6c466745e5b124756d83bd0c11326a852a81df962a0f4f955dfc6982c782e12b95cdd09
         | 
    
        data/README.md
    CHANGED
    
    | @@ -41,13 +41,14 @@ Or install it yourself as: | |
| 41 41 | 
             
              state_file_name /mnt/nfs/cloudwatch.state
         | 
| 42 42 | 
             
              interval 60
         | 
| 43 43 | 
             
              max_log_streams_per_group 50
         | 
| 44 | 
            -
              error_interval 5 | 
| 45 | 
            -
               | 
| 46 | 
            -
               | 
| 47 | 
            -
               | 
| 48 | 
            -
               | 
| 49 | 
            -
               | 
| 50 | 
            -
               | 
| 44 | 
            +
              error_interval 5            # Time to wait between error conditions before retry
         | 
| 45 | 
            +
              get_log_events_interval 0.0 # Time to pause between get_log_events to reduce throttle error 
         | 
| 46 | 
            +
              limit_events 10000          # Number of events to fetch in any given iteration
         | 
| 47 | 
            +
              event_start_time 0          # Do not fetch events before this time (UNIX epoch, miliseconds)
         | 
| 48 | 
            +
              oldest_logs_first false     # When true fetch the oldest logs first
         | 
| 49 | 
            +
              drop_blank_events true      # Fluentd may throw an exception if a blank event is emitted
         | 
| 50 | 
            +
              telemetry false             # Produce statsd telemetry
         | 
| 51 | 
            +
              statsd_endpoint localhost   # Endpoint to which telemetry should be sent
         | 
| 51 52 | 
             
              <parse>
         | 
| 52 53 | 
             
                @type cloudwatch_ingest
         | 
| 53 54 | 
             
                expression /^(?<message>.+)$/
         | 
| @@ -34,6 +34,8 @@ module Fluent::Plugin | |
| 34 34 | 
             
                desc 'Time to pause between error conditions'
         | 
| 35 35 | 
             
                config_param :error_interval, :time, default: 5
         | 
| 36 36 | 
             
                config_param :api_interval, :time, default: nil
         | 
| 37 | 
            +
                desc 'Time to pause between get_log_events to reduce throttle error'
         | 
| 38 | 
            +
                config_param :get_log_events_interval, :float, default: 0.0
         | 
| 37 39 | 
             
                desc 'Tag to apply to record'
         | 
| 38 40 | 
             
                config_param :tag, :string, default: 'cloudwatch'
         | 
| 39 41 | 
             
                desc 'Enable AWS SDK logging'
         | 
| @@ -254,16 +256,51 @@ module Fluent::Plugin | |
| 254 256 |  | 
| 255 257 | 
             
                def process_stream(group, stream, next_token, start_time, state)
         | 
| 256 258 | 
             
                  event_count = 0
         | 
| 259 | 
            +
                  has_stream_timestamp = true if state.store[group][stream]['timestamp']
         | 
| 257 260 |  | 
| 258 261 | 
             
                  metric(:increment, 'api.calls.getlogevents.attempted')
         | 
| 259 | 
            -
                   | 
| 260 | 
            -
                     | 
| 261 | 
            -
                     | 
| 262 | 
            -
                     | 
| 263 | 
            -
             | 
| 264 | 
            -
                     | 
| 265 | 
            -
             | 
| 266 | 
            -
             | 
| 262 | 
            +
                  begin
         | 
| 263 | 
            +
                    param_next_token = next_token
         | 
| 264 | 
            +
                    param_start_time = start_time
         | 
| 265 | 
            +
                    retried = false
         | 
| 266 | 
            +
             | 
| 267 | 
            +
                    begin
         | 
| 268 | 
            +
                      log.info('log_group_name' => group, 'log_stream_name' => stream,
         | 
| 269 | 
            +
                               'next_token' => param_next_token, 'limit' => @limit_events,
         | 
| 270 | 
            +
                               'start_time' => param_start_time,
         | 
| 271 | 
            +
                               'start_from_head' => @oldest_logs_first)
         | 
| 272 | 
            +
                      sleep @get_log_events_interval
         | 
| 273 | 
            +
                      response = @aws.get_log_events(
         | 
| 274 | 
            +
                        log_group_name: group,
         | 
| 275 | 
            +
                        log_stream_name: stream,
         | 
| 276 | 
            +
                        next_token: param_next_token,
         | 
| 277 | 
            +
                        limit: @limit_events,
         | 
| 278 | 
            +
                        start_time: param_start_time,
         | 
| 279 | 
            +
                        start_from_head: @oldest_logs_first
         | 
| 280 | 
            +
                      )
         | 
| 281 | 
            +
                    rescue Aws::CloudWatchLogs::Errors::InvalidParameterException
         | 
| 282 | 
            +
                      raise if retried
         | 
| 283 | 
            +
             | 
| 284 | 
            +
                      metric(:increment, 'api.calls.getlogevents.invalid_token')
         | 
| 285 | 
            +
                      log.error(
         | 
| 286 | 
            +
                        'cloudwatch token is expired or broken. '\
         | 
| 287 | 
            +
                              'trying with timestamp.'
         | 
| 288 | 
            +
                      )
         | 
| 289 | 
            +
                      param_next_token = nil
         | 
| 290 | 
            +
                      param_start_time = state.store[group][stream]['timestamp']
         | 
| 291 | 
            +
                      param_start_time ||= @event_start_time
         | 
| 292 | 
            +
                      retried = true
         | 
| 293 | 
            +
                      retry
         | 
| 294 | 
            +
                    end
         | 
| 295 | 
            +
                  rescue Aws::CloudWatchLogs::Errors::ThrottlingException,
         | 
| 296 | 
            +
                         Aws::CloudWatchLogs::Errors::ServiceUnavailableException,
         | 
| 297 | 
            +
                         Seahorse::Client::NetworkingError
         | 
| 298 | 
            +
                    # on temporary error, save the current state to retry next time
         | 
| 299 | 
            +
                    if has_stream_timestamp
         | 
| 300 | 
            +
                      state.new_store[group][stream] = state.store[group][stream]
         | 
| 301 | 
            +
                    end
         | 
| 302 | 
            +
                    raise # handle as error in run method
         | 
| 303 | 
            +
                  end
         | 
| 267 304 |  | 
| 268 305 | 
             
                  response.events.each do |e|
         | 
| 269 306 | 
             
                    begin
         | 
| @@ -276,8 +313,6 @@ module Fluent::Plugin | |
| 276 313 |  | 
| 277 314 | 
             
                  log.info("#{event_count} events processed for stream #{stream}")
         | 
| 278 315 |  | 
| 279 | 
            -
                  has_stream_timestamp = true if state.store[group][stream]['timestamp']
         | 
| 280 | 
            -
             | 
| 281 316 | 
             
                  if !has_stream_timestamp && response.events.count.zero?
         | 
| 282 317 | 
             
                    # This stream has returned no data ever.
         | 
| 283 318 | 
             
                    # In this case, don't save state (token could be an invalid one)
         | 
| @@ -333,33 +368,6 @@ module Fluent::Plugin | |
| 333 368 | 
             
                                @event_start_time,
         | 
| 334 369 | 
             
                                state
         | 
| 335 370 | 
             
                              )
         | 
| 336 | 
            -
                            rescue Aws::CloudWatchLogs::Errors::InvalidParameterException
         | 
| 337 | 
            -
                              metric(:increment, 'api.calls.getlogevents.invalid_token')
         | 
| 338 | 
            -
                              log.error(
         | 
| 339 | 
            -
                                'cloudwatch token is expired or broken. '\
         | 
| 340 | 
            -
                                'trying with timestamp.'
         | 
| 341 | 
            -
                              )
         | 
| 342 | 
            -
             | 
| 343 | 
            -
                              # try again with timestamp instead of forward token
         | 
| 344 | 
            -
                              begin
         | 
| 345 | 
            -
                                timestamp = state.store[group][stream]['timestamp']
         | 
| 346 | 
            -
                                timestamp ||= @event_start_time
         | 
| 347 | 
            -
             | 
| 348 | 
            -
                                event_count += process_stream(group,
         | 
| 349 | 
            -
                                                              stream,
         | 
| 350 | 
            -
                                                              nil,
         | 
| 351 | 
            -
                                                              timestamp,
         | 
| 352 | 
            -
                                                              state)
         | 
| 353 | 
            -
                              rescue StandardError => boom
         | 
| 354 | 
            -
                                log.error(
         | 
| 355 | 
            -
                                  'Unable to retrieve events for stream '\
         | 
| 356 | 
            -
                                  "#{stream} in group #{group}: "\
         | 
| 357 | 
            -
                                  "#{boom.inspect}"\
         | 
| 358 | 
            -
                                )
         | 
| 359 | 
            -
                                metric(:increment, 'api.calls.getlogevents.failed')
         | 
| 360 | 
            -
                                sleep @error_interval
         | 
| 361 | 
            -
                                next
         | 
| 362 | 
            -
                              end
         | 
| 363 371 | 
             
                            rescue StandardError => boom
         | 
| 364 372 | 
             
                              log.error("Unable to retrieve events for stream #{stream} "\
         | 
| 365 373 | 
             
                                        "in group #{group}: #{boom.inspect}")
         | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: fluent-plugin-cloudwatch-ingest
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 1.7.0. | 
| 4 | 
            +
              version: 1.7.0.rc4
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Sam Pointer
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: exe
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2018-01 | 
| 11 | 
            +
            date: 2018-02-01 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: bundler
         |