How locate an app instance_guid in VMware Tanzu Application Service for VMs
search cancel

How locate an app instance_guid in VMware Tanzu Application Service for VMs

book

Article ID: 298007

calendar_today

Updated On:

Products

VMware Tanzu Application Service for VMs

Issue/Introduction

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:

  • app_guid940b24d3-1b0a-4534-a1bd-a5ec6ee61703
  • process_guid940b24d3-1b0a-4534-a1bd-a5ec6ee61703-9f59a95c-7f77-4ed4-9492-459ce17ea3fe

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.


Environment

Product Version: 2.7

Resolution

In the case process_guid and app_guid do not match, there are two scenarios: 

Scenario 1 - the app has public route

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

2. Open the newly created /tmp/routes.json file and search for your application's routing table entry by the application's route.

Note: It is also possible to find the entry by the application's app_guid here as well, but depending on your TAS version, the tag may or may not be available. In either case, searching by the application route should be sufficient.

After opening the file, and searching for the route, you see the following routing table entry:
  "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.

Scenario 2 - the app has only internal route

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>"}]}

Alternatively:

We can locate the process_guid in `cfdot actual-lrps` output based on the web process guid and version from the API. For example:
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"