From d94cb51491438390110e0387532ffd8aef0fd14f Mon Sep 17 00:00:00 2001 From: Masahiro Nakagawa Date: Fri, 12 Jun 2020 05:31:25 +0900 Subject: [PATCH] in_http: Add dump_error_log parameter. fix #3035 Signed-off-by: Masahiro Nakagawa --- lib/fluent/plugin/in_http.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/fluent/plugin/in_http.rb b/lib/fluent/plugin/in_http.rb index ed88f855ac..1b30ee0b0c 100644 --- a/lib/fluent/plugin/in_http.rb +++ b/lib/fluent/plugin/in_http.rb @@ -60,6 +60,8 @@ class HttpInput < Input config_param :respond_with_empty_img, :bool, default: false desc 'Respond status code with 204.' config_param :use_204_response, :bool, default: false + desc 'Dump error log or not' + config_param :dump_error_log, :bool, default: true config_section :parse do config_set_default :@type, 'in_http' @@ -180,8 +182,11 @@ def on_request(path_info, params) else record_time.nil? ? Fluent::EventTime.now : record_time end - rescue - return ["400 Bad Request", {'Content-Type'=>'text/plain'}, "400 Bad Request\n#{$!}\n"] + rescue => e + if @dump_error_log + log.error "failed to process request", error: e + end + return ["400 Bad Request", {'Content-Type'=>'text/plain'}, "400 Bad Request\n#{e}\n"] end # TODO server error @@ -219,6 +224,9 @@ def on_request(path_info, params) router.emit(tag, time, record) end rescue + if @dump_error_log + log.error "failed to emit data", error: e + end return ["500 Internal Server Error", {'Content-Type'=>'text/plain'}, "500 Internal Server Error\n#{$!}\n"] end