Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Instance scan checks

Madhan007
Tera Contributor

Hi Everyone,

I have to create Instance scan checks and schedule the checks everyday to check -
1. Flow executions throwing an error
2.import set records throwing an error
3.outbound http logs and expiring tokens

I know that i have to create a suite of checks and  schedule the suite. I am not exactly sure how.
If anyone has worked on custom Instance checks or if there are any articles related, will be very helpful.

Thanks in advance!

3 REPLIES 3

GlideFather
Tera Patron

Hi @Madhan007,

 

the instance scan checks for anomalies, if you want to see errors, that would be better to create a scheduled job or a dashboard checking either logs or for example transaction tables (user provisoning)...

 

What flow/table are we talking about?

———
/* If my response wasn’t a total disaster ↙️ drop a Kudos or Accept as Solution ↘️ Cheers! */


Hey @GlideFather , Thanks for your reply.
I need to check  flow executions and import set records failed today, and oAuth tokens expiring this week.
the reason we went with Instance scan checks is that scan tasks referring to failed executions can be created and assigned

MaxMixali
Tera Guru
1) Flow Executions Throwing an Error you need a custom check querying sys_flow_context or sys_flow_execution_detail.
 
Table to Check
 
sys_flow_context → field state = ‘error’
 
 
2) Import Set Records Throwing an Error
 
Table to Check
 
sys_import_set_run or sys_import_set_log
 
 
3) Outbound HTTP Logs + Expiring Tokens
 
A. Check Outbound HTTP Errors
 
Table: sys_outbound_http_request
 
 
you need to create the check for this table: 
use this sample code, adapt it for each table
 
 
(function() {
    var gr = new GlideRecord('sys_flow_context');
    gr.addQuery('state', 'error');
    gr.query();
 
    if (gr.hasNext()) {
        gs.info('Flow execution errors detected: ' + gr.getRowCount());
        return false; // FAIL
    }
 
    return true; // PASS
})();
 
 
 
 
 
 
Once your checks are created:
1.Go to Instance Scan → Scan Jobs → New
2.Choose Tables/Script checks you created
3.Save the Scan Job
4.Go to Schedule related list → New
5.Set:
 
•Run = Daily
•Time = e.g., 02:00 AM
•Active = Yes
 
6.(Optional) Enable Notifications when scan fails.