Logging Request Body/ Response Body with HTTP LOG

Hi Guys, what are options if request/response body needs to be logged with Http-log? Seems like runscope plugin already does this, should be Possible with http-log plugin too?

Maybe just in scenario where something need to be debugged and logging Request Body/ Response Body could be turned on as option in HTTP-LOG Plugin.

Or it can be different plugin altogether?

Someone did a PR here for TCP/UDP. Could be adapted to the HTTP Logger: https://github.com/Kong/kong/pull/3028 . We discussed on chat too. some :slight_smile:

1 Like

Thanks, will look into it. We are also looking into runscope and also writing modified version of http-log with optional flag.

1 Like

Hi guys! :slight_smile:

Is this possible in any way? I’m using the http log plugin to send my logs to an elasticsearch instance and visualizing it on kibana. But right now I don’t have the request and response bodies.

As the Runscope plugin is already deprecated how can we handle this? Probably putting two different plugins to work together? Or any other way?

Does somebody know if logging the req / res bodies is in Kong’s plans?

Thank you

1 Like

file-log plugin nicely captures request and response bodies.

Are you sure the file-log plugin will save the body itself? I tested that pretty extensively but I never got it to work that the body was logged in the file. Am I missing some configuration option which is not documented?

1 Like

+1
I’m trying to log the request body as well, but can’t seem to make it work… the PR mentioned in this thread is still open.
Did anyone manage to make it happen?

@Fernando_Z, would something like Moesif API Analytics work? There is a plugin available for Moesif: https://docs.konghq.com/hub/moesif/kong-plugin-moesif/

I currently log the requests to a Splunk server and was looking for a way to just include the HTTP body in the default tcp plugin logs. I’ll take a look into Moesif, thanks!

Hi Guys,

I have the same use case as Lucastex has. I am using the Http Log plugin to dump the logs to my elastic search instance and Visualize it on Kibaan. But the response body is not logged as the part of it.
I have a special use case where I need to dump the Response Body as the part of logging so that Reports could be generated in Kibana using the Http Log plugin.

Can the Http Log plugin be tweaked such that we can log the response body in the Elastic instance?
Is there any other Supported Plugin or way. I know the Runscope plugin is deprecated so we cant go with that.

It would be quite helpful if we get the support on this.

Regards

@Shubhanshu_Rastogi how are you writing the HTTP logs to Kibana? I tried to point the “HTTP End Point” to my Elastic instance (which Kibana is watching), but that does not seem to be working.

Struggling with the same issue 18 months later. Anyone have a preferred way to do this? i.e. logging the request/response body.

2 Likes

Commenting here to increase reach of this post. I have the same question.
@mgkong : Could you demonstrate how it is capturing request,response body

Same question for me, I’d like to capture body for debugging, but I can’t find how to do that…

I met problem like that. Do anyone have some ideas to solve?

Did anyone try config.custom_fields_by_lua ? It returns no logs when I add get_body() function call to my yml config.

I wrote a blog post about this. If you are using kong 2.4 or later, you can inject request/response body to any logging plugin dynamically using pre-function plugin.

1 Like