lib/fluent/plugin/out_unomaly.rb in fluent-plugin-unomaly-0.1.3 vs lib/fluent/plugin/out_unomaly.rb in fluent-plugin-unomaly-0.1.4

- old
+ new

@@ -80,26 +80,32 @@ metadata.delete(@source_key) metadata.delete(@message_key) metadata["tag"]=tag - unomaly_event["metadata"]=flatten(metadata,"") + unomaly_event["metadata"]=metadata.to_json + if @debug + log.info "Event #{unomaly_event.to_json}" + end documents.push(unomaly_event) end send_batch(documents) end def send_batch(events) url = @host + @api_path body = events.to_json + ssl = url.start_with?('https') uri = URI.parse(url) header = {'Content-Type' => 'application/json'} http = Net::HTTP.new(uri.host, uri.port) - http.use_ssl = true - if @accept_self_signed_certs - http.verify_mode = OpenSSL::SSL::VERIFY_NONE + if ssl + http.use_ssl = true + if @accept_self_signed_certs + http.verify_mode = OpenSSL::SSL::VERIFY_NONE + end end request = Net::HTTP::Post.new(uri.request_uri, header) request.body = body \ No newline at end of file