lib/fluent/plugin/out_indicative.rb in fluent-plugin-indicative-0.1.7 vs lib/fluent/plugin/out_indicative.rb in fluent-plugin-indicative-0.1.8
- old
+ new
@@ -15,12 +15,10 @@
elsif v.is_a? Array
# Indicative doesn't support arrays so we use the value of the array as a key and set it to true
v.each do |item|
if item.is_a?(Hash) && item.has_key?("key") && item.has_key?("value")
h["#{k}.#{item["key"]}"] = item["value"]
- else
- h["#{k}.#{item}"] = true
end
end
else
h[k] = v
end
@@ -35,10 +33,11 @@
config_param :api_url, :string, default: 'https://api.indicative.com/service/event/batch'
config_param :batch_size, :integer, default: 15
config_param :event_name_key, :string
config_param :event_time_key, :string
config_param :event_unique_id_keys, :array, value_type: :string
+ config_param :event_filter_key, :string, default: nil
def process(tag, es)
es.each_slice(@batch_size) do |events|
send_events(events.map {|time, record| record})
end
@@ -59,10 +58,10 @@
headers = {'Content-Type' => 'application/json'}
payload = {
apiKey: @api_key,
- events: events.map do |data|
+ events: events.filter {|data| !@event_filter_key or data[@event_filter_key] != false}.map do |data|
unique_id_key = @event_unique_id_keys.find {|k| data[k]}
{
eventName: data[@event_name_key],
eventUniqueId: unique_id_key && data[unique_id_key],
properties: flatten_hash(data),