Extracting notifications from Monitoring to IBM Cloud Event Streams
You can extract notifications from Monitoring to IBM Cloud Event Streams by using the Event Streams REST API.
Complete the following steps:
Step 1. Provision an Event Streams instance and provision a topic
Complete the following steps:
- Provision an Event Streams instance with an Enterprise Plan. Ensure that the Event Streams instance uses private endpoints.
- Create a topic in the Event Streams instance, for example,
my-sample-topic
.
Step 2. Obtain the Event Streams API connection details
Obtain the following Event Streams API connection details that you must use when you configure the notification channel:
- api_key
- kafka_http_url
Choose 1 of the following methods:
Get credentials using the IBM Cloud console
- Locate your Event Streams service on the dashboard.
- Click your service tile.
- Click Service Credentials.
- Click New Credential.
- Complete the details for your new credential like a name and role and click Add. A new credential appears in the credentials list.
- Click this credential by using View Credentials to reveal the details in JSON format.
Get credentials using the IBM Cloud CLI
Complete the following steps:
-
Locate your service instance.
ibmcloud resource service-instances
-
Create a service key via the command line.
ibmcloud resource service-key-create KEY_NAME Writer --instance-name INSTANCE_NAME --service-endpoint private
Where
KEY_NAME
is the name of the key, andINSTANCE_NAME
is the name of the Event Streams instance.The output of this command includes the details that are needed to make a REST call to send notifications to the Event Streams instance.
Step 3. Create a notification channel
From the Monitoring UI, setup a Webhook notification channel.
Complete the following steps to add a notification channel:
-
Launch the web UI. For more information on how to launch the Web UI, see Navigating to the Web UI.
-
Click the user icon. This is the icon with the initials of the logged on user. Then click Settings.
-
Select Notification Channels.
-
Click Add Notification Channel.
-
Configure a notification channel:
-
Select the type of notification, for example,
Webhook
. -
Enter the name of the channel.
-
Enable the Notify when Resolved condition to receive a notification when the alert is manually resolved by a user.
-
Enable the Notify when Acknowledged field to receive a notification when the alert is manually acknowledged by the user.
-
For a webhook notification, enter the webhook URL. The format is the following:
<kafka_http_url>/topics/<topic>/records?apikey=<api_key>
Where
<topic>
is the name of your topic.For example, the URL field can be
https://y545tf67898h.svc01.eu-gb.eventstreams.cloud.ibm.com/topics/my-sample-topic/records?apikey=27836238765487558695
When an alert is triggered, the notification is sent as a POST in JSON format to your webhook endpoint.
-
For other notification types, configure the appropriate fields for the notification.
-
Optionally, and for integrations that allow a test, enable the Test notification condition to receive a test notification. If you do not receive a test notification in 10 minutes, review your channel configuration.
-
-
Click Save.
Currently additionalHeaders cannot be created on the original create. However, you can patch the notification channel. For example, you can use cURL to modify a notification channel:
-
Run the following command:
curl -X PUT ’https://us-east.monitoring.cloud.ibm.com/api/notificationChannels/<CHANNEL_ID>' \ --header ‘Content-Type: application/json’ --header ‘Authorization: Bearer <token>’ -d @/tmp/notification.json
Next. Setup alerts
Next setup alerts in Monitoring by using this notification channel.