Skip to main content
Question

ServiceNow Event Management

  • 28 May 2024
  • 8 replies
  • 76 views

Hi team,

For sending events from Centreon to ServiceNow instance, i configured servicenow event manager, using the following document.

 https://docs.centreon.com/docs/integrations/event-management/sc-service-now-em-events/.

But, i was unable to get the events  in servicenow instance and in the central-broker-master.log log file, i am getting the error like:

 p2024-05-27T23:55:21.285-05:00] 0lua] uerror] lua: unknown error running function `write'

Do you have any suggestions to help me solve the problem and to get the events in servicenow instance?

 

8 replies

Userlevel 3
Badge +6

Hello :)

This lua error may occures with a large way of possibilities, so to try to isolate it I’ll ask you some questions to help the troubleshooting:
1) After completing the stream connector service-now-em-events in your broker configuration did you export and reload the configuration ? (maybe restart centengine may help because of lua cache).
2) Can you show us the contain of the service-now-em-events logfile (default value suggest in documentation is: /var/log/centreon-broker/servicenow-em-stream-connector.log) ? 

Note : This may not be the case here but often setting a stream connector type option in broker configuration as string while it’s a number option may create issues.

Badge +2

Hi @ldubrunfaut ,

Thanks for your response,

For first question:  

      Yeah, i did export of central server and restarted the centengine using the command

      > systemctl restart cbd

      > systemctl restart cbd centengine

For second one:

    The logs of /var/log/centreon-broker/servicenow-em-stream-connector.log are given below , As the credentials are sensitive data, i am replacing it with ****.

    

Tue May 28 04:07:01 2024: INFO: [sc_params:param_override]: overriding parameter: username with value: ****

Tue May 28 04:07:01 2024: INFO: [sc_params:param_override]: overriding parameter: log_level with value: 1

Tue May 28 04:07:01 2024: INFO: [sc_params:param_override]: overriding parameter: password with value: *****

Tue May 28 04:07:01 2024: INFO: [sc_params:param_override]: overriding parameter: logfile with value: /var/log/centreon-broker/servicenow-em-stream-connector.log

Tue May 28 04:07:29 2024: INFO: [sc_params:param_override]: overriding parameter: log_level with value: 1

Tue May 28 04:07:29 2024: INFO: [sc_params:param_override]: overriding parameter: client_secret with value: ****

Tue May 28 04:07:29 2024: INFO: [sc_params:param_override]: overriding parameter: client_id with value: ****

Tue May 28 04:07:29 2024: INFO: [sc_params:param_override]: overriding parameter: username with value: ****

Tue May 28 04:07:29 2024: INFO: [sc_params:param_override]: overriding parameter: instance with value: ****

Tue May 28 04:07:29 2024: INFO: [sc_params:param_override]: overriding parameter: logfile with value: /var/log/centreon-broker/servicenow-em-stream-connector.log

Tue May 28 04:07:29 2024: INFO: [sc_params:param_override]: overriding parameter: password with value: ****

Tue May 28 10:00:44 2024: INFO: [sc_params:param_override]: overriding parameter: username with value: ****

Tue May 28 10:00:44 2024: INFO: [sc_params:param_override]: overriding parameter: client_id with value: ****

Tue May 28 10:00:44 2024: INFO: [sc_params:param_override]: overriding parameter: password with value: ****

Tue May 28 10:00:44 2024: INFO: [sc_params:param_override]: overriding parameter: logfile with value: /var/log/centreon-broker/servicenow-em-stream-connector.log

Tue May 28 10:00:44 2024: INFO: [sc_params:param_override]: overriding parameter: instance with value: ****

Tue May 28 10:00:44 2024: INFO: [sc_params:param_override]: overriding parameter: client_secret with value: ****

Tue May 28 10:00:44 2024: INFO: [sc_params:param_override]: overriding parameter: log_level with value: 1

     

       

                         

 

    

Userlevel 3
Badge +6

Hello :)

I had set up a VM with Centreon 23.10/EL8 and config the SC following the documentation page. I had create a passive host and passive service only for testing. Because it’s for testing I added the option `send_data_test` to avoid trying to connect in fake url / credentials. My logfile (default name and path suggested by documentation) looks like this:

Wed May 29 09:55:50 2024: INFO: [sc_params:param_override]: overriding parameter: username with value: username
Wed May 29 09:55:50 2024: INFO: [sc_params:param_override]: overriding parameter: client_id with value: client-id
Wed May 29 09:55:50 2024: INFO: [sc_params:param_override]: overriding parameter: instance with value: instance
Wed May 29 09:55:50 2024: INFO: [sc_params:param_override]: overriding parameter: send_data_test with value: 1
Wed May 29 09:55:50 2024: INFO: [sc_params:param_override]: overriding parameter: password with value: ******
Wed May 29 09:55:50 2024: INFO: [sc_params:param_override]: overriding parameter: client_secret with value: client-secret
Wed May 29 09:55:50 2024: INFO: [sc_params:param_override]: overriding parameter: logfile with value: /var/log/centreon-broker/servicenow-em-stream-connector.log
Wed May 29 09:55:50 2024: INFO: [sc_params:param_override]: overriding parameter: log_level with value: 2
Wed May 29 09:55:50 2024: WARNING: [sc_broker:get_instance]: couldn't get instance name from broker cache for instance id: 1
Wed May 29 09:55:50 2024: WARNING: [sc_broker:get_severity]: no severity found in broker cache for host: 9
Wed May 29 09:55:50 2024: WARNING: [sc_broker:get_severity]: no severity found in broker cache for host id: 9 and service id: 7
Wed May 29 09:55:50 2024: INFO: [EventQueue:add]: queue size is now: 1, max is: 1
Wed May 29 09:55:50 2024: WARNING: [sc_broker:get_instance]: couldn't get instance name from broker cache for instance id: 1
Wed May 29 09:55:50 2024: WARNING: [sc_broker:get_severity]: no severity found in broker cache for host: 9
Wed May 29 09:55:50 2024: INFO: [EventQueue:add]: queue size is now: 1, max is: 1
Wed May 29 09:55:50 2024: INFO: EventQueue:send_data: creating json: {"records":[{"node":"Test-SC","event_class":"centreon","severity":0,"source":"centreon","time_of_event":"2024-05-29 07:54:42","resource":"Service-test","description":"OK: Service is OK"}]}
Wed May 29 09:55:50 2024: INFO: [send_data]: {"records":[{"node":"Test-SC","event_class":"centreon","severity":0,"source":"centreon","time_of_event":"2024-05-29 07:54:42","resource":"Service-test","description":"OK: Service is OK"}]} to endpoint: https://instance.service-now.com/api/global/em/jsonv2
Wed May 29 09:55:50 2024: INFO: EventQueue:send_data: creating json: {"records":[{"node":"Test-SC","event_class":"centreon","severity":0,"source":"centreon","time_of_event":"2024-05-29 07:54:42","resource":"Test-SC","description":"OK: Host is OK"}]}
Wed May 29 09:55:50 2024: INFO: [send_data]: {"records":[{"node":"Test-SC","event_class":"centreon","severity":0,"source":"centreon","time_of_event":"2024-05-29 07:54:42","resource":"Test-SC","description":"OK: Host is OK"}]} to endpoint: https://instance.service-now.com/api/global/em/jsonv2

and there is the SC output extract of my configuration : /etc/centreon-broker/central-broker.json

 {
"name": "Servicenow_events",
"path": "/usr/share/centreon-broker/lua/servicenow-em-events-apiv2.lua",
"filters": {
"category": [
"neb"
]
},
"type": "lua",
"lua_parameter": [
{
"type": "string",
"name": "instance",
"value": "instance"
},
{
"type": "string",
"name": "client_id",
"value": "client-id"
},
{
"type": "string",
"name": "client_secret",
"value": "client-secret"
},
{
"type": "string",
"name": "username",
"value": "username"
},
{
"type": "string",
"name": "password",
"value": "password"
},
{
"type": "string",
"name": "logfile",
"value": "/var/log/centreon-broker/servicenow-em-stream-connector.log"
},
{
"type": "number",
"name": "log_level",
"value": "2"
},
{
"type": "number",
"name": "send_data_test",
"value": "1"
}
]
}

Can you check if your log_level in configuration file is “number” as type ?
Can you also show your logfile (hidde credentials again no problem with that) with a log_level set at 2 (for more verbose debug informations) ?

Badge +2

Hi,

Below is my /etc/centreon-broker/central-broker.json file

{

                "name": "Servicenow_events",

                "path": "/usr/share/centreon-broker/lua/servicenow-em-events-apiv2.lua",

                "type": "lua",

                "lua_parameter": [

                    {

                        "type": "string",

                        "name": "instance",

                        "value": "****"

                    },

                    {

                        "type": "string",

                        "name": "client_id",

                        "value": "****"

                    },

                    {

                        "type": "string",

                        "name": "client_secret",

                        "value": "****"

                    },

                    {

                        "type": "string",

                        "name": "username",

                        "value": "****"

                    },

                    {

                        "type": "string",

                        "name": "password",

                        "value": "****"

                    },

                    {

                        "type": "string",

                        "name": "logfile",

                        "value": "****"

                    },

                    {

                        "type": "number",

                        "name": "log_level",

                        "value": "3"

                    }

                ]

           }

Still my /var/log/centreon-broker/servicenow-em-stream-connector.log file is showing the out as same the above case i mentioned in my previous reply.

By adding log statements to the file  /usr/share/centreon-broker/lua/servicenow-em-events-apiv2.lua, i got to know that, error is coming at the line “ request:perform() “ . So, i guess, it was unable to make request from centreon to servicenow instance for making api call. 

Userlevel 3
Badge +6

I’m not sure what you are saying by “adding log statements to the file” but I’ll investigate this line “request:perform()”.
Can you check if all curl commands used in the SC works out of the SC ? This curl commands are provides in the documentation.

Badge +2

I just added log statements as mentioned below, in file “/usr/share/centreon-broker/lua/servicenow-em-events-apiv2.lua” under the function “function EventQueue:call(url, method, data, authToken)”

 local sc_logger1 = require("centreon-stream-connectors-lib.sc_logger")
local self1 = {}
local logfile1 = "/var/log/centreon-broker/central-broker-master.log"
local log_level1 = 3
self1.sc_logger = sc_logger1.new(logfile1, log_level1)
self1.sc_logger:error("Log statement before request perform line")
request:perform()
self1.sc_logger:error("Log statement after request perform line ")

I was unable to get the log statement which are written after the line “request:perform()” line.

Coming to curl command, i tried those commands as mentioned in that documentation, those are working fine i.e using curl commands i was able to get events to servicenow instance.

Userlevel 5
Badge +11

Hi @sukanyadevi,

Please remember to click the “Best Answer” button for the solution that helped you resolve your issue.
Alternatively, you can share with us how you were able to solve the problem.

By doing so, you'll help someone else with the same issue in easily finding the solution.

Thank you,

Userlevel 3
Badge +6

Hello :)

In fact I put this in a side of my head but haven’t the time yet to test it further, I’m not sure my help was enough to solve the issue :/

Reply