SYS Audit Table Management & Best Practices

cloudboy
ServiceNow Employee
ServiceNow Employee

Hello ,

We are facing issues of Activity stream loading while opening any record from the list view, during our analysis we found that there are huge entries in sys_audit table and its loading take huge time, approx > 20K records are for one table and corresponding doc key, i have written below fix script which executes in 3 hrs , for finding the huge entries also for 1 record deletion from sys audit took 2 hours. Would like to know whats the best practice to fix the problem here..

 

var threshHoldAudit=3000; 

var agg = new GlideAggregate('sys_audit');

agg.addAggregate('count');

agg.addQuery("tablename","tsp1_project")

agg.groupBy('documentkey');

agg.query();

while (agg.next()) {

var currAggVal = agg.getAggregate('count');

if(currAggVal > threshHoldAudit)

gs.info('#WARNING: Audit for docKey ' + agg.documentkey + ' is having = ' + currAggVal + " Records");

}

What should be the min entries in sys audit table for specific dockey/sys_id and how we can delete/purge them periodically?

Thanks.

 

5 REPLIES 5

Hi,

I believe then those might be coming for TASK table activity since these tables are extended from TASK.

If you want to create the one, you might want to customize the activities by following below link and then check in system properties, if you see the property got created for the table in question. Remember, when you customize the activity, those changes are reflected back to property for that table

 

https://docs.servicenow.com/bundle/helsinki-platform-administration/page/administer/form-administrat...