vRealize Operations, vROps, Webhook

vRealize Operations and Telegram – Alerts on your Phone

As you all know vRealize Operations is a perfect tool to manage and monitor your SDDC and in case of issues vROps creates alerts and informs you as quickly as possible providing many details related to an alert.

Without any additional customization, vRealize Operations displays the alerts in the Alerts tab. Sending alerts via email is the most common way to quickly attract your attention and increase the chances of reacting to the alert quickly.

With the Webhook Notification Plugin, it is possible to integrate vROps with almost any REST API endpoint. Telegram provides an easy-to-use API and allows for sending vROps alerts as messages into a Telegram chat.

Telegram Chat, Bot, and Token

The first step is to prepare Telegram to allow vROps to send messages to a chat. Basically, you will need a chat, a bot, and a token. The process is very well described here.

The actual REST API POST call uses the chat ID and the Token to ingest messages into the chat.

https://api.telegram.org/bot$token/sendMessage?chat_id=$chat&text=Hello+World

The POST content is pretty simple.

{
  "text": "my message"
}

vROps Outbound Instance

The next step is the vROps Outbound Webhook Plugin instance that will point to our telegram chat. For simplicity, the Outbound URL contains the entire URL we need to send messages to Telegram.

In my environment, the instance looks like depicted in the following figure, bot ID and token are truncated for visibility and my data privacy.

Figure 01: Outbound Webhook Plugin instance.

You do not have to specify any user or password as the ingestion uses the token in the URL. When you run the test you will see an error but this is in our case OK.

vROps Payload Template

Following the Outbound Plugin instance, we need to specify the details of the REST call and the payload. In my example, I would like to receive datastore space-related alarms in my chat. Details of the alert definition are not described in this post.

The Payload Template is where we define these settings, subdivided into:

  • Details: Specifies the name of the instance and the Outbound Method to use, in this case, the Webhook Notification Plugin.
  • Object Content: Here we can add additional information, like metrics and properties to be used in the actual payload. I have added a few additional metrics to help qualify the alarm.
  • Payload Details: Specifies the actual REST call, like method or content type, and describes the body of the call as required by the receiving instance. In the body itself, we can use the predefined parameters (uppercase) and our additional metrics or properties or related objects (lowercase).

The following two pictures show my Payload Template.

Figure 02: Payload Template – Details.
Figure 03: Payload Template – Object Content.
Figure 04: Payload Template – Payload Details.

vROps Notification

The last step of the process is to bring everything together, the alert definition, the outbound instance, and the payload template to work together and send the message towards Telegram.

This is where the good old vROps Notifications come into play. It wires everything and does exactly what the name implies – notifies you in an alarm event.

The process of notification creation has four steps:

  1. Notification: Here you give the notification a name and enable or disable it.
  2. Define Criteria: This step gives you a large number of options to exactly specify when the notification should be triggered. In my use case, I want this notification to be triggered only on one specific object type (Datastore) and only for one specific alert definition (tk-vSAN Remaining Space Low).
  3. Set Outbound Method: Here we define the Outbound Method (Webhook Notification Plugin) and the Outbound Instance we created for Telegram.
  4. Select Payload Template: In the last step we define the Payload Template to use, in our use case the template we created for Telegram.

The following pictures show my Notification settings.

Figure 05: vROps Notification – Notification.
Figure 06: vROps Notification – Define Criteria.
Figure 07: vROps Notification – Set Outbound Method.
Figure 08: vROps Notification – Select Payload Template.

The Result

When all steps are finished successfully, any time the specified alarm has been triggered you will receive a message in your Telegram chat, as depicted in the following figure.

Figure 09: vROps Alarm in Telegram chat.

Stay safe.

Thomas – https://twitter.com/ThomasKopton

Leave a Reply

Your email address will not be published.