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 +4 -4
- data/lib/logstash/outputs/awslogs.rb +9 -4
- data/logstash-output-awslogs.gemspec +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fce690cb9742677ce8bf664f44357992e5b3b15f15cf6b237c1d4e0d8b4d5505
|
4
|
+
data.tar.gz: 273a8e3ef5f7aa8ced982880d8ff4da771bae62c6380afb72f71e171b4186897
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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)
|
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.
|
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:
|
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
|