How to reset Usage Service by purging Cloud Controller events in VMware Tanzu Application Service (TAS) for VMs
search cancel

How to reset Usage Service by purging Cloud Controller events in VMware Tanzu Application Service (TAS) for VMs

book

Article ID: 297490

calendar_today

Updated On:

Products

VMware Tanzu Application Service for VMs

Issue/Introduction

This article details how to purge and reseed the Usage Service app in VMware Tanzu Application Service (TAS) for VMs.

Warning: Be aware that this process will completely erase the app_usage database, as well as current application events data in Cloud Controller (CC).

Resolution

Note:

push-usage-service-release version 674.0.54 (TAS 4.0.5) brings enhancements and robustness to app-usage-service. 

  • Usage-service has been updated to fix some of causes found for the loss of data.

  • Usage-service has improved diagnostics in the logs for root causing.

  • Warning banner in apps manager when problems is happening aids in timely discovery.

Recommendation is for customers using app-usage service to upgrade to latest patch release of TAS with push-usage-service enhancement.​​​​​​

 

Purge and reseed the data

Warning: This process will completely erase the app_usage database as well as current application events data in Cloud Controller.

See the database table below for details on which data will be deleted. 

1. Using the cf CLI, login to your affected foundation:

cf login -a <your-affected-foundation>


2. Select System Org and System Space:

cf target -o system -s system


3. Stop all three App Usage applications with the following commands:

cf stop app-usage-worker
cf stop app-usage-scheduler
cf stop app-usage-server


4. From the Ops Manager VM, connect to the MySQL server in your affected foundation:

  • Run bosh instances to find the name of your VM.
  • Run bosh ssh mysql/0, where mysql is the name of your VM.

5. Login to the MySQL Database using the root credentials

mysql -u root -p


6. Drop the app_usage_service database.

DROP DATABASE app_usage_service;


7. Recreate an empty database called app_usage_service:

CREATE DATABASE app_usage_service;


8. Destructively purge and reseed the application, task, and Service Usage events in Cloud Controller (CC).

cf curl -X POST /v2/app_usage_events/destructively_purge_all_and_reseed_started_apps

cf curl -X POST /v2/service_usage_events/destructively_purge_all_and_reseed_existing_instances


9. Start the Usage Service applications using the cf CLI in the following order:

cf start app-usage-server
cf start app-usage-scheduler
cf start app-usage-worker 


You should now have the new database populated with the indexes and tables similar to the sample app_usage_service database below.


Sample app_usage_service database:
 

[app_usage_service]> show tables;
 
 Tables_in_app_usage_service
 app_events
 app_events_fetcher_job_run_logs
app_usage_rollover_job_run_logs
daily_app_config_usages
delayed_jobs
 monthly_app_config_usages
 old_app_data_deleter_job_run_logs
 old_service_data_deleter_job_run_logs
 persisted_monthly_usage_summaries
 platform_app_instance_counts
 schema_migrations
 service_events
 service_events_fetcher_job_run_logs
 service_instance_usages
 system_logs
 worker_check_ins