fluent-plugin-dedot_filter 1.0.1 → 1.1.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 +4 -4
- data/.github/dependabot.yml +8 -0
- data/.github/workflows/release.yml +47 -0
- data/.github/workflows/test.yml +1 -1
- data/CHANGELOG.md +17 -0
- data/README.md +4 -2
- data/VERSION +1 -1
- data/fluent-plugin-dedot_filter.gemspec +2 -2
- data/lib/fluent/plugin/filter_dedot.rb +28 -12
- data/spec/filter_dedot_spec.rb +37 -2
- metadata +7 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a7e963fb965375f0d76e68975d7360bfa684633bfddbaae66dc5f0d633d3a1b0
|
|
4
|
+
data.tar.gz: 03d04fde31f801c1c5e11a945a30bf57a8b2707f117f263fbb1d40ce1d1991bc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 73fd62f7b4ac38afcd8c9fe2c6029d77bb484ac64de65c41bc78963b804158cd8311fdf26d3f5a7d5835c3aff2d5e9ace776f93cf395c15a8816669569b004f4
|
|
7
|
+
data.tar.gz: 7232a94fd96f05252f24fe36c83b906715b14f90c59cb9afbff5dcc672b0cff5c186f4dcafe7f0826f6a086f24fb40fd699b602140204c33eeabf7da46e91790
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
|
|
3
|
+
# Publishes the gem to RubyGems.org via Trusted Publishing (OIDC) when a
|
|
4
|
+
# version tag such as v1.2.3 is pushed. No RubyGems API key is stored here.
|
|
5
|
+
on:
|
|
6
|
+
push:
|
|
7
|
+
tags:
|
|
8
|
+
- "v*"
|
|
9
|
+
|
|
10
|
+
permissions: {}
|
|
11
|
+
|
|
12
|
+
jobs:
|
|
13
|
+
release:
|
|
14
|
+
name: Push gem to RubyGems.org
|
|
15
|
+
runs-on: ubuntu-latest
|
|
16
|
+
# Must match the environment configured for the trusted publisher on
|
|
17
|
+
# RubyGems.org.
|
|
18
|
+
environment: release
|
|
19
|
+
permissions:
|
|
20
|
+
contents: read
|
|
21
|
+
id-token: write # required to request the OIDC token for RubyGems.org
|
|
22
|
+
|
|
23
|
+
steps:
|
|
24
|
+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
|
|
25
|
+
with:
|
|
26
|
+
persist-credentials: false
|
|
27
|
+
|
|
28
|
+
- name: Check that the tag matches VERSION
|
|
29
|
+
env:
|
|
30
|
+
TAG: ${{ github.ref_name }}
|
|
31
|
+
run: |
|
|
32
|
+
expected="v$(cat VERSION)"
|
|
33
|
+
if [ "$TAG" != "$expected" ]; then
|
|
34
|
+
echo "::error::Tag $TAG does not match VERSION ($expected)"
|
|
35
|
+
exit 1
|
|
36
|
+
fi
|
|
37
|
+
|
|
38
|
+
- uses: ruby/setup-ruby@7eaac3fe3108dfb746bef3a3c1a21344d57923c7 # v1.348.0
|
|
39
|
+
with:
|
|
40
|
+
ruby-version: ruby
|
|
41
|
+
bundler-cache: true
|
|
42
|
+
|
|
43
|
+
- name: Run specs
|
|
44
|
+
run: bundle exec rake spec
|
|
45
|
+
|
|
46
|
+
# The tag already exists, so `rake release` only builds and pushes the gem.
|
|
47
|
+
- uses: rubygems/release-gem@2654a0fe0dc39725c07fe84d7fe863a084f2424e # v1.5.0
|
data/.github/workflows/test.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,23 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project are documented in this file.
|
|
4
4
|
|
|
5
|
+
## 1.1.0 - 2026-12-05
|
|
6
|
+
|
|
7
|
+
### Fixed
|
|
8
|
+
|
|
9
|
+
- Records with Symbol or Integer keys are no longer routed to the error
|
|
10
|
+
stream. Symbol keys are de-dotted and stay Symbols; other non-string keys
|
|
11
|
+
are kept as they are (#12).
|
|
12
|
+
- With `de_dot_nested true`, keys of hashes inside arrays nested in arrays are
|
|
13
|
+
now rewritten (#12).
|
|
14
|
+
|
|
15
|
+
### Changed
|
|
16
|
+
|
|
17
|
+
- Gem summary and description now describe the plugin and mention
|
|
18
|
+
OpenSearch (#12).
|
|
19
|
+
- Releases are published from GitHub Actions via RubyGems Trusted
|
|
20
|
+
Publishing (#10).
|
|
21
|
+
|
|
5
22
|
## 1.0.1 - 2026-12-05
|
|
6
23
|
|
|
7
24
|
### Fixed
|
data/README.md
CHANGED
|
@@ -73,9 +73,11 @@ if it has one).
|
|
|
73
73
|
|--------------------|--------|---------|-------------|
|
|
74
74
|
| `de_dot` | bool | `true` | Enables de-dotting. When `false`, records are passed through unchanged. |
|
|
75
75
|
| `de_dot_separator` | string | `_` | Replacement for each `.` in a key. Cannot be or contain `.`. |
|
|
76
|
-
| `de_dot_nested` | bool | `false` | Also rewrite keys inside nested hashes, including hashes inside arrays. |
|
|
76
|
+
| `de_dot_nested` | bool | `false` | Also rewrite keys inside nested hashes, including hashes inside (nested) arrays. |
|
|
77
77
|
|
|
78
|
-
Only keys are rewritten; values are never modified.
|
|
78
|
+
Only keys are rewritten; values are never modified. String and Symbol keys are
|
|
79
|
+
de-dotted (Symbol keys stay Symbols); other keys, such as Integers, are kept as
|
|
80
|
+
they are.
|
|
79
81
|
|
|
80
82
|
> **Note:** versions up to 1.0.0 dropped every record when `de_dot false` was
|
|
81
83
|
> set ([#6](https://github.com/lunardial/fluent-plugin-dedot_filter/issues/6)).
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.0
|
|
1
|
+
1.1.0
|
|
@@ -8,8 +8,8 @@ Gem::Specification.new do |spec|
|
|
|
8
8
|
spec.authors = ["Tomoyuki Sugimura"]
|
|
9
9
|
spec.email = ["12116691+lunardial@users.noreply.github.com"]
|
|
10
10
|
|
|
11
|
-
spec.summary = %q{
|
|
12
|
-
spec.description = %q{
|
|
11
|
+
spec.summary = %q{Fluentd filter plugin that replaces dots in record keys}
|
|
12
|
+
spec.description = %q{A Fluentd filter plugin that replaces dots (.) in record keys with another character, so that Elasticsearch and OpenSearch do not treat them as object paths.}
|
|
13
13
|
spec.homepage = "https://github.com/lunardial/fluent-plugin-dedot_filter"
|
|
14
14
|
spec.license = "MIT"
|
|
15
15
|
spec.metadata = {
|
|
@@ -43,22 +43,38 @@ module Fluent::Plugin
|
|
|
43
43
|
newrecord = {}
|
|
44
44
|
|
|
45
45
|
record.each do |key, value|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
# Recurse hashes and arrays:
|
|
49
|
-
if @de_dot_nested
|
|
50
|
-
if value.is_a? Hash
|
|
51
|
-
value = de_dot value
|
|
52
|
-
elsif value.is_a? Array
|
|
53
|
-
value = value.map { |v| v.is_a?(Hash) ? de_dot(v) : v }
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
newrecord[newkey] = value
|
|
46
|
+
newrecord[de_dot_key(key)] = @de_dot_nested ? de_dot_value(value) : value
|
|
58
47
|
end
|
|
59
48
|
|
|
60
49
|
newrecord
|
|
61
50
|
end
|
|
62
51
|
|
|
52
|
+
private
|
|
53
|
+
|
|
54
|
+
# Only String and Symbol keys can contain dots; other keys (for example
|
|
55
|
+
# Integer keys produced by some parsers) are kept as they are.
|
|
56
|
+
def de_dot_key(key)
|
|
57
|
+
case key
|
|
58
|
+
when String
|
|
59
|
+
key.gsub(/\./, @de_dot_separator)
|
|
60
|
+
when Symbol
|
|
61
|
+
key.to_s.gsub(/\./, @de_dot_separator).to_sym
|
|
62
|
+
else
|
|
63
|
+
key
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
# Recurse into hashes and arrays, including arrays nested in arrays.
|
|
68
|
+
def de_dot_value(value)
|
|
69
|
+
case value
|
|
70
|
+
when Hash
|
|
71
|
+
de_dot(value)
|
|
72
|
+
when Array
|
|
73
|
+
value.map { |v| de_dot_value(v) }
|
|
74
|
+
else
|
|
75
|
+
value
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
63
79
|
end
|
|
64
80
|
end
|
data/spec/filter_dedot_spec.rb
CHANGED
|
@@ -101,16 +101,51 @@ class TestDedotFilter
|
|
|
101
101
|
end
|
|
102
102
|
|
|
103
103
|
it "routes records that fail to process to the error stream" do
|
|
104
|
-
# Integer keys cannot be de-dotted (no #gsub), which raises inside the filter.
|
|
105
104
|
driver = create_driver
|
|
105
|
+
allow(driver.instance).to receive(:de_dot).and_wrap_original do |original, record|
|
|
106
|
+
raise "boom" if record.key?("boom")
|
|
107
|
+
original.call(record)
|
|
108
|
+
end
|
|
106
109
|
driver.run(default_tag: 'test') do
|
|
107
|
-
driver.feed({
|
|
110
|
+
driver.feed({"boom" => "value"})
|
|
108
111
|
driver.feed({"a.b" => "ok"})
|
|
109
112
|
end
|
|
110
113
|
expect(driver.filtered_records).to eq [{"a_b" => "ok"}]
|
|
111
114
|
expect(driver.error_events.size).to eq 1
|
|
112
115
|
end
|
|
113
116
|
|
|
117
|
+
it "de-dots symbol keys and keeps them as symbols" do
|
|
118
|
+
records = filter_records(%[], [{:"a.b" => 1, :c => 2}])
|
|
119
|
+
expect(records).to eq [{:a_b => 1, :c => 2}]
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
it "keeps non-string keys instead of dropping the record" do
|
|
123
|
+
driver = create_driver
|
|
124
|
+
driver.run(default_tag: 'test') do
|
|
125
|
+
driver.feed({1 => "int", nil => "nil", "a.b" => 2})
|
|
126
|
+
end
|
|
127
|
+
expect(driver.filtered_records).to eq [{1 => "int", nil => "nil", "a_b" => 2}]
|
|
128
|
+
expect(driver.error_events).to be_empty
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
it "de-dots non-string keys inside nested hashes when de_dot_nested is true" do
|
|
132
|
+
input = {"a.b" => {1 => "int", :"c.d" => 2}}
|
|
133
|
+
records = filter_records(%[de_dot_nested true], [input])
|
|
134
|
+
expect(records).to eq [{"a_b" => {1 => "int", :c_d => 2}}]
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
it "rewrites hashes in arrays nested in arrays when de_dot_nested is true" do
|
|
138
|
+
input = {"a.b" => [[{"c.d" => 1}, ["e.f", [{"g.h" => 2}]]], {"i.j" => [[]]}]}
|
|
139
|
+
records = filter_records(%[de_dot_nested true], [input])
|
|
140
|
+
expect(records).to eq [{"a_b" => [[{"c_d" => 1}, ["e.f", [{"g_h" => 2}]]], {"i_j" => [[]]}]}]
|
|
141
|
+
end
|
|
142
|
+
|
|
143
|
+
it "leaves arrays nested in arrays untouched when de_dot_nested is false" do
|
|
144
|
+
input = {"a.b" => [[{"c.d" => 1}]]}
|
|
145
|
+
records = filter_records(%[], [input])
|
|
146
|
+
expect(records).to eq [{"a_b" => [[{"c.d" => 1}]]}]
|
|
147
|
+
end
|
|
148
|
+
|
|
114
149
|
end
|
|
115
150
|
|
|
116
151
|
context "#de_dot" do
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fluent-plugin-dedot_filter
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0
|
|
4
|
+
version: 1.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tomoyuki Sugimura
|
|
@@ -85,7 +85,8 @@ dependencies:
|
|
|
85
85
|
- - "~>"
|
|
86
86
|
- !ruby/object:Gem::Version
|
|
87
87
|
version: '3.0'
|
|
88
|
-
description:
|
|
88
|
+
description: A Fluentd filter plugin that replaces dots (.) in record keys with another
|
|
89
|
+
character, so that Elasticsearch and OpenSearch do not treat them as object paths.
|
|
89
90
|
email:
|
|
90
91
|
- 12116691+lunardial@users.noreply.github.com
|
|
91
92
|
executables: []
|
|
@@ -93,6 +94,8 @@ extensions: []
|
|
|
93
94
|
extra_rdoc_files: []
|
|
94
95
|
files:
|
|
95
96
|
- ".devcontainer/devcontainer.json"
|
|
97
|
+
- ".github/dependabot.yml"
|
|
98
|
+
- ".github/workflows/release.yml"
|
|
96
99
|
- ".github/workflows/test.yml"
|
|
97
100
|
- ".gitignore"
|
|
98
101
|
- ".rspec"
|
|
@@ -129,9 +132,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
129
132
|
- !ruby/object:Gem::Version
|
|
130
133
|
version: '0'
|
|
131
134
|
requirements: []
|
|
132
|
-
rubygems_version:
|
|
135
|
+
rubygems_version: 4.0.20
|
|
133
136
|
specification_version: 4
|
|
134
|
-
summary:
|
|
137
|
+
summary: Fluentd filter plugin that replaces dots in record keys
|
|
135
138
|
test_files:
|
|
136
139
|
- spec/filter_dedot_spec.rb
|
|
137
140
|
- spec/helper.rb
|