fluent-plugin-record_indexing 0.2.0 → 0.2.1

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: 033425b882af2c7a8cfc88fcf822fe582214eeab990b07fd1dbe31c12df8f5ac
4
- data.tar.gz: 2368227e5bf02a0c86c9b21a5f6ed4b6f8f9ebec9b2722b9fc03903263c4cce7
3
+ metadata.gz: 55b3c230a4fe0c5c4a6dd0b914c2728d1cd91e84c9702689628388278cba45dd
4
+ data.tar.gz: 818543e3a427d6e14a6a7acea3753b0bbe94117df54951dcfe53ebfbbd09a4bf
5
5
  SHA512:
6
- metadata.gz: 0e046669d2eb9fbfbd0c69e1354a3cb93331e1cb4a267aa5769b26ae5a28c3d2988db9bc49a860a9ea5f00fe24c571a3d02052c0fc13b9c2245b7fb99ac01c1b
7
- data.tar.gz: 17a7d7c7d9ede5aa87db54a83fbed0116d5a1eced3a2cada1be24fadf643ff64841ccc10de5550260641180960060c00a211e69053b55d7b189e936bb80fc9f9
6
+ metadata.gz: afa2cc12fcbea30b784488c3efff17baf83cb9bde31922723f5986fc35b8fc068491bdf11e10c91b8d8012871cb252cc6a9e97db4c893469cfda9c8e6d468625
7
+ data.tar.gz: d4883c2c3c9c1d7adeb11e08cf5d0dc8365f92a861530aa1e4776c2aee6fa47ff5a37fd0236e5b7d8b18fa02a473581d26e36f6c17fcd19dd66a8874d8b411fb
@@ -1,14 +1,14 @@
1
1
  # coding: utf-8
2
2
  Gem::Specification.new do |spec|
3
3
  spec.name = "fluent-plugin-record_indexing"
4
- spec.version = "0.2.0"
4
+ spec.version = "0.2.1"
5
5
  spec.authors = ["imcotop"]
6
6
  spec.email = ["imcotop@icloud.com"]
7
7
 
8
8
  spec.summary = %{A fluentd filter plugin that will be used to Iterate over the object with its index and returns the value of the given object.}
9
9
  spec.description = spec.summary
10
10
  spec.homepage = "https://github.com/imcotop/fluent-plugin-record_indexing"
11
- spec.license = "apache2"
11
+ spec.license = "Apache-2.0"
12
12
 
13
13
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
14
14
  spec.executables = []
@@ -3,16 +3,17 @@ require "fluent/filter"
3
3
  module Fluent
4
4
  class RecordIndexingFilter < Filter
5
5
  Fluent::Plugin.register_filter("record_indexing", self)
6
-
7
- desc "Key name to spin"
8
- config_param :key_name, :string, default: nil
6
+
7
+ desc "Key names to spin"
8
+ config_param :key_names, :array, default: []
9
9
  config_param :key_prefix, :string, default: nil
10
10
  config_param :check_all_key, :bool, default: true
11
-
11
+ config_param :exclude_keys, :array, default: []
12
+
12
13
  def filter(tag, time, record)
13
14
  if check_all_key == false
14
- unless key_name
15
- raise ArgumentError, "key_name parameter is required if check_all_key set false"
15
+ unless key_names.any?
16
+ raise ArgumentError, "key_names parameter is required if check_all_key set false"
16
17
  end
17
18
  end
18
19
  new_record = {}
@@ -21,30 +22,30 @@ module Fluent
21
22
  new_record
22
23
  end
23
24
 
24
- def is_nested_field?(field_value)
25
- field_value.is_a?(Hash)
26
- end
27
-
28
25
  def each_with_index(record, new_record)
29
26
  record.each do |key, value|
30
- if check_all_key || key == key_name
31
- if value.nil?
32
- next # Skip if the value is nil
27
+ if check_all_key || key_names.include?(key)
28
+ if exclude_keys.include?(key)
29
+ new_record[key] = value # Keep the value as is without indexing
33
30
  elsif value.is_a?(Array)
34
31
  new_record[key] = {}
35
32
  value.each_with_index do |item, index|
36
- new_record[key]["#{key_prefix}#{index}"] = item unless item.nil?
33
+ new_record[key]["#{key_prefix}#{index}"] = item
37
34
  end
38
- elsif is_nested_field?(value)
35
+ elsif value.is_a?(Hash)
39
36
  new_record[key] = {}
40
37
  each_with_index(value, new_record[key])
41
38
  else
42
39
  new_record[key] = value
43
40
  end
41
+ elsif value.is_a?(Hash) # Check if the value is a nested Hash
42
+ new_record[key] = {}
43
+ each_with_index(value, new_record[key]) # Recursively index nested fields
44
44
  else
45
45
  new_record[key] = value
46
46
  end
47
47
  end
48
+ new_record
48
49
  end
49
50
 
50
51
  def remove_empty_fields(record)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fluent-plugin-record_indexing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - imcotop
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-08 00:00:00.000000000 Z
11
+ date: 2023-08-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -76,7 +76,7 @@ files:
76
76
  - lib/fluent/plugin/filter_record_indexing.rb
77
77
  homepage: https://github.com/imcotop/fluent-plugin-record_indexing
78
78
  licenses:
79
- - apache2
79
+ - Apache-2.0
80
80
  metadata: {}
81
81
  post_install_message:
82
82
  rdoc_options: []