logstash-output-awslogs 0.1.20 → 0.1.25

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: a17afa9328ef3d785b0ff6cbd00b60db09fa3f64f8dec15c93b587b00ff8bad7
4
- data.tar.gz: e343fe4e97dfe5ea2dbd7c4949be7e8d5b59a6880249c7a21fa8f3409aadfbc7
3
+ metadata.gz: af5368bbf48b36f76d7efd64b8e45ded1ab26ab9f78c3a1ea49dcd624a7d7b8c
4
+ data.tar.gz: 4c24673badededf455e7fb09f3751e61fb30e8ad057855f345f4f3475803dfba
5
5
  SHA512:
6
- metadata.gz: 64487c9cb52c41e5ca319f1fac727ebda10c30118d6ba6009db4b3f33d1ace0965e669c5d7080d978d5a63f1682ebdec04362def17749b6d3c4549f3af58dd89
7
- data.tar.gz: f377fb99c2c526528d64298ce7841f9b84d8c6df1a30b4f8b7534dd65861b57e944f8ff66f9bb56f9e9198cc015ee988f7183581862816146cc73f343801e8c1
6
+ metadata.gz: 4656350c7598bbf7834fff235c6b9a1cfcb8ebb526a24bf6660b8044fe3e5f958b452707dc37114f735b9ebcebd0ea51364deecb20d7b69a35a4ae102b889d84
7
+ data.tar.gz: 8fd394e3b07729b16daaa3bafaa9626c2c184c5644b68587141a805b73c5d31182ee0a4b138a2e419e192c6e992bb8d5fd6094e80822baf1ed3a59a969ba6971
@@ -30,7 +30,7 @@ class LogStash::Outputs::Awslogs < LogStash::Outputs::Base
30
30
  to_send = {}
31
31
  sequence_tokens = {}
32
32
 
33
- events_and_encoded.each do |event, _encoded|
33
+ events_and_encoded.each do |event, encoded|
34
34
  event_log_stream_name = event.sprintf(log_stream_name)
35
35
  event_log_group_name = event.sprintf(log_group_name)
36
36
 
@@ -38,31 +38,48 @@ class LogStash::Outputs::Awslogs < LogStash::Outputs::Base
38
38
  unless to_send.keys.include? next_sequence_token_key
39
39
  to_send.store(next_sequence_token_key, [])
40
40
  end
41
- to_send[next_sequence_token_key].push(
42
- timestamp: (event.timestamp.time.to_f * 1000).to_int,
43
- message: event.get('message')
44
- )
41
+ if event.get('message') && !event.get('message').empty?
42
+ to_send[next_sequence_token_key].push(
43
+ timestamp: (event.timestamp.time.to_f * 1000).to_int,
44
+ message: event.get('message')
45
+ )
46
+ else
47
+ to_send[next_sequence_token_key].push(
48
+ timestamp: (event.timestamp.time.to_f * 1000).to_int,
49
+ message: encoded
50
+ )
51
+ end
45
52
  end
46
53
 
54
+ group_names = []
47
55
  to_send.each do |event_log_names, _events|
48
56
  event_log_group_name = event_log_names[0]
49
- next if sequence_tokens.keys.include? event_log_group_name
57
+ event_log_stream_name = event_log_names[1]
58
+ next_sequence_token_key = [event_log_group_name, event_log_stream_name]
59
+ next if @next_sequence_tokens.keys.include? next_sequence_token_key
60
+ unless group_names.include? event_log_group_name
61
+ group_names.push(event_log_group_name)
62
+ end
63
+ end
50
64
 
51
- sequence_tokens.store(event_log_group_name, {})
65
+ group_names.each do |log_group_name|
66
+ unless sequence_tokens.keys.include? log_group_name
67
+ sequence_tokens.store(log_group_name, {})
68
+ end
52
69
  begin
53
- @client.describe_log_streams({log_group_name: event_log_group_name}).each do |response|
70
+ @client.describe_log_streams({log_group_name: log_group_name}).each do |response|
54
71
  response.log_streams.each do |log_stream_data|
55
72
  unless log_stream_data.upload_sequence_token&.empty?
56
- sequence_tokens[event_log_group_name][log_stream_data.log_stream_name.to_s] = log_stream_data.upload_sequence_token.to_s
73
+ sequence_tokens[log_group_name][log_stream_data.log_stream_name.to_s] = log_stream_data.upload_sequence_token.to_s
57
74
  end
58
75
  end
59
76
  end
60
77
  rescue Aws::CloudWatchLogs::Errors::ResourceNotFoundException => e
61
- @logger.info('Will create log group/stream and retry')
78
+ @logger.info("Will create log group #{log_group_name} and retry")
62
79
  begin
63
- @client.create_log_group({log_group_name: event_log_group_name})
80
+ @client.create_log_group({log_group_name: log_group_name})
64
81
  rescue Aws::CloudWatchLogs::Errors::ResourceAlreadyExistsException => e
65
- @logger.info("Log group #{event_log_group_name} already exists")
82
+ @logger.info("Log group #{log_group_name} already exists")
66
83
  end
67
84
  retry
68
85
  rescue Aws::CloudWatchLogs::Errors::ThrottlingException => e
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'logstash-output-awslogs'
3
- s.version = '0.1.20'
3
+ s.version = '0.1.25'
4
4
  s.licenses = ['Apache-2.0']
5
5
  s.summary = 'Writes events to AWS CloudWatch logs.'
6
6
  s.homepage = 'https://github.com/rickycook/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: 0.1.20
4
+ version: 0.1.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anton Klyba
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-17 00:00:00.000000000 Z
11
+ date: 2020-06-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement