Skip to content
Open
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions lib/fluent/plugin/out_influxdb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class Fluent::Plugin::InfluxdbOutput < Fluent::Plugin::Output
desc: "Enable/Disable auto-tagging behaviour which makes strings tags."
config_param :tag_keys, :array, default: [],
desc: "The names of the keys to use as influxDB tags."
config_param :tag_keys_field, :string, default: nil,
desc: "The name of the fields where influxdb key names are stored"
config_param :sequence_tag, :string, default: nil,
desc: <<-DESC
The name of the tag whose value is incremented for the consecutive simultaneous
Expand Down Expand Up @@ -145,6 +147,10 @@ def write(chunk)
end
end
end
if !@tag_keys_field.nil? && record.include?(tag_keys_field)
tags.update(record[tag_keys_field])
values.delete(tag_keys_field)
end
if @sequence_tag
if @prev_timestamp == timestamp
@seq += 1
Expand Down
29 changes: 29 additions & 0 deletions test/plugin/test_out_influxdb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,35 @@ def test_write_with_measurement
], driver.instance.influxdb.points)
end

def test_empty_tag_keys_field
config_with_tags = %Q(
#{CONFIG}
tag_keys_field b
)

driver = create_driver(config_with_tags)

time = event_time("2011-01-02 13:14:15 UTC")
driver.run(default_tag: 'input.influxdb') do
driver.feed(time, {'b' => {'a' => "2"}, 'c' => '2'})
end

assert_equal([
[
[
{
timestamp: 1293974055,
series: 'input.influxdb',
values: {'c' => "2"},
tags: {'a' => "2"}
},
],
nil,
nil
]
], driver.instance.influxdb.points)
end

def test_empty_tag_keys
config_with_tags = %Q(
#{CONFIG}
Expand Down