AZURE / EVENT Management

Jonny Lord
Giga Contributor

Hey Guys,

We have integrated many monitoring tools successfully into our new ServiceNow instance.

I'm stuck with my Azure Events coming into ServiceNow - i have them coming in via a web hook with the configuration suggested here: https://docs.servicenow.com/bundle/london-it-operations-management/page/product/event-management/task/azure-events-transform-script.html

I can confirm that Azure alerts are coming into ServiceNow but are not populating the Event table.
They are infact populating the logs files with the event message...immediately followed by another log entry with the same timestamp with the source as "com.glide.ui.ServletErrorListener"  and payload as;

JavaScript evaluation error on:
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
var body = GlideStringUtil.getStringFromStream(request.body.dataStream);
 var queryParams = request.queryParams;
 var source = queryParams['source'] ? queryParams['source'][0] : '';
 var headers = request.headers;
 delete headers["authorization"]; // dont save the base64 user/password
 var gr;
 if (gs.getProperty('cloud.event.debug') == 'true') {
  gr = new GlideRecord('em_connector_push_debug');
  gr.body = body;
  gr.source = source;
  var hstr = JSON.stringify(headers);
  gr.headers = hstr;
  gr.query_params = JSON.stringify(queryParams);
  gr.url = request.uri;
  gr.insert();
 }
 
 gr = new GlideRecord('em_connector_push');
 gr.addActiveQuery();
 gr.addQuery('type', 1);
    gr.addQuery('source', 'azure');
 gr.orderBy('order');
 gr.query();
 var results = {};var exception;
 while (gr.next()) {
  var procSource = gr.getValue('source');
  var procName = gr.getValue('name');

   var script = gr.getValue('script');
   gs.debug('Executing event processing script: ' + procName);
   var evaluator = new GlideScopedEvaluator();
   evaluator.putVariable('request', request);
   evaluator.putVariable('body', body);
   evaluator.putVariable('status', 200);
    var res = evaluator.evaluateScript(gr, 'script');
   if(evaluator.getVariable('status')!==200){
    exception=new sn_ws_err.ServiceError().setStatus(evaluator.getVariable('status'));
    exception.setMessage(procName+" : "+ res);
    throw exception;
   }
   
    
    results[procName] = res;
   return results;
   //}
 }
 
 exception=new sn_ws_err.ServiceError().setStatus(400);
 exception.setMessage('No Transform script found for given header or source ');
 throw exception;
})(request, response);
: org.mozilla.javascript.JavaScriptException: [object ServiceError] (sys_ws_operation.648f0381672132001e91c44d2685ef6e.operation_script; line 40): org.mozilla.javascript.gen.sys_ws_operation_648f0381672132001e91c44d2685ef6e_operation_script_4974._c_process_1(sys_ws_operation.648f0381672132001e91c44d2685ef6e.operation_script:40)
org.mozilla.javascript.gen.sys_ws_operation_648f0381672132001e91c44d2685ef6e_operation_script_4974.call(sys_ws_operation.648f0381672132001e91c44d2685ef6e.operation_script)
org.mozilla.javascript.ScriptRuntime.doCall2(ScriptRuntime.java:2650)
org.mozilla.javascript.ScriptRuntime.doCall(ScriptRuntime.java:2590)
org.mozilla.javascript.optimizer.OptRuntime.call2(OptRuntime.java:42)
org.mozilla.javascript.gen.sys_ws_operation_648f0381672132001e91c44d2685ef6e_operation_script_4974._c_script_0(sys_ws_operation.648f0381672132001e91c44d2685ef6e.operation_script:1)
org.mozilla.javascript.gen.sys_ws_operation_648f0381672132001e91c44d2685ef6e_operation_script_4974.call(sys_ws_operation.648f0381672132001e91c44d2685ef6e.operation_script)
org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:563)
org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3428)
org.mozilla.javascript.gen.sys_ws_operation_648f0381672132001e91c44d2685ef6e_operation_script_4974.call(sys_ws_operation.648f0381672132001e91c44d2685ef6e.operation_script)
org.mozilla.javascript.gen.sys_ws_operation_648f0381672132001e91c44d2685ef6e_operation_script_4974.exec(sys_ws_operation.648f0381672132001e91c44d2685ef6e.operation_script)
com.glide.script.ScriptEvaluator.execute(ScriptEvaluator.java:279)
com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:118)
com.glide.script.ScriptEvaluator.evaluateString(ScriptEvaluator.java:82)
com.glide.script.fencing.GlideScopedEvaluator.evaluateScript(GlideScopedEvaluator.java:309)
com.glide.script.fencing.GlideScopedEvaluator.evaluateScript(GlideScopedEvaluator.java:214)
com.glide.script.fencing.GlideScopedEvaluator.evaluateScript(GlideScopedEvaluator.java:201)
com.glide.rest.service.custom.CustomService.runScript(CustomService.java:95)
com.glide.rest.service.custom.CustomService.execute(CustomService.java:82)
com.glide.rest.handler.impl.ServiceHandlerImpl.invokeService(ServiceHandlerImpl.java:36)
com.glide.rest.processors.RESTAPIProcessor.process(RESTAPIProcessor.java:271)
com.glide.processors.AProcessor.runProcessor(AProcessor.java:483)
com.glide.processors.AProcessor.processTransaction(AProcessor.java:205)
com.glide.processors.ProcessorRegistry.process0(ProcessorRegistry.java:178)
com.glide.processors.ProcessorRegistry.process(ProcessorRegistry.java:167)
com.glide.ui.GlideServletTransaction.process(GlideServletTransaction.java:31)
com.glide.sys.Transaction.run(Transaction.java:2038)
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
java.lang.Thread.run(Thread.java:748)

 

What should the header be based on events coming in via a Listener transform script?
The header name and header value fields are none mandatory and i have no clue what they need to be, if in fact this is the issue. Any other direction would be great.

Thanks Guys.

 

 

1 ACCEPTED SOLUTION

Jonny Lord
Giga Contributor

Awesome, i will check this out.
Thanks!

View solution in original post

13 REPLIES 13

Jonny Lord
Giga Contributor

Nick - This worked - Thanks very much

Hey Johnny,

 

Would you mind sharing how you ended up solving this? We are in a similar boat here.

 

Thanks,

-Dom

Hi Jonny Can you help us to understand what kind of changes you have done to resolve it. Waiting for kind response ☺☺☺