fluent-plugin-record_indexing 0.2.0 → 0.2.1
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 +4 -4
- data/fluent-plugin-record_indexing.gemspec +2 -2
- data/lib/fluent/plugin/filter_record_indexing.rb +16 -15
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55b3c230a4fe0c5c4a6dd0b914c2728d1cd91e84c9702689628388278cba45dd
|
4
|
+
data.tar.gz: 818543e3a427d6e14a6a7acea3753b0bbe94117df54951dcfe53ebfbbd09a4bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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 = "
|
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
|
8
|
-
config_param :
|
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
|
15
|
-
raise ArgumentError, "
|
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
|
31
|
-
if
|
32
|
-
|
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
|
33
|
+
new_record[key]["#{key_prefix}#{index}"] = item
|
37
34
|
end
|
38
|
-
elsif
|
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.
|
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-
|
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
|
-
-
|
79
|
+
- Apache-2.0
|
80
80
|
metadata: {}
|
81
81
|
post_install_message:
|
82
82
|
rdoc_options: []
|