How "Instance Time (hrs)" is being calculated for Apps running on TAS (Tanzu Application Service)
search cancel

How "Instance Time (hrs)" is being calculated for Apps running on TAS (Tanzu Application Service)

book

Article ID: 399196

calendar_today

Updated On:

Products

VMware Tanzu Application Service

Issue/Introduction

Customers might be interested to understand how "Instance Time (hrs)" is being calculated for Apps running on TAS (Tanzu Application Service) and know whether the number is correct or not.

Resolution

The quickest way to validate is to retrieve the usage data from the database and do the calculation. Here is an example procedure. 

1. SSH into a mysql server instance and switch to the Root user. Reference How to connect to the VMware Tanzu Application Service (TAS) for VMs internal MySQL database for more details.

$ bosh -d $(bosh ds --column=name | grep cf-) ssh mysql/0 

$ sudo -i

2. Connect to the database.

mysql --defaults-file=/var/vcap/jobs/pxc-mysql/config/mylogin.cnf

3. Select the app_usage_service database.

mysql> USE app_usage_service;

4. Basically "Instance Time (hrs)" is the the (sum of (instance_count * duration_in_seconds)) / 3600

So to calculate for a particular application, run the following query. (Application name in this sample is spring-music. Change it to your own application name accordingly.)

mysql> SELECT SUM(instance_count*duration_in_seconds)/3600 FROM monthly_app_config_usages WHERE app_name="spring-music" group by app_name;
+----------------------------------------------+
| SUM(instance_count*duration_in_seconds)/3600 |
+----------------------------------------------+
|                                     928.5214 |
+----------------------------------------------+
1 row in set (0.00 sec)

 This is also the value being displayed in the App Manager UI > Organization > Usage Report page.

If there is a need to calculate for apps running on TAS, then you might want to run the following query.

mysql> SELECT app_name, sum(instance_count * duration_in_seconds)/3600 FROM monthly_app_config_usages group by app_name;
+-------------------------------+------------------------------------------------+
| app_name                      | sum(instance_count * duration_in_seconds)/3600 |
+-------------------------------+------------------------------------------------+
| app-usage-worker-venerable    |                                       126.1053 |
| app-usage-scheduler-venerable |                                       126.1053 |
| app-usage-server-venerable    |                                       252.2106 |
| p-invitations-green           |                                       252.2339 |
| search-server-green           |                                       252.2317 |
......
| spring-music                  |                                       928.5214 |
+-------------------------------+------------------------------------------------+
28 rows in set (0.00 sec)