|
| 1 | +## Description |
| 2 | + |
| 3 | +This shell script ([**alerts_to_bhom.sh**](alerts_to_bhom.sh)) sends BMC Helix Control-M alerts as events to BMC Helix Operations Management. |
| 4 | + |
| 5 | +It parses the alert data coming from Helix Control-M (**HCTM**) into JSON format, and then sends it to Helix Operations Management (**BHOM**) using its event ingestion API. The JSON data is structured according to an event class which has to be previously created in BHOM. |
| 6 | + |
| 7 | +## Pre-requisites |
| 8 | + |
| 9 | +- **Configure the HCTM "External Alert Management" service** from the Automation API to execute the script every time an alert is raised. |
| 10 | + |
| 11 | + - For more information, check the HCTM documentation for [Setting Up External Alerts](https://documents.bmc.com/supportu/controlm-saas/en-US/Documentation/Alerts.htm#SettingUpExternalAlerts) and the HCTM Automation API documentation for [External Alert Management](https://docs.bmc.com/docs/saas-api/run-service-941879047.html#Runservice-alert_managementExternalAlertManagement). |
| 12 | + |
| 13 | + - As explained in the documentation, you need to use "run alerts:listener:script::set" to define the path to the script - and then open the alerts stream and start the alerts listener process. |
| 14 | + |
| 15 | +- **Create a new Event Class in BHOM**, using the definition from the [**bhom_ctm_event_class.json**](bhom_ctm_event_class.json) file. |
| 16 | + |
| 17 | + This event class called "**ControlMAlert**" includes all the required fields from the HCTM alert data, plus one additional field to include a link to the job that generated the alert (when applicable). It also inherits all fields from its parent classes "IIMonitorEvent", "MonitorEvent" and the "Event" base class (check the BHOM documentation on [Event classification and formatting](https://docs.bmc.com/docs/helixoperationsmanagement/231/event-classification-and-formatting-1160751038.html) for more details). |
| 18 | + |
| 19 | + - To create the event class, contact your BHOM administrator or follow the documentation for [Event management endpoints in the REST API](https://docs.bmc.com/docs/helixoperationsmanagement/231/event-management-endpoints-in-the-rest-api-1160751462.html) (*remember to select your product version*), and use the "POST /events/classes" endpoint. |
| 20 | + |
| 21 | + - If the "IIMonitorEvent" event class is not available in your BHOM environment, you can update the json file to use the "MonitorEvent" class instead. |
| 22 | + |
| 23 | +- **Import an Event Policy in BHOM**, using the [**bhom_ctm_event_policy.json**](bhom_ctm_event_policy.json) file. **[OPTIONAL]** |
| 24 | + |
| 25 | + This event policy can be useful when alerts are also managed from HCTM (e.g. when an operator uses the HCTM web interface to close an alert, modify the urgency or add a comment), and we want to automatically reflect those changes in BHOM. If the HCTM alerts are only going to be managed from BHOM, there is no need to import this event policy. |
| 26 | + |
| 27 | + Depending on the case, remember to set the "**alert_updates**" variable in the script accordingly (Y/N). If set to "N", alert updates are not sent to BHOM (and the policy will never apply, even if imported). If set to "Y", it is recommended to use the policy to avoid creating duplicate events in BHOM every time the alert details are updated from HCTM. |
| 28 | + |
| 29 | + The event policy will automatically 1) update existing events coming from HCTM if they already exist in BHOM (which happens when the alert "Status", "Urgency" or "Comment" are updated in HCTM), 2) map the status from the HCTM alert to the BHOM event (e.g. close the event in BHOM if the alert is closed in HCTM), and 3) record the last alert comment into the BHOM notes history. Be aware that, if the event is closed in BHOM and the associated alert is updated from HCTM, a new event (with the same "alertId") will be created. |
| 30 | + |
| 31 | + - To import the event policy from the BHOM console, go to the "Configuration" menu and select "Event Policies", click on the import button (located on the top right corner, right to the "Create" button) and attach the json file. Once imported, remember to select the policy name and click on the "Enable" button. |
| 32 | + |
| 33 | + - To import the event policy using the API, follow the BHOM documentation for [Event policy management endpoints in the REST API](https://docs.bmc.com/docs/helixoperationsmanagement/231/event-policy-management-endpoints-in-the-rest-api-1160751484.html), and use the "POST /event_policies" endpoint. |
| 34 | + |
| 35 | +## Instructions |
| 36 | + |
| 37 | +Before using the script, update the following variables: |
| 38 | + |
| 39 | +- **hctm_url** : enter the URL for the HCTM tenant (e.g. "*https://\<tenant name\>.us1.controlm.com*"). |
| 40 | +- **hctm_name** : the default is "Helix Control-M", but can be updated to e.g. use different names for multiple HCTM environments (the value is assigned to the BHOM "location" field). |
| 41 | +- **bhom_url** : enter the URL for the BHOM event data endpoint (e.g. "*https://\<BMC Helix Portal URL\>/events-service/api/v1.0/events*"), as described in the BHOM documentation for [Policy, event data, and metric data management endpoints in the REST API](https://docs.bmc.com/docs/helixoperationsmanagement/231/policy-event-data-and-metric-data-management-endpoints-in-the-rest-api-1160751457.html). |
| 42 | +- **bhom_api_key** : enter a valid BHOM API key, which you can obtain from the BHOM console in the "Administration" menu, selecting "Repository" and clicking on "Copy API Key". |
| 43 | +- **sev_V/U/R** : update the three variables to set the HCTM to BHOM correspondence for the "severity" field according to your preferences (alerts coming from HCTM can be Very urgent, Urgent or Regular; while BHOM event severity can be CRITICAL, MAJOR, MINOR, WARNING, INFO, OK or UNKNOWN). |
| 44 | +- **alert_updates** : select whether you want to send or not updates of existing HCTM alerts to BHOM (which happens when the alert "Status", "Urgency" or "Comment" are updated in HCTM). |
| 45 | + |
| 46 | +Do NOT modify the following variables: |
| 47 | + |
| 48 | +- **bhom_class** : leave as is to use the previously imported "ControlMAlert" event class. |
| 49 | +- **alert_fields** : leave as is to use the default field names for HCTM alerts. If you have previously modified the JSON template for alerts in HCTM, restore the default alert fields (as documented in the [Alerts Template reference](https://docs.bmc.com/docs/saas-api/alerts-template-reference-1144242602.html)). |
| 50 | +- **bhom_slots** : leave as is to use the default event slots defined in the "ControlMAlert" class. |
| 51 | + |
| 52 | +## Additional information |
| 53 | + |
| 54 | +- The integration has been tested with: |
| 55 | + |
| 56 | + - BMC Helix Control-M 9.0.21.080 |
| 57 | + - BMC Helix Operations Management 23.1 |
| 58 | + |
| 59 | +- You can create an **Event Group** in BHOM to show HCTM alerts only: |
| 60 | + |
| 61 | + - In the BHOM console, go to the "Configuration" menu, select "Groups" and click on "Create". |
| 62 | + - In the "Group Information" section, enter the group name (e.g. "Helix Control-M") and a description. |
| 63 | + - In the "Selection Query" section, go to "Event Selection Criteria" and add "Class Equals ControlMAlert". |
| 64 | + - Save the Group. Now you can go to the "Monitoring" menu, select "Groups" and click on the one you just created to view only events related to HCTM. |
| 65 | + |
| 66 | +- You can create a custom **Table View** in BHOM to show any HCTM alert fields of your choice in the "Events" or "Groups" dashboards. |
| 67 | + |
| 68 | + - Follow the steps in the BHOM documentation for [Creating table views](https://docs.bmc.com/docs/helixoperationsmanagement/231/creating-table-views-1160750840.html). |
| 69 | + - For example, a custom table view can be used to show the "jobLink" field in the main event dashboard, which when clicked will open the HCTM web interface with a monitoring viewpoint showing the problematic job and its neighborhood (when the alert is related to a job, and as long as the user is already logged in the HCTM web interface). |
| 70 | + |
| 71 | +- If you get the error "*curl: (48) An unknown option was passed in to libcurl*" when testing the script, uncomment the following line: |
| 72 | + |
| 73 | + ``export LD_LIBRARY_PATH="/usr/lib64:$LD_LIBRARY_PATH"`` |
| 74 | + |
| 75 | +- The following table shows the correspondence between the HCTM alert fields and the BHOM event slots (defined in the "ControlMAlert" class or inherited from its parent classes), plus additional information for fields which are modified in the script. |
| 76 | + |
| 77 | + For more information on the HCTM alert fields, check the [Alerts Template reference](https://docs.bmc.com/docs/saas-api/alerts-template-reference-1144242602.html) documentation. |
| 78 | + |
| 79 | + | HCTM alert field | BHOM event slot | Comments | |
| 80 | + | - | - | - | |
| 81 | + | ``eventType`` | ``eventType`` | | |
| 82 | + | ``id`` | ``alertId`` | | |
| 83 | + | ``server`` | ``ctmServer`` | | |
| 84 | + | ``fileName`` | ``fileName`` | | |
| 85 | + | ``runId`` | ``runId`` | | |
| 86 | + | ``severity`` | ``severity`` | The value is updated to map the HCTM to BHOM correspondence. Not included in the "ControlMAlert" class, as it is inherited from the base class "Event". | |
| 87 | + | ``status`` | ``alertStatus`` | | |
| 88 | + | ``time`` | ``creation_time`` | The value is converted to the format expected by BHOM (Epoch time, in milliseconds). Not included in the "ControlMAlert" class, as it is inherited from the base class "Event". | |
| 89 | + | ``user`` | ``ctmUser`` | | |
| 90 | + | ``updateTime`` | ``updateTime`` | The value is converted to the format expected by BHOM (Epoch time, in milliseconds). | |
| 91 | + | ``message`` | ``msg`` | Not included in the "ControlMAlert" class, as it is inherited from the base class "Event". | |
| 92 | + | ``runAs`` | ``runAs`` | | |
| 93 | + | ``subApplication`` | ``subApplication`` | | |
| 94 | + | ``application`` | ``application`` | | |
| 95 | + | ``jobName`` | ``jobName`` | | |
| 96 | + | ``host`` | ``source_hostname`` | When the alert "host" value is empty, it defaults to the "source_identifier" event slot. Not included in the "ControlMAlert" class, as it is inherited from the base class "Event". | |
| 97 | + | ``type`` | ``alertType`` | | |
| 98 | + | ``closedByControlM`` | ``closedByControlM`` | | |
| 99 | + | ``ticketNumber`` | ``ticketNumber`` | | |
| 100 | + | ``runNo`` | ``runNo`` | | |
| 101 | + | ``notes`` | ``alertNotes`` | | |
| 102 | + | | ``jobLink`` | Additional slot included in the "ControlMAlert" class, which value is defined in the script using the HCTM tenant URL, runId, ctmServer and jobName. | |
| 103 | + | | ``location`` | The value is defined in the script using the "hctm_name" variable. Not included in the "ControlMAlert" class, as it is inherited from the base class "Event". | |
| 104 | + | | ``source_identifier`` | The value is defined in the script using the HCTM tenant URL (removing the "https://"). Not included in the "ControlMAlert" class, as it is inherited from the base class "Event". | |
| 105 | + |
| 106 | +- The script could be modified to also include the ``external_id`` slot from the "IIMonitorEvent" class, in order to associate the event with a CI (configuration item).* |
| 107 | + |
| 108 | +## Versions |
| 109 | + |
| 110 | +| Date | Updated by | Changes | |
| 111 | +| - | - | - | |
| 112 | +| 2023-03-18 | David Fernández | First release | |
0 commit comments