You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When sending logs to HEC endpoint and not receiving 200x response code with response body in non-JSON, Splunk swallows actual response body and throws MalformedJsonException.
Eg.:
Response body:
</html>
</body>
<hr><center>nginx/1.21.3</center>
<center><h1>502 Bad Gateway</h1></center>
<body>
<head><title>502 Bad Gateway</title></head>
<html>
Splunk logs:
Message: ServerErrorException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 2 column 2 path $
Because try-catch block swallows the response body in com.splunk.logging.HttpEventCollectorErrorHandler.ServerErrorException#ServerErrorException:
and in com.splunk.logging.util.StandardErrorCallback used method ex.getMessage() which returns errorText.
So, in order to preserve proper response body in logs we need to write custom ErrorCallback but would be great to do it via standard methods as other response body format can be returned.
The text was updated successfully, but these errors were encountered:
artem-emelin
changed the title
Splunk client swallows server response in non-JSON format
Splunk client swallows server error response in non-JSON format
Dec 9, 2022
When sending logs to HEC endpoint and not receiving 200x response code with response body in non-JSON, Splunk swallows actual response body and throws
MalformedJsonException
.Eg.:
Response body:
Splunk logs:
Because
try-catch
block swallows the response body incom.splunk.logging.HttpEventCollectorErrorHandler.ServerErrorException#ServerErrorException
:and in
com.splunk.logging.util.StandardErrorCallback
used methodex.getMessage()
which returnserrorText
.So, in order to preserve proper response body in logs we need to write custom
ErrorCallback
but would be great to do it via standard methods as other response body format can be returned.The text was updated successfully, but these errors were encountered: