logstash-filter-kv 4.4.1 → 4.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9f997d5d9787b39b3ffbb7f27130fbef6137ebf0f03ec65202795c47be856032
4
- data.tar.gz: 20864a2cb4f477591f010e1e7bdc682db38615dedd76fb8d1e6d961c784dec9a
3
+ metadata.gz: dba46789cadec9a5f93b5e2922cc6ba05c1fd70100973733e6bbe3960b44512f
4
+ data.tar.gz: f806099e1d9cb3ee841c856023960f78d3b3799cc1490d09d366596f9ed42c23
5
5
  SHA512:
6
- metadata.gz: e866ec418609a22c5365d737f0b3714a650b1d2a8538b9d59b709f4661ccf4af6e6a3a0a58eead83f6fa2dfa1596885c2ee642b6d1ac2a52005512d7a568c197
7
- data.tar.gz: d101397b3fa8a9f488e56c87532ccf71d8c683344a7cf27d5befa7dcfcc5c3ea6299816648ef47c22ee248b9fecc989136c24193e122b577a165cfa0fe3fa662
6
+ metadata.gz: 4dcb8c1bc3d8edc6ac19fffc9b89a0954d7fed9ffba37f21c95e688c81100566daf04fb66f6666f58ac4a338f3611afd5bfee4d02969947dc3d8fbb86e241420
7
+ data.tar.gz: 7e91c74720fc32407c2acac971d881fd03950e138ec4b0e76c67ca7087397d29ce7a4570299971cd3ec86b0234685fc87a60a7f5a14d696c6c9fa6412010a9cb
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## 4.5.0
2
+ - Feat: check that target is set in ECS mode [#96](https://github.com/logstash-plugins/logstash-filter-kv/pull/96)
3
+
1
4
  ## 4.4.1
2
5
  - Fixed issue where a `field_split_pattern` containing a literal backslash failed to match correctly [#87](https://github.com/logstash-plugins/logstash-filter-kv/issues/87)
3
6
 
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Logstash Plugin
2
2
 
3
- [![Travis Build Status](https://travis-ci.org/logstash-plugins/logstash-filter-kv.svg)](https://travis-ci.org/logstash-plugins/logstash-filter-kv)
3
+ [![Travis Build Status](https://travis-ci.com/logstash-plugins/logstash-filter-kv.svg)](https://travis-ci.com/logstash-plugins/logstash-filter-kv)
4
4
 
5
5
  This is a plugin for [Logstash](https://github.com/elastic/logstash).
6
6
 
data/docs/index.asciidoc CHANGED
@@ -44,6 +44,13 @@ in case your data is not structured using `=` signs and whitespace.
44
44
  For example, this filter can also be used to parse query parameters like
45
45
  `foo=bar&baz=fizz` by setting the `field_split` parameter to `&`.
46
46
 
47
+ [id="plugins-{type}s-{plugin}-ecs_metadata"]
48
+ ==== Event Metadata and the Elastic Common Schema (ECS)
49
+
50
+ The plugin behaves the same regardless of ECS compatibility, except giving a warning when ECS is enabled and `target` isn't set.
51
+
52
+ TIP: Set the `target` option to avoid potential schema conflicts.
53
+
47
54
  [id="plugins-{type}s-{plugin}-options"]
48
55
  ==== Kv Filter Configuration Options
49
56
 
@@ -54,6 +61,7 @@ This plugin supports the following configuration options plus the <<plugins-{typ
54
61
  |Setting |Input type|Required
55
62
  | <<plugins-{type}s-{plugin}-allow_duplicate_values>> |<<boolean,boolean>>|No
56
63
  | <<plugins-{type}s-{plugin}-default_keys>> |<<hash,hash>>|No
64
+ | <<plugins-{type}s-{plugin}-ecs_compatibility>> | <<string,string>>|No
57
65
  | <<plugins-{type}s-{plugin}-exclude_keys>> |<<array,array>>|No
58
66
  | <<plugins-{type}s-{plugin}-field_split>> |<<string,string>>|No
59
67
  | <<plugins-{type}s-{plugin}-field_split_pattern>> |<<string,string>>|No
@@ -117,6 +125,17 @@ in case these keys do not exist in the source field being parsed.
117
125
  }
118
126
  }
119
127
 
128
+ [id="plugins-{type}s-{plugin}-ecs_compatibility"]
129
+ ===== `ecs_compatibility`
130
+
131
+ * Value type is <<string,string>>
132
+ * Supported values are:
133
+ ** `disabled`: does not use ECS-compatible field names
134
+ ** `v1`: Elastic Common Schema compliant behavior (warns when `target` isn't set)
135
+
136
+ Controls this plugin's compatibility with the {ecs-ref}[Elastic Common Schema (ECS)].
137
+ See <<plugins-{type}s-{plugin}-ecs_metadata>> for detailed information.
138
+
120
139
  [id="plugins-{type}s-{plugin}-exclude_keys"]
121
140
  ===== `exclude_keys`
122
141
 
@@ -2,6 +2,9 @@
2
2
 
3
3
  require "logstash/filters/base"
4
4
  require "logstash/namespace"
5
+ require 'logstash/plugin_mixins/ecs_compatibility_support'
6
+ require 'logstash/plugin_mixins/ecs_compatibility_support/target_check'
7
+ require 'logstash/plugin_mixins/validator_support/field_reference_validation_adapter'
5
8
  require "timeout"
6
9
 
7
10
  # This filter helps automatically parse messages (or specific event fields)
@@ -30,6 +33,11 @@ require "timeout"
30
33
  class LogStash::Filters::KV < LogStash::Filters::Base
31
34
  config_name "kv"
32
35
 
36
+ include LogStash::PluginMixins::ECSCompatibilitySupport
37
+ include LogStash::PluginMixins::ECSCompatibilitySupport::TargetCheck
38
+
39
+ extend LogStash::PluginMixins::ValidatorSupport::FieldReferenceValidationAdapter
40
+
33
41
  # Constants used for transform check
34
42
  TRANSFORM_LOWERCASE_KEY = "lowercase"
35
43
  TRANSFORM_UPPERCASE_KEY = "uppercase"
@@ -201,7 +209,7 @@ class LogStash::Filters::KV < LogStash::Filters::Base
201
209
  # For example, to process the `not_the_message` field:
202
210
  # [source,ruby]
203
211
  # filter { kv { source => "not_the_message" } }
204
- config :source, :validate => :string, :default => "message"
212
+ config :source, :validate => :field_reference, :default => "message"
205
213
 
206
214
  # The name of the container to put all of the key-value pairs into.
207
215
  #
@@ -211,7 +219,7 @@ class LogStash::Filters::KV < LogStash::Filters::Base
211
219
  # For example, to place all keys into the event field kv:
212
220
  # [source,ruby]
213
221
  # filter { kv { target => "kv" } }
214
- config :target, :validate => :string
222
+ config :target, :validate => :field_reference
215
223
 
216
224
  # An array specifying the parsed keys which should be added to the event.
217
225
  # By default all keys will be added.
@@ -429,7 +437,9 @@ class LogStash::Filters::KV < LogStash::Filters::Base
429
437
  return if kv.empty?
430
438
 
431
439
  if @target
432
- @logger.debug? && @logger.debug("Overwriting existing target field", :target => @target)
440
+ if event.include?(@target)
441
+ @logger.debug? && @logger.debug("Overwriting existing target field", field: @target, existing_value: event.get(@target))
442
+ end
433
443
  event.set(@target, kv)
434
444
  else
435
445
  kv.each{|k, v| event.set(k, v)}
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
 
3
3
  s.name = 'logstash-filter-kv'
4
- s.version = '4.4.1'
4
+ s.version = '4.5.0'
5
5
  s.licenses = ['Apache License (2.0)']
6
6
  s.summary = "Parses key-value pairs"
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"
@@ -21,6 +21,8 @@ Gem::Specification.new do |s|
21
21
 
22
22
  # Gem dependencies
23
23
  s.add_runtime_dependency "logstash-core-plugin-api", ">= 1.60", "<= 2.99"
24
+ s.add_runtime_dependency 'logstash-mixin-ecs_compatibility_support', '~> 1.3'
25
+ s.add_runtime_dependency 'logstash-mixin-validator_support', '~> 1.0'
24
26
 
25
27
  s.add_development_dependency 'logstash-devutils'
26
28
  s.add_development_dependency 'insist'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: logstash-filter-kv
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.4.1
4
+ version: 4.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elastic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-03 00:00:00.000000000 Z
11
+ date: 2021-07-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement
@@ -20,8 +20,8 @@ dependencies:
20
20
  - !ruby/object:Gem::Version
21
21
  version: '2.99'
22
22
  name: logstash-core-plugin-api
23
- prerelease: false
24
23
  type: :runtime
24
+ prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
27
  - - ">="
@@ -30,6 +30,34 @@ dependencies:
30
30
  - - "<="
31
31
  - !ruby/object:Gem::Version
32
32
  version: '2.99'
33
+ - !ruby/object:Gem::Dependency
34
+ requirement: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - "~>"
37
+ - !ruby/object:Gem::Version
38
+ version: '1.3'
39
+ name: logstash-mixin-ecs_compatibility_support
40
+ type: :runtime
41
+ prerelease: false
42
+ version_requirements: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.3'
47
+ - !ruby/object:Gem::Dependency
48
+ requirement: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - "~>"
51
+ - !ruby/object:Gem::Version
52
+ version: '1.0'
53
+ name: logstash-mixin-validator_support
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: '1.0'
33
61
  - !ruby/object:Gem::Dependency
34
62
  requirement: !ruby/object:Gem::Requirement
35
63
  requirements:
@@ -37,8 +65,8 @@ dependencies:
37
65
  - !ruby/object:Gem::Version
38
66
  version: '0'
39
67
  name: logstash-devutils
40
- prerelease: false
41
68
  type: :development
69
+ prerelease: false
42
70
  version_requirements: !ruby/object:Gem::Requirement
43
71
  requirements:
44
72
  - - ">="
@@ -51,8 +79,8 @@ dependencies:
51
79
  - !ruby/object:Gem::Version
52
80
  version: '0'
53
81
  name: insist
54
- prerelease: false
55
82
  type: :development
83
+ prerelease: false
56
84
  version_requirements: !ruby/object:Gem::Requirement
57
85
  requirements:
58
86
  - - ">="
@@ -97,8 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
125
  - !ruby/object:Gem::Version
98
126
  version: '0'
99
127
  requirements: []
100
- rubyforge_project:
101
- rubygems_version: 2.6.13
128
+ rubygems_version: 3.0.6
102
129
  signing_key:
103
130
  specification_version: 4
104
131
  summary: Parses key-value pairs