fluent-plugin-array-splitter 0.1.2 → 0.1.4

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: 0bf5d03998979b55a12ce89992692bbda3b010bfbccb2b1cf9dbd670a3c63cec
4
- data.tar.gz: 311c9c506b8e7e3b1a48fa77df5e500ac630b7df3797066756beafe985e4468b
3
+ metadata.gz: cf67e2c59a583af70c9b81774c104b80369013106d2157a21f5784d21664e735
4
+ data.tar.gz: 8fa7990b28a24aa91595e21c8920badc08a7a1e9b35cec2679d2bdc43fdd3c2e
5
5
  SHA512:
6
- metadata.gz: 789c595e0ae1f9c8cc14d8668e25dba1984e72f1df6c8c51eb29ecb5299ee2fa3482936e78d9ba28427cf7f25c38dc45a336b26080960934af54b6e0f7ec93e2
7
- data.tar.gz: 00e5532d24f9eb2e2e0ecc7829356daca338f5a26f79deaaccae09ec1414aba3c74fabe65e7f83dfe2daffa8ab0d5645e3bfdae673bab0879106210c56c5a13b
6
+ metadata.gz: 9bc39e54c5b3900801f4e8739f7bbb569024c8cb521445cdc230f41ee51e55a3cea6c3e83536bd74e8b2bba9feacb8f52e43e2a40efc021e8a8a4ba673961a7a
7
+ data.tar.gz: 8c794a899d574885303d49c5d066bc24520114949dd12eda93327b34a0490d8a1b38246c54ec58eb4dad8a742263dab6e396c7ef565ceddcee98d2f4510dedf5
data/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  # fluent-plugin-array-splitter
2
2
 
