From 4be87f419e6b80295b22b436b37f30c9dc543e9c Mon Sep 17 00:00:00 2001 From: Abhishek Pandey <91930405+bird-03@users.noreply.github.com> Date: Thu, 3 Oct 2024 09:31:26 +0530 Subject: [PATCH 1/2] Create syslog_script.js Fix script to identify TOP 'N' number of records by 'Source' name in any specific duration to optimize and maintain log table health --- .../Syslog_top10Contributors/syslog_script.js | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Fix scripts/Syslog_top10Contributors/syslog_script.js diff --git a/Fix scripts/Syslog_top10Contributors/syslog_script.js b/Fix scripts/Syslog_top10Contributors/syslog_script.js new file mode 100644 index 0000000000..03dd1b917e --- /dev/null +++ b/Fix scripts/Syslog_top10Contributors/syslog_script.js @@ -0,0 +1,23 @@ +/* Create a GlideAggregate on the Syslog table to identify the Top 10 contributors by 'Source name' and 'Number of occurrences on 'Daily' or'any specific interval'. + +This could be vital to maintain the instance performance by regualar optimizing the Syslog table by identifying the top contributors. Based on this syslog table +Could it be reviewed by owners to make the correct decisions on whether logging is required for these tables? + +*/ + +topN('syslog', 'source', 10); //Create a function to identify top 'N' number of records by source. Eg. 10 + +function topN(pTable, pColumn, pCount) { + var ga = new GlideAggregate(pTable); // query on table required + ga.addAggregate('COUNT', pColumn); // Count the number of records by source to record how many times it generated log + ga.orderByAggregate('COUNT', pColumn); + ga.addEncodedQuery('sys_created_onONLast 15 minutes@javascript:gs.beginningOfLast15Minutes()@javascript:gs.endOfLast15Minutes()'); //query for last 15min data + ga.query(); + var i = 0; + var stdout = []; + stdout.push('\nTop ' + pCount + ' ' + pColumn + ' values from ' + pTable + '\n'); + while (ga.next() && (i++ < pCount)) { + stdout.push(ga.getValue(pColumn) + ' ' + ga.getAggregate('COUNT', pColumn)); + } + gs.print(stdout.join("\n")); // display data by 'Sourve' and Number of occurance count +} From 9b296bc618a08639865941f0609651880e02934d Mon Sep 17 00:00:00 2001 From: Abhishek Pandey <91930405+bird-03@users.noreply.github.com> Date: Thu, 3 Oct 2024 09:38:11 +0530 Subject: [PATCH 2/2] Create readme.md This file will detail you the fix script --- Fix scripts/Syslog_top10Contributors/readme.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 Fix scripts/Syslog_top10Contributors/readme.md diff --git a/Fix scripts/Syslog_top10Contributors/readme.md b/Fix scripts/Syslog_top10Contributors/readme.md new file mode 100644 index 0000000000..94c5a1fac7 --- /dev/null +++ b/Fix scripts/Syslog_top10Contributors/readme.md @@ -0,0 +1,5 @@ +Log[syslog] table Optimization Script ( Server Side) + - This fix script will execute on syslog table to identify top '10' contributors in last '15 minutes'. + - This can be altered as per requirement to idenitfy daily top contributors to take action on unnecessary log contibutors + - This will help to maintain the health of log table and reduce load + - It will ultimately contribute to your instance performance and reviewing the transaction occured