logstash-input-s3 3.6.0 → 3.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/docs/index.asciidoc +34 -6
- data/lib/logstash/inputs/s3.rb +12 -4
- data/logstash-input-s3.gemspec +2 -1
- data/spec/inputs/s3_spec.rb +14 -5
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0b5ad2fe42e0003da67ebb3e1aad774f5bab3cb2afc07e4699fbfa5e84c0d472
|
4
|
+
data.tar.gz: fb8691a6276181e17a2c80319247d04f11c8d547affff1b109f5447547eca4be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3782d59c63fe4e53cb01dff9c7a431773fc69126dfc17c90ea45b8018205897dfabd8d942a732c37cb1740a4c924608110e81955205734523a9f5d1a928bed5d
|
7
|
+
data.tar.gz: 3ff5255afa6d8a978a2231bc69a3c11dd9f354a90895e779be569971aaa75c34c456d35b979effbb0304801160cb15ce5f81b5967e121133d79e0a48f59638b7
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## 3.7.0
|
2
|
+
- Add ECS support. [#228](https://github.com/logstash-plugins/logstash-input-s3/pull/228)
|
3
|
+
- Fix missing file in cutoff time change. [#224](https://github.com/logstash-plugins/logstash-input-s3/pull/224)
|
4
|
+
|
1
5
|
## 3.6.0
|
2
6
|
- Fixed unprocessed file with the same `last_modified` in ingestion. [#220](https://github.com/logstash-plugins/logstash-input-s3/pull/220)
|
3
7
|
|
data/docs/index.asciidoc
CHANGED
@@ -31,6 +31,21 @@ Files ending in `.gz` are handled as gzip'ed files.
|
|
31
31
|
|
32
32
|
Files that are archived to AWS Glacier will be skipped.
|
33
33
|
|
34
|
+
[id="plugins-{type}s-{plugin}-ecs_metadata"]
|
35
|
+
==== Event Metadata and the Elastic Common Schema (ECS)
|
36
|
+
This plugin adds cloudfront metadata to event.
|
37
|
+
When ECS compatibility is disabled, the value is stored in the root level.
|
38
|
+
When ECS is enabled, the value is stored in the `@metadata` where it can be used by other plugins in your pipeline.
|
39
|
+
|
40
|
+
Here’s how ECS compatibility mode affects output.
|
41
|
+
[cols="<l,<l,e,<e"]
|
42
|
+
|=======================================================================
|
43
|
+
| ECS disabled | ECS v1 | Availability | Description
|
44
|
+
|
45
|
+
| cloudfront_fields | [@metadata][s3][cloudfront][fields] | available when the file is a CloudFront log | column names of log
|
46
|
+
| cloudfront_version | [@metadata][s3][cloudfront][version] | available when the file is a CloudFront log | version of log
|
47
|
+
|=======================================================================
|
48
|
+
|
34
49
|
[id="plugins-{type}s-{plugin}-options"]
|
35
50
|
==== S3 Input Configuration Options
|
36
51
|
|
@@ -47,6 +62,7 @@ This plugin supports the following configuration options plus the <<plugins-{typ
|
|
47
62
|
| <<plugins-{type}s-{plugin}-backup_to_dir>> |<<string,string>>|No
|
48
63
|
| <<plugins-{type}s-{plugin}-bucket>> |<<string,string>>|Yes
|
49
64
|
| <<plugins-{type}s-{plugin}-delete>> |<<boolean,boolean>>|No
|
65
|
+
| <<plugins-{type}s-{plugin}-ecs_compatibility>> |<<string,string>>|No
|
50
66
|
| <<plugins-{type}s-{plugin}-endpoint>> |<<string,string>>|No
|
51
67
|
| <<plugins-{type}s-{plugin}-exclude_pattern>> |<<string,string>>|No
|
52
68
|
| <<plugins-{type}s-{plugin}-gzip_pattern>> |<<string,string>>|No
|
@@ -96,12 +112,12 @@ the connection to s3. See full list in https://docs.aws.amazon.com/sdkforruby/ap
|
|
96
112
|
[source,ruby]
|
97
113
|
input {
|
98
114
|
s3 {
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
115
|
+
access_key_id => "1234"
|
116
|
+
secret_access_key => "secret"
|
117
|
+
bucket => "logstash-test"
|
118
|
+
additional_settings => {
|
119
|
+
force_path_style => true
|
120
|
+
follow_redirects => false
|
105
121
|
}
|
106
122
|
}
|
107
123
|
}
|
@@ -167,6 +183,18 @@ The name of the S3 bucket.
|
|
167
183
|
|
168
184
|
Whether to delete processed files from the original bucket.
|
169
185
|
|
186
|
+
[id="plugins-{type}s-{plugin}-ecs_compatibility"]
|
187
|
+
===== `ecs_compatibility`
|
188
|
+
|
189
|
+
* Value type is <<string,string>>
|
190
|
+
* Supported values are:
|
191
|
+
** `disabled`: does not use ECS-compatible field names
|
192
|
+
** `v1`: uses metadata fields that are compatible with Elastic Common Schema
|
193
|
+
|
194
|
+
Controls this plugin's compatibility with the
|
195
|
+
{ecs-ref}[Elastic Common Schema (ECS)].
|
196
|
+
See <<plugins-{type}s-{plugin}-ecs_metadata>> for detailed information.
|
197
|
+
|
170
198
|
[id="plugins-{type}s-{plugin}-endpoint"]
|
171
199
|
===== `endpoint`
|
172
200
|
|
data/lib/logstash/inputs/s3.rb
CHANGED
@@ -9,6 +9,7 @@ require "stud/interval"
|
|
9
9
|
require "stud/temporary"
|
10
10
|
require "aws-sdk"
|
11
11
|
require "logstash/inputs/s3/patch"
|
12
|
+
require "logstash/plugin_mixins/ecs_compatibility_support"
|
12
13
|
|
13
14
|
require 'java'
|
14
15
|
|
@@ -27,6 +28,7 @@ class LogStash::Inputs::S3 < LogStash::Inputs::Base
|
|
27
28
|
java_import java.util.zip.ZipException
|
28
29
|
|
29
30
|
include LogStash::PluginMixins::AwsConfig::V2
|
31
|
+
include LogStash::PluginMixins::ECSCompatibilitySupport(:disabled, :v1)
|
30
32
|
|
31
33
|
config_name "s3"
|
32
34
|
|
@@ -88,6 +90,12 @@ class LogStash::Inputs::S3 < LogStash::Inputs::Base
|
|
88
90
|
|
89
91
|
CUTOFF_SECOND = 3
|
90
92
|
|
93
|
+
def initialize(*params)
|
94
|
+
super
|
95
|
+
@cloudfront_fields_key = ecs_select[disabled: 'cloudfront_fields', v1: '[@metadata][s3][cloudfront][fields]']
|
96
|
+
@cloudfront_version_key = ecs_select[disabled: 'cloudfront_version', v1: '[@metadata][s3][cloudfront][version]']
|
97
|
+
end
|
98
|
+
|
91
99
|
def register
|
92
100
|
require "fileutils"
|
93
101
|
require "digest/md5"
|
@@ -130,6 +138,7 @@ class LogStash::Inputs::S3 < LogStash::Inputs::Base
|
|
130
138
|
def list_new_files
|
131
139
|
objects = []
|
132
140
|
found = false
|
141
|
+
current_time = Time.now
|
133
142
|
begin
|
134
143
|
@s3bucket.objects(:prefix => @prefix).each do |log|
|
135
144
|
found = true
|
@@ -140,7 +149,7 @@ class LogStash::Inputs::S3 < LogStash::Inputs::Base
|
|
140
149
|
@logger.debug('Object Zero Length', :key => log.key)
|
141
150
|
elsif !sincedb.newer?(log.last_modified)
|
142
151
|
@logger.debug('Object Not Modified', :key => log.key)
|
143
|
-
elsif log.last_modified > (
|
152
|
+
elsif log.last_modified > (current_time - CUTOFF_SECOND).utc # file modified within last two seconds will be processed in next cycle
|
144
153
|
@logger.debug('Object Modified After Cutoff Time', :key => log.key)
|
145
154
|
elsif (log.storage_class == 'GLACIER' || log.storage_class == 'DEEP_ARCHIVE') && !file_restored?(log.object)
|
146
155
|
@logger.debug('Object Archived to Glacier', :key => log.key)
|
@@ -227,9 +236,6 @@ class LogStash::Inputs::S3 < LogStash::Inputs::Base
|
|
227
236
|
else
|
228
237
|
decorate(event)
|
229
238
|
|
230
|
-
event.set("cloudfront_version", metadata[:cloudfront_version]) unless metadata[:cloudfront_version].nil?
|
231
|
-
event.set("cloudfront_fields", metadata[:cloudfront_fields]) unless metadata[:cloudfront_fields].nil?
|
232
|
-
|
233
239
|
if @include_object_properties
|
234
240
|
event.set("[@metadata][s3]", object.data.to_h)
|
235
241
|
else
|
@@ -237,6 +243,8 @@ class LogStash::Inputs::S3 < LogStash::Inputs::Base
|
|
237
243
|
end
|
238
244
|
|
239
245
|
event.set("[@metadata][s3][key]", object.key)
|
246
|
+
event.set(@cloudfront_version_key, metadata[:cloudfront_version]) unless metadata[:cloudfront_version].nil?
|
247
|
+
event.set(@cloudfront_fields_key, metadata[:cloudfront_fields]) unless metadata[:cloudfront_fields].nil?
|
240
248
|
|
241
249
|
queue << event
|
242
250
|
end
|
data/logstash-input-s3.gemspec
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
|
3
3
|
s.name = 'logstash-input-s3'
|
4
|
-
s.version = '3.
|
4
|
+
s.version = '3.7.0'
|
5
5
|
s.licenses = ['Apache-2.0']
|
6
6
|
s.summary = "Streams events from files in a S3 bucket"
|
7
7
|
s.description = "This gem is a Logstash plugin required to be installed on top of the Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This gem is not a stand-alone program"
|
@@ -27,4 +27,5 @@ Gem::Specification.new do |s|
|
|
27
27
|
s.add_development_dependency 'logstash-devutils'
|
28
28
|
s.add_development_dependency "logstash-codec-json"
|
29
29
|
s.add_development_dependency "logstash-codec-multiline"
|
30
|
+
s.add_runtime_dependency 'logstash-mixin-ecs_compatibility_support', '~>1.1'
|
30
31
|
end
|
data/spec/inputs/s3_spec.rb
CHANGED
@@ -9,6 +9,7 @@ require_relative "../support/helpers"
|
|
9
9
|
require "stud/temporary"
|
10
10
|
require "aws-sdk"
|
11
11
|
require "fileutils"
|
12
|
+
require 'logstash/plugin_mixins/ecs_compatibility_support/spec_helper'
|
12
13
|
|
13
14
|
describe LogStash::Inputs::S3 do
|
14
15
|
let(:temporary_directory) { Stud::Temporary.pathname }
|
@@ -494,12 +495,20 @@ describe LogStash::Inputs::S3 do
|
|
494
495
|
context 'cloudfront' do
|
495
496
|
let(:log_file) { File.join(File.dirname(__FILE__), '..', 'fixtures', 'cloudfront.log') }
|
496
497
|
|
497
|
-
|
498
|
-
|
498
|
+
describe "metadata", :ecs_compatibility_support, :aggregate_failures do
|
499
|
+
ecs_compatibility_matrix(:disabled, :v1) do |ecs_select|
|
500
|
+
before(:each) do
|
501
|
+
allow_any_instance_of(described_class).to receive(:ecs_compatibility).and_return(ecs_compatibility)
|
502
|
+
end
|
499
503
|
|
500
|
-
|
501
|
-
|
502
|
-
|
504
|
+
it 'should extract metadata from cloudfront log' do
|
505
|
+
events = fetch_events(config)
|
506
|
+
|
507
|
+
events.each do |event|
|
508
|
+
expect(event.get ecs_select[disabled: "cloudfront_fields", v1: "[@metadata][s3][cloudfront][fields]"] ).to eq('date time x-edge-location c-ip x-event sc-bytes x-cf-status x-cf-client-id cs-uri-stem cs-uri-query c-referrer x-page-url c-user-agent x-sname x-sname-query x-file-ext x-sid')
|
509
|
+
expect(event.get ecs_select[disabled: "cloudfront_version", v1: "[@metadata][s3][cloudfront][version]"] ).to eq('1.0')
|
510
|
+
end
|
511
|
+
end
|
503
512
|
end
|
504
513
|
end
|
505
514
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: logstash-input-s3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Elastic
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,6 +100,20 @@ dependencies:
|
|
100
100
|
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
102
|
version: '0'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
requirement: !ruby/object:Gem::Requirement
|
105
|
+
requirements:
|
106
|
+
- - "~>"
|
107
|
+
- !ruby/object:Gem::Version
|
108
|
+
version: '1.1'
|
109
|
+
name: logstash-mixin-ecs_compatibility_support
|
110
|
+
prerelease: false
|
111
|
+
type: :runtime
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '1.1'
|
103
117
|
description: This gem is a Logstash plugin required to be installed on top of the
|
104
118
|
Logstash core pipeline using $LS_HOME/bin/logstash-plugin install gemname. This
|
105
119
|
gem is not a stand-alone program
|