logstash-output-awslogs 1.1.3 → 1.1.4

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: 5d89bf2683352b8d8e1dfb360760e5129db4d0bcfb447bea11101c3dc7648b11
4
+ data.tar.gz: 64e3749306d9da99ff81ca006bfb2e7c34255981b75119ee238d00b149e379f9
5
5
  SHA512:
6
- metadata.gz: 789581c0eff8aaf841a805ffd054733e30cc910897bafc2d245e2cb26ae891e9893ce0e836c709c419c874d5187603a0db6ca7dca96f5236be702f00b02f3e0a
7
- data.tar.gz: f7531d29688b185862a9e4af27bf796ffa21c638d1423fbaa14b9fb24291eaac89bf08239f2109cfea7fe7edfc1ab3b53b769f866f2635a652d8347ca204b197
6
+ metadata.gz: fc23ff3640ec9526027a3a1de59329dc00fedf2722602eca9e71ac4081007ad029e38391fe40a9895821aecd3e0f938c7f4f92c9f3139bee3a6410a640e8fffc
7
+ data.tar.gz: ce9e61a5e8d17bdb8aaa3a61bce0d7510f7547bc01327579263a9494cf110a8646d271d11b087bf915f035aa0de107f1a35eaa798f36306a546b9648ced32427
@@ -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],
@@ -60,16 +65,17 @@ class LogStash::Outputs::Awslogs < LogStash::Outputs::Base
60
65
  end
61
66
  retry
62
67
  end
68
+ rescue Aws::CloudWatchLogs::Errors::LimitExceededException
69
+ @logger.info("AWSLogs: Rate limit exceeded, retrying")
70
+ retry
71
+ end
72
+ @last_flush = Time.now.to_f
63
73
  end
64
74
 
65
75
  private
66
76
  def form_event_batches(events_arr)
67
77
  batches = []
68
78
  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
79
  log_events = events_arr.sort_by { |event| event.timestamp.time.to_f}
74
80
  log_events.each do |event|
75
81
  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.4'
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.4
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-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement