Skip to content

Commit 4e1a2a7

Browse files
authored
ecs: add v8 alias to v1 implementation (#429)
* ecs: add v8 alias to v1 implementation * use event factory
1 parent 150f75a commit 4e1a2a7

10 files changed

+22
-7
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
## 6.2.0
2+
- ECS compatibility enablement: Adds alias to support upcoming ECS v8 with the existing ECS v1 implementation
3+
14
## 6.1.7
25
- [DOC] Remove limitations topic and link [#428](https://github.com/logstash-plugins/logstash-input-http/pull/428)
36

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
6.1.7
1+
6.2.0

docs/index.asciidoc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,11 @@ output.
141141

142142
[cols="<l,<l,e,<e"]
143143
|=======================================================================
144-
|ECS disabled |ECS v1 |Availability |Description
144+
|ECS `disabled` |ECS `v1`, `v8` |Availability |Description
145145

146146
|[host] |[@metadata][input][beats][host][name] |Always |Name or address of the {plugin-singular} host
147147
|[@metadata][ip_address] |[@metadata][input][beats][host][ip] |Always |IP address of the {plugin-uc} client
148-
|[@metadata][tls_peer][status] | [@metadata][tls_peer][status] | When SSL related fields are populated | Contains "verified"/"unverified" labels in `disabled`, `true`/`false` in `v1`
148+
|[@metadata][tls_peer][status] | [@metadata][tls_peer][status] | When SSL related fields are populated | Contains "verified"/"unverified" labels in `disabled`, `true`/`false` in `v1`/`v8`
149149
|[@metadata][tls_peer][protocol] | [@metadata][input][beats][tls][version_protocol] | When SSL status is "verified" | Contains the TLS version used (e.g. `TLSv1.2`)
150150
|[@metadata][tls_peer][subject] | [@metadata][input][beats][tls][client][subject] | When SSL status is "verified" | Contains the identity name of the remote end (e.g. `CN=artifacts-no-kpi.elastic.co`)
151151
|[@metadata][tls_peer][cipher_suite] | [@metadata][input][beats][tls][cipher] | When SSL status is "verified" | Contains the name of cipher suite used (e.g. `TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256`)
@@ -216,7 +216,8 @@ Close Idle clients after X seconds of inactivity.
216216
* Value type is <<string,string>>
217217
* Supported values are:
218218
** `disabled`: unstructured connection metadata added at root level
219-
** `v1`: structured connection metadata added under ECS compliant namespaces
219+
** `v1`: structured connection metadata added under ECS v1 compliant namespaces
220+
** `v8`: structured connection metadata added under ECS v8 compliant namespaces
220221
* Default value depends on which version of Logstash is running:
221222
** When Logstash provides a `pipeline.ecs_compatibility` setting, its value is used as the default
222223
** Otherwise, the default value is `disabled`.

lib/logstash/inputs/beats.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
require "logstash/util"
77
require "logstash-input-beats_jars"
88
require "logstash/plugin_mixins/ecs_compatibility_support"
9+
require 'logstash/plugin_mixins/event_support/event_factory_adapter'
910
require_relative "beats/patch"
1011

1112
# This input plugin enables Logstash to receive events from the
@@ -51,7 +52,9 @@ class LogStash::Inputs::Beats < LogStash::Inputs::Base
5152
require "logstash/inputs/beats/tls"
5253

5354
# adds ecs_compatibility config which could be :disabled or :v1
54-
include LogStash::PluginMixins::ECSCompatibilitySupport(:disabled,:v1)
55+
include LogStash::PluginMixins::ECSCompatibilitySupport(:disabled,:v1, :v8 => :v1)
56+
57+
include LogStash::PluginMixins::EventSupport::EventFactoryAdapter
5558

5659
config_name "beats"
5760

lib/logstash/inputs/beats/message_listener.rb

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class MessageListener
1515

1616
attr_reader :logger, :input, :connections_list
1717

18+
attr_reader :event_factory
19+
1820
def initialize(queue, input)
1921
@connections_list = ThreadSafe::Hash.new
2022
@queue = queue
@@ -25,6 +27,7 @@ def initialize(queue, input)
2527

2628
@nocodec_transformer = RawEventTransform.new(@input)
2729
@codec_transformer = DecodedEventTransform.new(@input)
30+
@event_factory = input.event_factory
2831
end
2932

3033
def onNewMessage(ctx, message)
@@ -39,7 +42,7 @@ def onNewMessage(ctx, message)
3942
extract_tls_peer(hash, ctx)
4043

4144
if target_field.nil?
42-
event = LogStash::Event.new(hash)
45+
event = event_factory.new_event(hash)
4346
@nocodec_transformer.transform(event)
4447
@queue << event
4548
else

logstash-input-beats.gemspec

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ Gem::Specification.new do |s|
2727
s.add_runtime_dependency "thread_safe", "~> 0.3.5"
2828
s.add_runtime_dependency "logstash-codec-multiline", ">= 2.0.5"
2929
s.add_runtime_dependency 'jar-dependencies', '~> 0.3', '>= 0.3.4'
30-
s.add_runtime_dependency 'logstash-mixin-ecs_compatibility_support', '~>1.1'
30+
s.add_runtime_dependency 'logstash-mixin-ecs_compatibility_support', '~>1.3'
31+
s.add_runtime_dependency 'logstash-mixin-event_support', '~>1.0'
3132

3233
s.add_development_dependency "flores", "~>0.0.6"
3334
s.add_development_dependency "rspec"

spec/inputs/beats/decoded_event_transform_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
include_examples "Common Event Transformation", :disabled, "host"
3333
include_examples "Common Event Transformation", :v1, "[@metadata][input][beats][host][name]"
34+
include_examples "Common Event Transformation", :v8, "[@metadata][input][beats][host][name]"
3435

3536
it "tags the event" do
3637
expect(subject.get("tags")).to include("beats_input_codec_plain_applied")

spec/inputs/beats/event_transform_common_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@
99

1010
include_examples "Common Event Transformation", :disabled, "host"
1111
include_examples "Common Event Transformation", :v1, "[@metadata][input][beats][host][name]"
12+
include_examples "Common Event Transformation", :v8, "[@metadata][input][beats][host][name]"
1213
end

spec/inputs/beats/message_listener_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,7 @@ def flush(&block)
211211

212212
it_behaves_like "when the message is from any libbeat", :disabled, "[@metadata][ip_address]"
213213
it_behaves_like "when the message is from any libbeat", :v1, "[@metadata][input][beats][host][ip]"
214+
it_behaves_like "when the message is from any libbeat", :v8, "[@metadata][input][beats][host][ip]"
214215
end
215216

216217
context "onException" do

spec/inputs/beats/raw_event_transform_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
include_examples "Common Event Transformation", :disabled, "host"
2222
include_examples "Common Event Transformation", :v1, "[@metadata][input][beats][host][name]"
23+
include_examples "Common Event Transformation", :v8, "[@metadata][input][beats][host][name]"
2324

2425
it "tags the event" do
2526
expect(subject.get("tags")).to include("beats_input_raw_event")

0 commit comments

Comments
 (0)