{"revision":"c10276e953456835cdbb1f3a60d58ae1980be353","document":{"id":30314,"path":"it-operations-management/event-management/configure-em-context-extension.md","title":"Configure the MID WebService Event Collector Context","bundle":null,"doc_type":null,"release":"australia","body":"\n# Configure the MID WebService Event Collector Context\n\nConfigure the MID WebService Event Collector Context to provide a URL method to push event messages from an external source to the MID Server.\n\n## Before you begin\n\nEnsure that the Event Management Connectors \\(sn\\_em\\_connector\\) plugin is installed on the ServiceNow AI Platform instance.\n\nRole required: evt\\_mgmt\\_admin\n\n## About this task\n\nThe default format of the URL to push event messages from an external source to the MID Server is `http://{MID_Server_IP}:{MID_Web_Server_Port}/api/mid/em/jsonv2`. This URL provides good performance.\n\nFrom an external source, to push event messages that are not in jsonv2 format, the format of the URL is: `http://{MID_Server_IP}:{MID_Web_Server_Port}/api/mid/em/inbound_event?Transform={Name_of_Transform_Script}`, where the *\\{Name\\_of\\_Transform\\_Script\\}* variable is the full name of the script and always begins with the text: `TransformEvents_`.\n\nFor example, assume the following values:\n\n-   \\{MID\\_Server\\_IP\\}: 10.118.69.27\n-   \\{MID\\_Web\\_Server\\_Port\\}: 8097\n-   Transform script name: EventsToProcess\n\nThe URL to be used is therefore: `http://10.118.69.27:8097/api/mid/em/inbound_event/TransformEvents_EventsToProcess`\n\n**Note:**\n\n-   The URL in the format `http://{MID_Server_IP}:{MID_Web_Server_Port}/api/mid/em/{transform_script_name}`is also supported.\n-   The date format for events is yyyy-M-d h:mm:ss.\n\n    If you receive an event whose date is in a different format, you must use a `{transform_script_name}` that is appropriate for the incoming event's date format. If you do not, the event will not be processed correctly.\n\n    For example, an event might arrive on June 27, 2019 at 11:25 AM with a listed date of **2019/06/27/ 11:25:00 a**. Use a `{transform_script_name}` with a date format of **yyyy/MM/dd/ HH:mm:ss a** to match the format of the received event.\n\n\n## Procedure\n\n1.  Navigate to **All** &gt; **Event Management** &gt; **Integrations** &gt; **MID WebService Event Listener**.\n\n2.  In the MID WebService Event Collector Contexts list, click **New**.\n\n3.  On the form, fill in the fields.\n\n<table id=\"table_od5_flc_bx\"><thead><tr><th>\n\nField\n\n</th><th>\n\nDescription\n\n</th></tr></thead><tbody><tr><td>\n\nName\n\n</td><td>\n\nA unique name for this collector for easy identification.\n\n</td></tr><tr><td>\n\nShort description\n\n</td><td>\n\nEnter a brief, meaningful description of this collector.\n\n</td></tr><tr><td>\n\nMID Web Server Extension\n\n</td><td>\n\nSpecify and then start the MID Web Server extension. The supported authentication methods are listed in the **Authentication Type** field of the MID Web Server extension. For information about how to configure a MID Web Server extension, see [Configure the MID Web Server](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/it-operations-management/event-management/configure-mid-web-server-extension.md).\n\n</td></tr><tr><td>\n\nStatus\n\n</td><td>\n\nThis field is auto-populated with the status of the MID Web Server extension. This field is blank until the MID Web Server extension is started. After issuing a command to the MID Web Server extension, one of the following values is displayed: -   **Started**: The collector is running.\n-   **Stopped**: The collector is not running.\n-   **Offline**: The MID Server is down.\n-   **Error**: The collector failed with an error \\(the error message is displayed in **Error Message**\\).\n-   **Warning**: A run-time exception has occurred.\n\n\n</td></tr><tr><td>\n\nExecute on\n\n</td><td>\n\n**Specific MID Server** or **Specific MID Server Cluster**, as defined on the specified MID Web Server extension.**Note:** **Specific MID Server Cluster** is only for internal processing of ECC queue record and is not for external API load balancing.\n\n</td></tr><tr><td>\n\nMID Server\n\n</td><td>\n\nThe **Specific MID Server** or **Specific MID Server Cluster**, as defined on the specified MID Web Server extension.\n\n</td></tr><tr><td>\n\nExecuting on\n\n</td><td>\n\nThe name of the MID Server on which the MID Web Server extension is running.\n\n</td></tr></tbody>\n</table>4.  Right-click the form heading and click **Save**.\n\n5.  Under **Related Links**, click **Start** to start the collector.\n\n    |Related Link|Description|\n    |------------|-----------|\n    |Start|If it is not running, start the collector. This action verifies that a web service API endpoint with the Event Management application is running on the MID Server.|\n    |Stop|Stops the running collector on the configured MID Server. If the collector is not running, no action is taken.|\n    |Restart|Stops, then starts the collector on the configured MID Server.|\n    |Update parameters|Sends updated parameters to the collector. Parameters are also updated when the Event Management MID Server context extension is updated. If you click this control when the collector is not running, no update is made.|\n\n\n## Example\n\n**Showing the use of the URL to transform JSON v2 formatted event messages**\n\nAssume that JSON v2 formatted event messages are sent to the MID Server. When using the `jsonv2` URL, there is no need to use a script include.\n\n|Field|Value|\n|-----|-----|\n|MID\\_Server\\_IP|10.218.64.27|\n|MID\\_Web\\_Server\\_Extension\\_Port|8097|\n|Event message format|jsonv2|\n\nReplace the variables in the default format of the URL `http://<my-instance>.service-now.com/api/global/em/jsonv2`with values from the preceding table:`http://10.218.64.27:8097/api/global/em/jsonv2`\n\n**Example showing the URL to push messages not in jsonv2 format**\n\nThe format of the URL to push event messages from an external source that are not in jsonv2 format is `http://{MID_Server_IP}:{MID_Web_Server_Port}/api/mid/em/inbound_event/Transform={Name_of_Transform_Script}`. The \\{Name\\_of\\_Transform\\_Script\\} variable is the full name of the script and always begins with the text: TransformEvents\\_. Specify the script name as the `Transform` header parameter and always start with the prefix `TransformEvents_`.\n\nFor this example, assume that the script name is EventsToProcess, the URL is therefore:`http://10.138.64.27:8097/api/mid/em/inbound_event/TransformEvents_EventsToProcess`\n\n**Example showing JSON v2 formatted event messages**\n\n**Note:** When copying and pasting the text following, hidden characters might also be copied and can cause unexpected results.\n\n```\n\ncurl -v -H \"Accept: application/json\" -H \"Content-Type: application/json\" -X POST --data \"{\n    \\\"records\"\\:\n    [ {\n         \\\"source\\\" : \\\"Simulated\\\",\n        \\\"node\\\" : \\\"nameofnode\\\",\n        \\\"type\\\" : \\\"High Virtual Memory\\\",\n        \\\"resource\\\" : \\\"C:\\\",\n        \\\"severity\\\" : \\\"5\\\",\n        \\\"description\\\" : \\\"Virtual memory usage exceeds 98%\\\",\n        \\\"ci_type\\\":\\\"cmdb_ci_app_server_tomcat\\\",\n        \\\"additional_info\\\":\\\"{\\\\\\\"name\\\\\\\":\\\\\\\"My Airlines\\\\\\\"}\\\"\n      },\n      {\n      \\\"source\\\" : \\\"Simulated\\\",\n      \\\"node\\\" : \\\"01.myairlines.com\\\",\n      \\\"type\\\" : \\\"High CPU Utilization\\\",\n      \\\"resource\\\" : \\\"D:\\\",\n      \\\"severity\\\" : \\\"5\\\",\n      \\\"description\\\" : \\\"CPU on 01.my.com at 60%\\\"\n      }\n   ]\n}\" -u UserName:Password http://{MID_Server_IP}:{MID_Web_Server_Port}/api/mid/em/jsonv2\n\n```\n\n## Example\n\n**Example showing JSON v2 formatted event messages with MID Web Server API key**\n\n**Note:** When copying and pasting the text following, hidden characters might also be copied and can cause unexpected results.\n\n```\n\ncurl --location -g --request POST 'http://{MID_Server_IP}:{MID_Web_Server_Port}/api/mid/em/jsonv2' \\\n--header 'Accept: application/json' \\\n--header 'Content-Type: application/json' \\\n--header 'Authorization: key <mid_webserver_api_key>' \\\n--data-raw '{\n   \"records\":\n    [ {\n         \\\"source\\\" : \\\"Simulated\\\",\n        \\\"node\\\" : \\\"nameofnode\\\",\n        \\\"type\\\" : \\\"High Virtual Memory\\\",\n        \\\"resource\\\" : \\\"C:\\\",\n        \\\"severity\\\" : \\\"5\\\",\n        \\\"description\\\" : \\\"Virtual memory usage exceeds 98%\\\",\n        \\\"ci_type\\\":\\\"cmdb_ci_app_server_tomcat\\\",\n        \\\"additional_info\\\":\\\"{\\\\\\\"name\\\\\\\":\\\\\\\"My Airlines\\\\\\\"}\\\"\n      },\n      {\n      \\\"source\\\" : \\\"Simulated\\\",\n      \\\"node\\\" : \\\"01.myairlines.com\\\",\n      \\\"type\\\" : \\\"High CPU Utilization\\\",\n      \\\"resource\\\" : \\\"D:\\\",\n      \\\"severity\\\" : \\\"5\\\",\n      \\\"description\\\" : \\\"CPU on 01.my.com at 60%\\\"\n      }\n   ]\n}'\n```\n\n## Configuring external API integrations with MID Server failover\n\nTo ensure high availability for external API integrations, deploy an external load balancer that distributes traffic across multiple MID servers. Note that the MID cluster web server configuration handles internal processing only \\(through ecc\\_queue\\) and can't manage inbound external API traffic.\n\n|Field|Value|\n|-----|-----|\n|MID Server 1|mid-1.internal:8080|\n|MID Server 2|mid-2.internal:8080|\n|External Load Balancer|mid-cluster.example.com:443|\n|API endpoint format|jsonv2|\n\nReference the external load balancer hostname in your webhook URL rather than individual MID Server addresses. Replace the variables in the default format: `https://<load-balancer>/api/mid/em/inbound_event?Transform=<format>` with values from the preceding table: `https:///mid-cluster.example.com/api/mid/em/inbound_event?Transform=jsonv2`.\n\nThis configuration distributes incoming requests across both MID servers. If one server becomes unavailable, the load balancer automatically routes traffic to the remaining operational server without service interruption.\n\n**Related topics**  \n\n\n[Configure the MID Web Server extension](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/it-operations-management/event-management/configure-mid-web-server-extension.md)\n\n[Event collection from BMC TrueSight](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/it-operations-management/event-management/event-collection-BMCTrueSight.md)\n\n[Event collection from Microsoft Azure Monitor](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/it-operations-management/event-management/event-collection-MicrosoftAzure.md)\n\n[Event collection from Google Cloud Platform](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/it-operations-management/event-management/event-collection-GCP.md)\n\n"}}