Notification for Table inserts sys_outbound_http_log

ewok
Giga Contributor

I am attempting to create a notification that will alert me if we receive a 400 HTTP response code. I am running this notification on the sys_outbound_http_log table with the following parameters. However it doesn't seem to work at all. I have since caused a few HTTP 400 errors and no notifications have been sent. I confirmed from the table itself that new records have been inserted yet no notification is sent. I even went so far as to remove my condition and still no notifications are sent. This notification is in my sub prob instance so i have all emailed forwarded to me rather than their actual users. I also have checked the outbound email log and i don't see anything there either. We are running Kingston patch 4 any suggestions?

 

find_real_file.png

1 ACCEPTED SOLUTION

ewok
Giga Contributor

Well ended up opening up a HI case regarding the problem. It turns out the issue was the table sys_outbound_http_log isn't notifications enabled. Meaning you can't configure notifications for it. 

 

So I went a different route and created the following scheduled job. It actually worked out better because it will create an incident rather than sending an email. What it does is every hour it runs and looks at the table sys_outbound_http_log for HTTP 400 errors and if it finds any it will create an incident for every 400 error it sees. 

 

//Create query filter
var encQuery = 'response_status=400^sys_created_onONCurrent hour@javascript:gs.beginningOfCurrentHour()@javascript:gs.endOfCurrentHour()';


//Check logs to see if there are 400 Errors
var http_logs = new GlideRecord('sys_outbound_http_log');
http_logs.addEncodedQuery(encQuery);
http_logs.query();

//If results set answer to true
while(http_logs.next()){
//Create Incident Glide record
var gr = new GlideRecord('incident');


//Create Incident
gr.initialize();
gr.caller_id = 'ServiceNow svc';
gr.category = 'servicenow';
gr.subcategory = 'other_servicenow';
gr.impact = '3';
gr.urgency = '3';
gr.short_description = "HTTP 400 Errors Detected from " + http_logs.hostname;
gr.description = 'HTTP 400 errors have been detected. Please review table sys_outbound_http_log for details.   \n\nTarget Hostname: ' + http_logs.hostname + '\n\nResponse Body: ' + http_logs.response_body + '\n\nRequest Body: ' + http_logs.request_body + '\n\nCreated: '+ http_logs.sys_updated_on;
gr.u_error_message = 'HTTP 400 errors detected.';
gr.u_troubleshooting_steps_taken = 'N/A I am just a script :)';
gr.insert();
}

View solution in original post

11 REPLIES 11

Thats strange, was able to trigger an email from an insert to this table on my PDI.

Thats strange, was able to trigger an email from an insert to this table on my PDI.

Thats strange, was able to trigger an email from an insert to this table on my PDI.

ewok
Giga Contributor

Here is the direct quote from what i got. I am running Kingston Patch 4 right now and we are still only around 1 year into our instance and started on Istanbul. It is possible if your instance is older you have this setting set to true. What version are you running and what version did your instance start on?

 

Hello Eric,

I had reached out to the Dev team on this and they have confirmed that in the backend code they have "setRunEngines(false)" on the sys_outbound_http_log class.

What this means is that things like business rules and notifications will not be evaluated on this table.
I will open an Enhancement for not listing tables in the drop down when building notifications that have the setRunEngines(false).

I will go ahead and set the state of this incident to 'Solution Proposed', please let me know if you have any further questions.

Ok, will have to check my instance further then. Thanks for sharing the Support reply.