Thursday, September 14, 2017

How to enable tracing logs on PCF DEV

Most of the time PCF does not show much error logs. After going through their documentation I found a catch. Since our calls are mainly API based, we can enable tracing logs for these calls and get an idea of the errors we get.

E.g.,  I had a situation, no matter how correctly developed app it is, when I push it in to dev environment, it keeps on crashing.

Only error log I could see was below

2017-09-14T15:23:56.84+0530 [API/0] OUT Updated app with guid 0163061c-0120-4662-a0b1-930d7ce6505b ({"state"=>"STOPPED"})

The  below command actually helped me to get more details of the error log.

What you have to do is append -vin to your cf command.

E.g.,


sudo cf push --docker-image test:test test -u process -v
  
This gives more error logs as below :

REQUEST: [2017-09-14T18:02:32+05:30]
GET /v2/apps/abc44f1f-3072-4c85-a72a-d0d6738dfb97/instances HTTP/1.1
Host: api.local.pcfdev.io
Accept: application/json
Authorization: [PRIVATE DATA HIDDEN]
Connection: close
Content-Type: application/json
User-Agent: go-cli 6.29.2+c66d0f3.2017-08-25 / linux



RESPONSE: [2017-09-14T18:02:32+05:30]
HTTP/1.1 200 OK
Connection: close
Content-Length: 96
Content-Type: application/json;charset=utf-8
Date: Thu, 14 Sep 2017 12:32:33 GMT
Server: nginx
X-Content-Type-Options: nosniff
X-Vcap-Request-Id: 09c44df1-7f8b-4147-6cd8-fa033dd68477
X-Vcap-Request-Id: 09c44df1-7f8b-4147-6cd8-fa033dd68477::ba3471cb-55be-46ac-a119-db14696c8f62

{"0":{"state":"DOWN","uptime":32,"since":1505392320,"details":"insufficient resources: memory"}}

REQUEST: [2017-09-14T18:02:32+05:30]
GET /v2/apps/abc44f1f-3072-4c85-a72a-d0d6738dfb97/stats HTTP/1.1
Host: api.local.pcfdev.io
Accept: application/json
Authorization: [PRIVATE DATA HIDDEN]
Connection: close
Content-Type: application/json
User-Agent: go-cli 6.29.2+c66d0f3.2017-08-25 / linux



RESPONSE: [2017-09-14T18:02:32+05:30]
HTTP/1.1 200 OK
Connection: close
Content-Length: 253
Content-Type: application/json;charset=utf-8
Date: Thu, 14 Sep 2017 12:32:33 GMT
Server: nginx
X-Content-Type-Options: nosniff
X-Vcap-Request-Id: 95f66d78-59b3-4e69-4b18-508de8d2c102
X-Vcap-Request-Id: 95f66d78-59b3-4e69-4b18-508de8d2c102::801fb2ec-4bc1-45a7-8726-10b57b7b6c73

{"0":{"state":"DOWN","stats":{"name":"working","uris":["working.local.pcfdev.io"],"host":null,"port":null,"uptime":32,"mem_quota":2147483648,"disk_quota":1073741824,"fds_quota":16384,"usage":{"time":"2017-09-14 12:32:33 UTC","cpu":0,"mem":0,"disk":0}}}}
0 of 1 instances running, 1 down