Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: supporting of nested fields #107

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions lib/fluent/plugin/out_influxdb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -138,14 +138,7 @@ def write(chunk)
values = {}
tags = {}
record.each_pair do |k, v|
if (@auto_tags && v.is_a?(String)) || @tag_keys.include?(k)
# If the tag value is not nil, empty, or a space, add the tag
if v.to_s.strip != ''
tags[k] = v
end
else
values[k] = v
end
_parse_field(k, v, tags, values)
end
end
if @sequence_tag
Expand Down Expand Up @@ -204,6 +197,21 @@ def write(chunk)
end
end

def _parse_field(k, v, tags, values)
if (@auto_tags && v.is_a?(String)) || @tag_keys.include?(k)
# If the tag value is not nil, empty, or a space, add the tag
if v.to_s.strip != ''
tags[k] = v
end
elsif v.is_a?(Hash)
v.each_pair do |nested_k, nested_v|
_parse_field("#{k}.#{nested_k}", nested_v, tags, values)
end
else
values[k] = v
end
end

def time_precise_lambda()
case @time_precision.to_sym
when :h then
Expand Down