logstash-output-awslogs 1.1.3 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cd6de218003a805ad230d143147375621fbf7bbf803a7739582bf39da44dc228
4
- data.tar.gz: 19a12a32d0a38df507e498783b046f329f727727bef51e770398afaeb1e7f9d8
3
+ metadata.gz: fce690cb9742677ce8bf664f44357992e5b3b15f15cf6b237c1d4e0d8b4d5505
4
+ data.tar.gz: 273a8e3ef5f7aa8ced982880d8ff4da771bae62c6380afb72f71e171b4186897
5
5
  SHA512:
6
- metadata.gz: 789581c0eff8aaf841a805ffd054733e30cc910897bafc2d245e2cb26ae891e9893ce0e836c709c419c874d5187603a0db6ca7dca96f5236be702f00b02f3e0a
7
- data.tar.gz: f7531d29688b185862a9e4af27bf796ffa21c638d1423fbaa14b9fb24291eaac89bf08239f2109cfea7fe7edfc1ab3b53b769f866f2635a652d8347ca204b197
6
+ metadata.gz: b53c48828b60db8020aaf01e1fadc9d9cf21c4f224c1544ad52720f43abfb3b621e6c9fdd6d0b131f8fb7e8549d3c51b9ef183e06ef9bb1782877b7e75268ee1
7
+ data.tar.gz: a7a66252e1ef7fa63848153c322d9bd01123ffc5070da5c910564b9f8c3789547021bb0076e21ecd353a7a0eee1d22bc1420026b3711b57f4099f77243d53d93
@@ -4,6 +4,7 @@ require 'logstash/outputs/base'
4
4
  require 'logstash/namespace'
5
5
  require 'logstash/plugin_mixins/aws_config'
6
6
  require 'aws-sdk-cloudwatchlogs'
7
+ require 'time'
7
8
 
8
9
 
9
10
  class LogStash::Outputs::Awslogs < LogStash::Outputs::Base
@@ -15,6 +16,7 @@ class LogStash::Outputs::Awslogs < LogStash::Outputs::Base
15
16
 
16
17
  PER_EVENT_OVERHEAD = 26
17
18
  MAX_BATCH_SIZE = 1024 * 1024
19
+ MIN_DELAY = 0.2
18
20
 
19
21
  # Log group to send event to
20
22
  config :log_group_name, validate: :string, required: true
@@ -26,6 +28,7 @@ class LogStash::Outputs::Awslogs < LogStash::Outputs::Base
26
28
  public
27
29
  def register
28
30
  @client = Aws::CloudWatchLogs::Client.new(aws_options_hash)
31
+ @last_flush = Time.now.to_f
29
32
  end # def register
30
33
 
31
34
  public
@@ -39,6 +42,8 @@ class LogStash::Outputs::Awslogs < LogStash::Outputs::Base
39
42
  private
40
43
  def put_events(batch)
41
44
  begin
45
+ delay = MIN_DELAY - (Time.now.to_f - @last_flush)
46
+ sleep(delay) if delay > 0
42
47
  @client.put_log_events(
43
48
  {
44
49
  log_group_name: batch[:log_group],
@@ -59,17 +64,17 @@ class LogStash::Outputs::Awslogs < LogStash::Outputs::Base
59
64
  @logger.info("AWSLogs: Log stream #{batch[:log_stream]} already exists")
60
65
  end
61
66
  retry
67
+ rescue Aws::CloudWatchLogs::Errors::LimitExceededException
68
+ @logger.info("AWSLogs: Rate limit exceeded, retrying")
69
+ retry
62
70
  end
71
+ @last_flush = Time.now.to_f
63
72
  end
64
73
 
65
74
  private
66
75
  def form_event_batches(events_arr)
67
76
  batches = []
68
77
  events_by_stream_and_group = {}
69
- # events_by_stream_and_group = {
70
- # ['group','stream'] => [{timestamp => 1, message => "message1"},{timestamp => 2, message => "mesage2"}],
71
- # ['group2','stream2'] => [{timestamp => 3, message => "message3"},{timestamp => 4, message => "message4"}]
72
- # }
73
78
  log_events = events_arr.sort_by { |event| event.timestamp.time.to_f}
74
79
  log_events.each do |event|
75
80
  event_log_stream_name = event.sprintf(log_stream_name)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-output-awslogs'
3
- s.version = '1.1.3'
3
+ s.version = '1.1.5'
4
4
  s.licenses = ['Apache-2.0']
5
5
  s.summary = 'Writes events to AWS CloudWatch logs.'
6
6
  s.homepage = 'https://github.com/Anarhyst266/logstash-output-awslogs'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-output-awslogs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Klyba
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-23 00:00:00.000000000 Z
11
+ date: 2024-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement