Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sn ap2024 01 #1114

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Fix scripts/Syslog_top10Contributors/readme.md
Original file line number Diff line number Diff line change
@@ -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
23 changes: 23 additions & 0 deletions Fix scripts/Syslog_top10Contributors/syslog_script.js
Original file line number Diff line number Diff line change
@@ -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
}
Loading