AppCenter Logging App: A Home Grown Approach

Learn Aster
Teradata Employee

I am sure there are much better approaches to doing this but I wanted to share it anyway.  I also know there is logging built in but I wanted an easier way to make this possible. 

What if I wanted to track the amount of times an appcenter application is executed?  Or what if I wanted to track overlap and concurrency of apps executed?  What if I wanted to run analytics on how long an app runs and do analytics on Aster.  You will need to be running on the latest edition of AppCenter, this may not work on the initial release. 

Here is a solution to make that possible:

1.  Build a Table:

CREATE FACT TABLE public.appcenter_log  (

  id varchar(1000) NULL,

  appdate timestamp NULL,

    appname     varchar(300),

  notes       varchar(1000) NULL

  )

  DISTRIBUTE BY HASH (id)

  STORAGE ROW

  COMPRESS LOW

This is the table that will hold the state of AppCenter App runs.

2.  Then add two lines of code to your app:

--ADD THIS LINE IN TO GET THE STARTING TIME OF THE APP:

insert into public.appcenter_log values('%uniqueId%'::VARCHAR, current_timestamp, 'THIS IS MY APPNAME', 'APP START');

--APPCODE GOES HERE:

DROP VIEW IF EXISTS public.vw_retail_sub_affinity;

--PRODUCT SUBTYPE CD AFFINITY

SELECT *

FROM cfilter (

ON (SELECT 1)

PARTITION BY 1

INPUTTABLE('vw_retail_activity_detail_batch')

OUTPUTTABLE('retail_product_subtype_cf')

INPUTCOLUMNS('product_subtype_cd')

JOINCOLUMNS('batch_id')

DROPTABLE('true')

);

---ADDITIONAL CODE

--ADD THIS LINE IN TO GET THE ENDING TIME OF THE APP:

insert into public.appcenter_log values('%uniqueId%'::VARCHAR, current_timestamp, 'THIS IS MY APPNAME', 'APP END');

3. Build reports and analytics as needed.