How to follow a buildpack as it interacts with TAS platform by following the logs in real time?
Noteable:
Steps below to see the logs in real time associated with buildpack commands/any cf command (you can redirect the outputs to a file if preferred):
1. In a terminal, ssh into opsman vm (may need to install cf cli) and run your CF_TRACE=true cf create-buildpack BUILDPACK command. Or can trigger buildpack update via pipeline.
2. Then grab/retrieve the cloud controller log bundle and find the request via parsing all of the cloud_controller_ng files.
3. Notice the output after running command (CF_TRACE=true cf create-buildpack BUILDPACK) will look similar to the below snippet: (you should see multiple of these calls associated with each command execution).
REQUEST: [2023-07-07T18:17:36Z] GET / HTTP/1.1 Host: api.run-31.slot-##.#####-##-#####.#####.com Accept: application/json User-Agent: cf/6.53.0+8e2b70a4a.2020-10-01 (go1.13.8; amd64 linux) RESPONSE: [2023-07-07T18:17:36Z] HTTP/1.1 200 OK Content-Length: 1552 Content-Type: application/json;charset=utf-8 Date: Fri, 07 Jul 2023 18:17:36 GMT Server: nginx X-B3-Spanid: 15bcacfe97f49209 X-B3-Traceid: 31fe2d117efd929315bcacfe97f49209 X-Content-Type-Options: nosniff X-Vcap-Request-Id: 72a239ee-f2fa-4324-636a-1adf7d8a8e29::5cfe8ec9-75f8-4dd9-ac72-cb25dbf21207
4. For each CF_TRACE=true "cf" command execution you should see multiple CAPI calls made by the cf cli client. Each call should have a unique Vcap Request Id. In the above example, take note of line #16 X-Vcap-Request-Id:72a239ee… At this point you can parse the /var/vcap/sys/log/cloud_controller_ng for the Vcap-Request Id:######.
-----------------------------------------------------------------------------------------------------------------------------------------------------
See the details in repro below to correlate the screenshot above:
----------------------------------------------------------------------------------------------------------------------------------------------------
#Command issued: ( ubuntu@opsmgr-31-####-###-#####-####-labs:~$ CF_TRACE=true cf create-buildpack java-test /tmp/java-buildpack-offline-v4.59.0.zip 3 ) #You will see output for each “CF_TRACE=true + cf command” detailing the numerous calls made in order to execute the command. You should see a REQUEST and RESPONSE for each call, this is where we locate and take note of the vcap_request_id:#### to follow along on the cloud controller vm in the /var/vcap/sys/log/cloud_controller_ng directory. (Will need sudo privilege) # nginx-access. log - a record of all requests handled by that Node # cloud_controller_ng. log - logs from the service which may detail information about a request (what was cc doing for the request) #REQUEST1: REQUEST: [2023-07-07T18:17:36Z] GET / HTTP/1.1 Host: api.run-31.slot-35.#####-##-#####.######.com Accept: application/json User-Agent: cf/6.53.0+8e2b70a4a.2020-10-01 (go1.13.8; amd64 linux) RESPONSE: [2023-07-07T18:17:36Z] HTTP/1.1 200 OK Content-Length: 1552 Content-Type: application/json;charset=utf-8 Date: Fri, 07 Jul 2023 18:17:36 GMT Server: nginx X-B3-Spanid: 15bcacfe97f49209 X-B3-Traceid: 31fe2d117efd#####5bcacfe97f49209 X-Content-Type-Options: nosniff X-Vcap-Request-Id: 72a239ee-####-4324-636a-1adf7d8a8e29::5cfe8ec9-####-4dd9-ac72-cb25dbf21207 #BELOW WE CAN SEE WHEN CLOUD CONTROLLER FIRST LEARNS ABOUT REQUEST AND WHEN THE NODE LEARNED OF THE REQUEST. #ACCESS LOG ENTRY: nginx-access.log:api.run-31.slot-35.######-###-###.######.com - [07/Jul/2023:18:17:36 +0000] "GET / HTTP/1.1" 200 1917 "-" "cf/6.53.0+8e2b70a4a.2020-10-01 (go1.13.8; amd64 linux)" 10.225.##.###, 10.225.##.###, 10.225.##.### vcap_request_id:72a239ee-####-4324-636a-1adf7d8a8e29::5cfe8ec9-75f8-4dd9-ac72-cb25dbf21207 response_time:0.012 #CLOUD CONTROLLER LOG ENTRY: (AS SHOWN BELOW, THE TOP ENTRY CC LEARNS ABOUT REQUEST AND BOTTOM ENTRY SHOWS CC COMPLETED REQUEST WITH STATUS CODE) cloud_controller_ng.log:{"timestamp":"2023-07-07T18:17:36.298560458Z","message":"Started GET \"/\" for user: , ip: 10.225.##.### with vcap-request-id: 72a239ee-f2fa-4324-636a-1adf7d8a8e29::5cfe8ec9-75f8-4dd9-ac72-cb25dbf21207 at 2023-07-07 18:17:36 UTC","log_level":"info","source":"cc.api","data":{"request_guid":"72a239ee-f2fa-4324-636a-1adf7d8a8e29::5cfe8ec9-75f8-4dd9-ac72-cb25dbf21207"},"thread_id":93360,"fiber_id":93380,"process_id":6,"file":"/var/vcap/data/packages/cloud_controller_ng/2ef9e18a5996820253530635cebf3c2a803bc289/cloud_controller_ng/lib/cloud_controller/logs/request_logs.rb","lineno":14,"method":"start_request"} cloud_controller_ng.log:{"timestamp":"2023-07-07T18:17:36.303965852Z","message":"Completed 200 vcap-request-id: 72a239ee-####-####-636a-1adf7d8a8e29::5cfe8ec9-####-4dd9-ac72-cb25dbf21207","log_level":"info","source":"cc.api","data":{"request_guid":"72a239ee-f2fa-4324-636a-1adf7d8a8e29::5cfe8ec9-75f8-4dd9-ac72-cb25dbf21207"},"thread_id":93360,"fiber_id":93380,"process_id":6,"file":"/var/vcap/data/packages/cloud_controller_ng/2ef9e18a5996820253530635cebf3c2a803bc289/cloud_controller_ng/lib/cloud_controller/logs/request_logs.rb","lineno":28,"method":"complete_request"}