Setup Notification webhooks

How to setup Notification webhooks

To send notifications from the CAST AI Console to an external system, select the organization you want to configure the webhook.

  1. Click on the Notifications Icon -> View All

  2. Click on Webhooks

  3. Click on Add webhooks

  4. Create the Webhook

FieldDescription
NameThe name of the Webhook configuration
Callback UrlThe callback URL to send the requests to
Severity TriggersThe severity levels that will trigger that notification
TemplateThe template of the request that will be sent to the callback URL

The Request Template should be a valid JSON. We provide a better overview of how to customize the payloads in the next section.

Request Template Configuration

We allow users to fully customize the request sent to external systems, in that way, we can support almost any application out there. The Request Template is the payload sent within the webhook call. The following variables from notifications are available:

VariableDescriptionUsage
NotificationIDThe UUID of the notification, it is unique{{ .NotificationID }}
OrganizationIDThe organization that owns the notification{{ .OrganizationID }}
SeverityIndicates the severity of the impact on the affected system.{{ .Severity }}
NameName of the notification{{ .Name }}
MessageA high-level text summary message of the event.{{ .Message}}
DetailsFree-form details from the event can be parsed into JSON{{ toJSON .Details }}
TimestampWhen the Notification was created by CAST AI{{ toISO8601 .Timestamp }}
ClusterCluster information, might be empty, if the notification isn't specific{{ toJSON .Cluster }}
Cluster.IDThe unique identifier of the cluster on CAST AI{{ .Cluster.ID }}
Cluster.NameName of the cluster on CAST AI{{ .Cluster.Name }}
Cluster.ProviderTypeCloud provider of the cluster (eks, gke, aks, kops){{ .Cluster.ProviderType }}
Cluster.ProjectNamespaceIDCluster location where cloud provider organizes resources, eg.: GCP project ID, AWS account ID.{{ .Cluster.ProjectNamespaceID }}

As you can see, the variables are in go template style, and you can mix them anywhere you want in your Request Template.

Example of Request Template Slack

To send a notification on Slack we need a simple JSON request with payload in the body,

{
    "text": "CAST AI - {{ .Name }}",
    "blocks": [
     {
      "type": "section",
      "text": {
       "type": "mrkdwn",
       "text": "{{ .Cluster.Name }}<br> {{ .Message}}"
      }
     }
    ]
}

How to create the webhook URL isn't in the scope of this how-to. You can find information following the link https://api.slack.com/messaging/webhooks.

Example of Request Template PagerDuty

PagerDuty accepts Alerts in the endpoint https://events.pagerduty.com/v2/enqueue. The content is a simple JSON request with the payload in the body. You can find below an example of a request template with the available variables:

{
    "payload": {
        "summary": "{{ .Message }}",
        "timestamp": "{{ toISO8601 .Timestamp }}",
        "severity": "critical",
        "source": "CAST AI",
        "component": "{{ .Cluster.Name}}-{{ .Cluster.ProviderType}}-{{ .Cluster.ProjectNamespaceID }}",
        "group": "{{ .Name }}",
        "class": "kubernetes",
        "custom_details": {
            "details": "{{ toJSON .Details }}"
        }
    },
    "routing_key": "--routing_key--",
    "dedup_key": "{{ .NotificationID }}",
    "event_action": "trigger",
    "client": "CAST AI",
    "client_url": "https://console.cast.ai/external-clusters/{{ .Cluster.ID}}?org={{ .OrganizationID }}",
}

Note that dedup_key was set as the NotificationID. This field is unique in CAST AI and will ensure you won't produce an alert with the same content more than once.

How to create the routing_key isn't in the scope of this how-to. You can find more information at https://developer.pagerduty.com/docs/ZG9jOjExMDI5NTgx-send-an-alert-event.

Example of OpsGenie Notification webhook setup.

This configuration enables the integration of OpsGenie with the CAST AI console, ensuring that alerts are received in OpsGenie.

OpsGenie pre-requisite

Add an API integration

  1. Go to Settings → Integrations.
  2. Run a search and select “API”.
  3. On the next screen, enter a name for the integration.
  4. Optional: Select a team in Assignee team if you want a specific team to receive alerts from the integration. Learn how alert notifications flow in Opsgenie.
  5. Select Continue.
    The integration is saved at this point.
  6. Expand the Steps to configure the integration section and copy the API key for use in your API requests.
  7. Select Turn on integration.
    The rules you create for the integration will work only if you turn on the integration.
API key integration example

API key integration example

Define rules for creating and processing alerts

The configuration of an API integration involves defining many different alert scenarios. These scenarios specify how and when alerts can be created, closed, acknowledged, etc. The integration comes with a default set of alert creation and processing rules; you can customize them and add as many rules of your own as you like. For example, you can add three rules for create alert, which means the incoming data is evaluated against these three scenarios in order, and if one of them matches, an alert is created.

Alert rules example

Alert rules example

OpsGenie Integration

Add a Webhook integration

  1. Go to Settings > Integrations.
  2. Select Add integration.
  3. Run a search and select “Webhook”.
  4. On the next screen, enter a name for the integration.
  5. Optional: Select a team in Assignee team if you want a specific team to receive alerts from the integration.
  6. Select Continue.
    The integration is saved at this point.
  7. Select Turn on integration.
    The rules you create for the integration will work only if you turn on the integration.

Sending alert description and alert details is only available for Create and Custom actions.

Webhook integration example

Webhook integration example

Webhook configuration

Utilize the provided API integration key to configure your webhook integration, ensuring it is utilized for authentication purposes.

=

Webhook integration validation

Before entering the essential details into the CAST AI webhook configuration, we recommend executing the following curl command. This action will verify whether the configured integration receives alerts and notifications as anticipated:

curl -X POST "<https://api.opsgenie.com/v2/alerts">  
    -H "Content-Type: application/json"  
    -H "Authorization: GenieKey <API Key>"  
    -d '{"message": "An example alert message"}'  
Alert within OpsGenie should be triggered:\`
OpsGenie Alert

OpsGenie Alert

CAST AI Integration

Add webhook via CAST AI console

  • Navigate to Notifications > Add Webhook

  • Set up the fields below using the information collected from the Webhook and API integration
    • Name of Webhook
    • Callback URL
    • Severity
    • Request template
    • Authorization keys (Headers)

Webhook “Can connect” example

Webhook “Can connect” example