lib/fluent/plugin/out_unomaly.rb in fluent-plugin-unomaly-0.1.8 vs lib/fluent/plugin/out_unomaly.rb in fluent-plugin-unomaly-0.1.10
- old
+ new
@@ -18,22 +18,20 @@
config_param :host, :string
# Key that will be used by Unomaly as the log message
config_param :message_key, :string, :default => "message"
- # Key that will be used by Unomaly as the log message
- config_param :date_key, :string, :default => nil
-
# Key that will be used by Unomaly as the system key
config_param :source_key, :string, :default => "host"
# Unomaly api path to push events
config_param :api_path, :string, :default => "/v1/batch"
# Display debug logs
config_param :debug, :bool, :default => false
+ # Accept self signed certs
config_param :accept_self_signed_certs, :bool, :default => false
# This method is called before starting.
# 'conf' is a Hash that includes configuration parameters.
# If the configuration is invalid, raise Fluent::ConfigError.
@@ -86,10 +84,15 @@
if @debug
log.info "Event #{unomaly_event.to_json}"
end
documents.push(unomaly_event)
+
+ if documents.length >= @batch_size
+ send_batch(documents)
+ documents = []
+ end
end
send_batch(documents)
end
def send_batch(events)
@@ -104,9 +107,11 @@
http.use_ssl = true
if @accept_self_signed_certs
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
end
end
+
+ log.info "Sending #{events.length} events to unomaly at #{@host}#{@api_path} (batch_size=#{@batch_size})"
request = Net::HTTP::Post.new(uri.request_uri, header)
request.body = body
resp = http.request(request)