This article covers an alternative method to identify an application instance's instance_guid, also known as the process_instance_id in Tanzu Application Service for VMs (TAS for VMs).
Typically when you need to find an application instance's instance_guid, you can locate it with cfdot.
For example, if you wanted to find the instance_guid for the application simpleapp, you could perform the following:
1. Identify the app GUID.
$ cf app simpleapp --guid 940b24d3-1b0a-4534-a1bd-a5ec6ee61703
2. SSH onto a diego_cell and utilize the cfdot utility's actual-lrps command to identify the instance_guid.
diego_cell/c9cf24db-e9c3-4c09-8231-3bda4b3ba4ee:~$ cfdot actual-lrps | grep 940b24d3-1b0a-4534-a1bd-a5ec6ee61703 {"process_guid":"940b24d3-1b0a-4534-a1bd-a5ec6ee61703-9f59a95c-7f77-4ed4-9492-459ce17ea3fe","index":0,"domain":"cf-apps","instance_guid":"87620a05-8853-48ae-5196-8b35","cell_id":"9ca6f0b4-f0da-4f2c-becf-5eb7233312dc","address":"IP","ports":[{"container_port":PORT,"host_port":PORT,"container_tls_proxy_port":PORT,"host_tls_proxy_port":PORT},{"container_port":PORT,"host_port":PORT,"container_tls_proxy_port":61002,"host_tls_proxy_port":PORT}],"instance_address":"IP","preferred_address":"HOST","crash_count":0,"state":"RUNNING","since":1620324151323579152,"modification_tag":{"epoch":"215f895a-bb69-461b-40fa-2b6dfb3ef1bc","index":2},"presence":"ORDINARY"}
Note: When you run the cfdot command, we piped the output to grep filtering on the app_guid. However, note that the app_guid is not part of the output. The filter matched based on the process_guid.
Typically the process_guid is made up from a combination of the app_guid and another unique GUID. In this example, we can see the following:
This is most often the case but not always. Sometimes the process_guid does not match the app_guid, and this is perfectly okay. You just need an alternate method to find an application instance's instance_guid for when the process_guid and app_guid do not match. The following method explained in the next section should help with this.
In the case process_guid and app_guid do not match, there are two scenarios:
This method utilizes the routing table within the Gorouter.
1. SSH onto a Gorouter and run the following:
# become sudo sudo su - # create a local copy of the routing table and redirect output to the tmp directory /var/vcap/jobs/gorouter/bin/retrieve-local-routes | jq . > /tmp/routes.json
"simpleapp-bright-gorilla.APPS-DOMAIN": [ { "address": "IP:PORT", "tls": true, "ttl": 120, "tags": { "app_id": "940b24d3-1b0a-4534-a1bd-a5ec6ee61703", "app_name": "simpleapp", "component": "route-emitter", "instance_id": "0", "organization_id": "d2caafec-bf04-4ae9-9660-868b29d6ee26", "organization_name": "jgainey", "process_id": "1adabfbd-5aa8-4688-8187-81dd539b9bcd", "process_instance_id": "87620a05-8853-48ae-5196-8b35", "process_type": "web", "source_id": "940b24d3-1b0a-4534-a1bd-a5ec6ee61703", "space_id": "4ceea8bf-7899-4bba-acab-7fe7b64c17aa", "space_name": "playarea" }, "private_instance_id": "87620a05-8853-48ae-5196-8b35", "server_cert_domain_san": "87620a05-8853-48ae-5196-8b35" } ]
The private_instance_id and tag process_instance_id represent the instance_guid. This also works if you have multiple instances of an application - simply scroll the array in this routing table entry until you see the instance index (the tag instance_id in the output above) you are looking for.
In this scenario, there is no app route in Gorouter routing table, app instance_guid can be located by searching <APP_INTERNAL_ROUTE> in `cfdot actual-lrps` output. Here is a sample output.
{"process_guid":"f86c6aef-b0e6-4138-8ecb-846668746cd4-b271157f-4666-4879-8b5e-a9a52866d60c","index":0,"domain":"cf-apps","instance_guid":"d6639720-64af-45ed-a156-dd74","cell_id":"e2085c46-78e5-408b-91db-2236f78f9cbb","address":"10.1.1.15","ports":[{"container_port":8080,"host_port":61017,"container_tls_proxy_port":61001,"host_tls_proxy_port":61018},{"container_port":8080,"host_port":61017,"container_tls_proxy_port":61443,"host_tls_proxy_port":61019}],"instance_address":"10.5.70.153","preferred_address":"INSTANCE","crash_count":0,"state":"RUNNING","since":1653297014953644532,"modification_tag":{"epoch":"22e983f9-b5b0-4c9c-82ef-8512db2a0902","index":2},"presence":"ORDINARY","actual_lrp_internal_routes":[{"hostname":"<APP_INTERNAL_ROUTE>"}]}
Get app guid: ❯ cf app my-app --guid 7feeb84a-2635-4158-9672-f525b69853c7 Get web process guid: ❯ cf curl /v3/apps/7feeb84a-2635-4158-9672-f525b69853c7/processes/web | jq .guid "e7c6a63b-0e59-4748-a53b-71777d35b925" Get version from v2: ❯ cf curl /v2/apps/7feeb84a-2635-4158-9672-f525b69853c7 | jq .entity.version "9edbfc9a-a4a7-4887-a07f-89d540cf0a03" Get actual LRP from cfdot: # cfdot actual-lrps | jq .process_guid "e7c6a63b-0e59-4748-a53b-71777d35b925-9edbfc9a-a4a7-4887-a07f-89d540cf0a03"