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

Adding keys remapping functionality #60

Open
wants to merge 2 commits 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
5 changes: 4 additions & 1 deletion lib/fluent/plugin/out_influxdb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ class Fluent::Plugin::InfluxdbOutput < Fluent::Plugin::Output
desc: "Use SSL when connecting to influxDB."
config_param :verify_ssl, :bool, default: true,
desc: "Enable/Disable SSL Certs verification when connecting to influxDB via SSL."
config_param :keys_mapping, :hash, :default => {},
desc: "The names of the keys mapping to map existing tags to those from influxDB."
config_param :auto_tags, :bool, default: false,
desc: "Enable/Disable auto-tagging behaviour which makes strings tags."
config_param :tag_keys, :array, default: [],
Expand Down Expand Up @@ -127,13 +129,14 @@ def write(chunk)
tag = chunk.metadata.tag
chunk.msgpack_each do |time, record|
timestamp = record.delete(@time_key) || time
if tag_keys.empty? && !@auto_tags
if @tag_keys.empty? && !@auto_tags && @keys_mapping.empty?
values = record
tags = {}
else
values = {}
tags = {}
record.each_pair do |k, v|
k = @keys_mapping.fetch(k, k)
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 != ''
Expand Down