3
- [Fluentd](https://fluentd.org/) filter plugin to do something.
4
-
5
- TODO: write description for you plugin.
3
+ ## Overview
4
+ This [Fluentd](https://fluentd.org/) filter plugin allows you to split array values within json formatted log records.
6
5
 
7
6
  ## Installation
8
7
 
@@ -28,16 +27,48 @@ $ bundle
28
27
 
29
28
  ## Configuration
30
29
 
31
- You can generate configuration template:
30
+ ### Parameters
31
+
32
+ |parameter|type|description|default|
33
+ |---|---|---|---|
34
+ |array_key|string (required)|The target field name to split array values||
35
+ |key_name|string (optional)|The field name to rename the key of a single array element|nil|
36
+
37
+ ### Example Configuration
38
+
39
+ ```
40
+ <filter pattern>
41
+ @type array_splitter
42
+ array_key message
43
+ key_name new_key
44
+ </filter>
45
+ ```
46
+
47
+ ## Usage
32
48
 
49
+ With the above configuration, an input like:
33
50
  ```
34
- $ fluent-plugin-config-format filter array_splitter
51
+ {"message": ["value1", "value2"]}
35
52
  ```
36
53
 
37
- You can copy and paste generated documents here.
54
+ will result in two records:
55
+ ```
56
+ {"new_key": "value1"}
57
+ {"new_key": "value2"}
58
+ ```
59
+
60
+ If you have an input like:
61
+ ```
62
+ {"message": [{"key1": "value1"}, {"key2": "value2"}]}
63
+ ```
64
+ will result as follows:
65
+ ```
66
+ {"key1": "value1"}
67
+ {"key2": "value2"}
68
+ ```
38
69
 
39
70
  ## Copyright
40
71
 
41
72
  * Copyright(c) 2023- pcoffmanjr
42
73
  * License
43
- *
74
+ * MIT License
@@ -3,14 +3,14 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  Gem::Specification.new do |spec|
5
5
  spec.name = "fluent-plugin-array-splitter"
6
- spec.version = "0.1.2"
6
+ spec.version = "0.1.4"
7
7
  spec.authors = ["pcoffmanjr"]
8
8
  spec.email = ["pcoffman@ctc-america.com"]
9
9
 
10
10
  spec.summary = %q{A Fluentd plugin to split array values into separate records.}
11
11
  spec.description = %q{This Fluentd plugin takes array values from a specified field and creates separate records for each array element.}
12
12
  spec.homepage = "https://github.com/paulcoffmanjr/fluent-plugin-array-splitter"
13
- spec.license = "MIT"
13
+ spec.license = "Apache-2.0"
14
14
 
15
15
  test_files, files = `git ls-files -z`.split("\x0").partition do |f|
16
16
  f.match(%r{^(test|spec|features)/})
@@ -23,5 +23,5 @@ Gem::Specification.new do |spec|
23
23
  spec.add_development_dependency "bundler", "~> 2.1.2"
24
24
  spec.add_development_dependency "rake", "~> 13.0.6"
25
25
  spec.add_development_dependency "test-unit", "~> 3.3.9"
26
- spec.add_runtime_dependency "fluentd", [">= 0.14.10", "< 2"]
26
+ spec.add_runtime_dependency "fluentd", [">= 1.11.1", "< 2"]
27
27
  end
@@ -1,3 +1,20 @@
1
+ # Apache License
2
+ #
3
+ # Version 2.0, January 2004
4
+ #
5
+ # Copyright (c) 2023 pcoffmanjr
6
+ #
7
+ # Licensed under the Apache License, Version 2.0 (the "License");
8
+ # you may not use this file except in compliance with the License.
9
+ # You may obtain a copy of the License at
10
+ #
11
+ # http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
1
18
 
2
19
 
3
20
  require "fluent/plugin/filter"
@@ -10,6 +27,9 @@ module Fluent
10
27
  desc 'The field name to split and expand array values'
11
28
  config_param :array_key, :string, default: 'message'
12
29
 
30
+ desc 'The field name to rename the key of a single array element'
31
+ config_param :key_name, :string, default: nil
32
+
13
33
  def configure(conf)
14
34
  super
15
35
  raise Fluent::ConfigError, "'array_key' parameter is required" unless conf.has_key?('array_key')
@@ -18,27 +38,28 @@ module Fluent
18
38
 
19
39
  def filter_stream(tag, es)
20
40
  new_es = Fluent::MultiEventStream.new
41
+
21
42
  es.each do |time, record|
22
43
  if record[@array_key].is_a?(Array)
23
44
  record[@array_key].each do |value|
24
45
  new_record = record.dup
25
46
  new_record.delete(@array_key)
47
+
26
48
  if value.is_a?(Hash)
27
- value.each do |k, v|
28
- new_record[k] = v
29
- end
49
+ value.each { |k, v| new_record[k] = v }
30
50
  else
31
- new_record[@array_key] = value
51
+ new_record[@key_name.nil? ? @array_key : @key_name] = value
32
52
  end
53
+
33
54
  new_es.add(time, new_record)
34
55
  end
35
56
  else
36
57
  new_es.add(time, record)
37
58
  end
38
59
  end
60
+
39
61
  new_es
40
62
  end
41
63
  end
42
64
  end
43
65
  end
44
-
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-array-splitter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - pcoffmanjr
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-16 00:00:00.000000000 Z
11
+ date: 2023-10-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -58,7 +58,7 @@ dependencies:
58
58
  requirements:
59
59
  - - ">="
60
60
  - !ruby/object:Gem::Version
61
- version: 0.14.10
61
+ version: 1.11.1
62
62
  - - "<"
63
63
  - !ruby/object:Gem::Version
64
64
  version: '2'
@@ -68,7 +68,7 @@ dependencies:
68
68
  requirements:
69
69
  - - ">="
70
70
  - !ruby/object:Gem::Version
71
- version: 0.14.10
71
+ version: 1.11.1
72
72
  - - "<"
73
73
  - !ruby/object:Gem::Version
74
74
  version: '2'
@@ -90,7 +90,7 @@ files:
90
90
  - test/plugin/test_filter_array_splitter.rb
91
91
  homepage: https://github.com/paulcoffmanjr/fluent-plugin-array-splitter
92
92
  licenses:
93
- - MIT
93
+ - Apache-2.0
94
94
  metadata: {}
95
95
  post_install_message:
96
96
  rdoc_options: []