Skip to content

Commit 5d49cd2

Browse files
authored
Sn ap2024 01 (#1114)
* 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 * Create readme.md This file will detail you the fix script
1 parent 54d5215 commit 5d49cd2

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Log[syslog] table Optimization Script ( Server Side)
2+
- This fix script will execute on syslog table to identify top '10' contributors in last '15 minutes'.
3+
- This can be altered as per requirement to idenitfy daily top contributors to take action on unnecessary log contibutors
4+
- This will help to maintain the health of log table and reduce load
5+
- It will ultimately contribute to your instance performance and reviewing the transaction occured
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/* 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'.
2+
3+
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
4+
Could it be reviewed by owners to make the correct decisions on whether logging is required for these tables?
5+
6+
*/
7+
8+
topN('syslog', 'source', 10); //Create a function to identify top 'N' number of records by source. Eg. 10
9+
10+
function topN(pTable, pColumn, pCount) {
11+
var ga = new GlideAggregate(pTable); // query on table required
12+
ga.addAggregate('COUNT', pColumn); // Count the number of records by source to record how many times it generated log
13+
ga.orderByAggregate('COUNT', pColumn);
14+
ga.addEncodedQuery('sys_created_onONLast 15 minutes@javascript:gs.beginningOfLast15Minutes()@javascript:gs.endOfLast15Minutes()'); //query for last 15min data
15+
ga.query();
16+
var i = 0;
17+
var stdout = [];
18+
stdout.push('\nTop ' + pCount + ' ' + pColumn + ' values from ' + pTable + '\n');
19+
while (ga.next() && (i++ < pCount)) {
20+
stdout.push(ga.getValue(pColumn) + ' ' + ga.getAggregate('COUNT', pColumn));
21+
}
22+
gs.print(stdout.join("\n")); // display data by 'Sourve' and Number of occurance count
23+
}

0 commit comments

Comments
 (0)