Customised audit logs


#1

can anyone tell, Is der any way to customise the audit logs from File_log plugin in kong?
I have configured my service with the file_log plugin in kong and getting the below audit logs
{
“consumer”:{
“custom_id”:“test1”,
“created_at”:1550841780,
“username”:“demo”,
“id”:“b450eab9-bf49-4a6b-aaee-4934cdc4fa58”
},
“latencies”:{
“request”:292,
“kong”:24,
“proxy”:268
},
“service”:{
“host”:“localhost”,
“created_at”:1550840969,
“connect_timeout”:60000,
“id”:“7aafcb78-3ace-4cbf-ab33-2c9509b8f10c”,
“protocol”:“http”,
“name”:“demo_service”,
“read_timeout”:60000,
“port”:8080,
“updated_at”:1550840969,
“retries”:5,
“write_timeout”:60000
},
“request”:{
“querystring”:{

  },
  "size":"125",
  "uri":"\/SpringBootRestApi\/api\/user\/",
  "url":"http:\/\/localhost:8000\/SpringBootRestApi\/api\/user\/",
  "headers":{  
     "host":"localhost:8000",
     "x-consumer-username":"demo",
     "user-agent":"curl\/7.29.0",
     "accept":"*\/*",
     "x-consumer-custom-id":"test1",
     "x-consumer-id":"b450eab9-bf49-4a6b-aaee-4934cdc4fa58",
     "apikey":"demopasswd"
  },
  "method":"GET"

},
“client_ip”:“127.0.0.1”,
“tries”:[
{
“balancer_latency”:0,
“port”:8080,
“balancer_start”:1551352892773,
“ip”:“127.0.0.1”
}
],
“authenticated_entity”:{
“id”:“7f37d739-f078-470b-aa07-8acf74e94811”
},
“upstream_uri”:"/SpringBootRestApi/api/user/",
“response”:{
“headers”:{
“content-type”:“application/json;charset=UTF-8”,
“date”:“Thu, 28 Feb 2019 11:21:33 GMT”,
“x-ratelimit-limit-hour”:“100”,
“connection”:“close”,
“x-ratelimit-limit-second”:“5”,
“via”:“kong/1.0.2”,
“x-ratelimit-remaining-second”:“4”,
“transfer-encoding”:“chunked”,
“x-kong-proxy-latency”:“3”,
“x-kong-upstream-latency”:“268”,
“x-ratelimit-remaining-hour”:“99”
},
“status”:200,
“size”:“557”
},
“route”:{
“created_at”:1550841050,
“methods”:[
“GET”
],
“id”:“f04ae234-37e8-4de6-be3f-64ab58c9383e”,
“service”:{
“id”:“7aafcb78-3ace-4cbf-ab33-2c9509b8f10c”
},
“updated_at”:1550841050,
“preserve_host”:false,
“regex_priority”:0,
“paths”:[
“/SpringBootRestApi/api/user/”
],
“protocols”:[
“http”,
“https”
],
“strip_path”:false
},
“started_at”:1551352892770
}

Here I dont want header and id information. Is der any way to remove these from logging.?


#2

Hi,

Currently there is not way to customize the format produced by the file log or similar logging plugins bundled with Kong. You can always use an intermediary log transformer like logstash to modify the output of the logging plugins to suit your needs, before forwarding it on to its final location.