How to Log with Kong

Hi !

I am trying to log every request called to Kong but I don’t understand how to use the plugin Http Log.
I read https://docs.konghq.com/plugins/http-log/
But when I added the plugin :
{
“created_at”: 1531839288000,
“config”: {
“http_endpoint”: “http://mockbin.org/bin/c88a0365-f6ab-49f9-9674-38283764dfcb”,
“timeout”: 1000,
“method”: “POST”,
“keepalive”: 1000,
“content_type”: “application/json”
},
“id”: “96035659-402c-454c-b204-0b54df8466d2”,
“name”: “http-log”,
“service_id”: “23380fd8-5a4a-4969-b2da-ab477dd1edfb”,
“enabled”: true
}
When I try to look at http://mockbin.org/bin/c88a0365-f6ab-49f9-9674-38283764dfcb or
http://mockbin.org/bin/c88a0365-f6ab-49f9-9674-38283764dfcb/log or
http://mockbin.org/bin/c88a0365-f6ab-49f9-9674-38283764dfcb/view

There is nothing.
I am not sure about how to use mockbin and http log.
If anyone know how to use it and can explain it i’ll be grateful.

Hello, the http log plugin is a “request logger” - for each request/response pair that goes through Kong, the plugin makes an http request.

If you have only configured the plugin but made no requests through Kong, the plugin will be installed, but it will never activate. You need to make some traffic go through Kong in order for it to appear in your mockbin instances.

I did, but nothing happened

1 Like

Maybe the traffic you are generating is not triggering the plugin.

  • First, make sure that the traffic you are generating goes through Kong (not directly to the upstream server)
  • Also, check that the traffic matches the service 23380fd8-5a4a-4969-b2da-ab477dd1edfb, which is the one associated with your http-log plugin. You must send your request to a route associated to that service.
  • Check that you are getting the expected responses from your traffic.
  • Give a look at the nginx logs and see if there are any errors happening while the traffic goes though Kong.

I added the plugin to be global so it should be activated by any services.
But now I think about using StatsD plugin instead of the Http Log.
It may be more useful in my case.
But I don’t understand how to use it.
I receive an error in my logs : send() failed (111: Connection refused) […] statsd_logger.lua:71: send_statsd(): failed to send data to localhost:8125: connection refused

I suppose that is because localhost:8125 is not a StatsD server but I am not sure about that.
And if it is for this reason I would like to know if there is an StatsD online to test it instead of installing one.

The connection refused message seems to indicate that localhost:8125 is not available at all - your problem seems to be network-related more than protocol-related.

If you are using Kong from inside Docker, you might need to change localhost by host.docker.internal. More info in https://docs.docker.com/docker-for-mac/networking/ .

if there is an StatsD online to test it instead of installing one.

I’m sorry, I know no such service.