Alert Webhooks
Alert webhooks
In addition to email and SMS notifications, you can configure alert monitors to invoke a webhook URL with a payload of your choice. An alert webhook could be used to send alert info the PagerDuty or OpsGenie APIs, your own DevOps alert endpoint, or any other alerting service with an HTTP-based API.
Creating alert webhooks
- Web App
- CLI
- API
To create or modify a webhook endpoint, click into the Settings page and select the Alert Webhooks tab. Click the + Add alert webhook button, enter an appropriate name for your alert webhook, URL, and payload information.
Alert webhooks are meant to be general enough that they can be used by multiple alert monitors, and their payload templates help with that. Within the Payload Template section you can enter certain keywords, which are replaced when an alert monitor fires with information about the alert monitor, instance, trigger, and monitor URL.
$SUBJECT
- The string literal "Prismatic.io Alert"$NAME
- The name of the alert monitor that was triggered$INSTANCE
- The name of the instance that had the triggered alert monitor$INSTANCE_ID
- The global identifier of the instance (theSW5z....
portion of the URL when you open the instance)$EXECUTION_ID
- the global identifier of the running execution$CUSTOMER
- The name of the customer the instance is deployed to$CUSTOMER_EXTERNAL_ID
- The external ID of the customer the instance is deployed to$FLOW
- The name of the flow that was running when the alert monitor triggered$TRIGGER
- The name of the alert trigger (like "Execution Failed")$STEP
- The name of the step within the integration that triggered the alert monitor$URL
- A URL that will navigate to the specific alert monitor that was triggered
After creating the alert webhook, you can modify the name, URL, or alert payload, and optionally add HTTP headers. Headers are frequently used for passing an authorization token to a webhook.
To create an alert webhook, use the alerts:webhooks:create
subcommand.
prism alerts:webhooks:create \
--name 'Devops Webhook' \
--headers '{"Authorization": "Bearer abc123"}' \
--payloadTemplate 'The instance "$INSTANCE" was triggered by "$TRIGGER" on monitor "$NAME". It appears that step "$STEP" generated and error. Respond by visiting $URL.' \
--url https://devops.progix.io/alerts/webhook
To create an alert webhook, use the createAlertWebhook mutation:
mutation {
createAlertWebhook(
input: {
name: "Devops Webhook"
url: "https://devops.progix.io/alerts/webhook"
headers: "{\"Authorization\": \"Bearer abc123\"}"
payloadTemplate: "The instance \"$INSTANCE\" was triggered by \"$TRIGGER\" on monitor \"$NAME\". It appears that step \"$STEP\" generated and error. Respond by visiting $URL."
}
) {
alertWebhook {
id
}
}
}
Editing existing alert webhooks
To modify an existing alert webhook, click Settings on the left-hand sidebar and then select the Alert Webhooks tab. Click into an existing alert webhook. In this screen, you can modify the name by clicking the name at the top of the page. You can modify the webhook template, payload template, or URL from the Details tab, and you can also add optional HTTP headers if your webhook requires authorization tokens, etc.
Deleting alert webhooks
- Web App
- CLI
- API
To delete an alert webhook open the Settings page from the left-hand sidebar. Click the Alert Webhooks tab and select an alert webhook. Within the alert webhook's page, click Delete Alert Webhook. Confirm deletion by clicking Remove alert webhook.
Find the webhook's ID with
prism alerts:webhooks:list --extended
and then delete the webhook with
prism alerts:webhooks:delete ${WEBHOOK_ID}
Delete an alert webhook by alert webhook ID using the deleteAlertWebhook mutation:
mutation {
deleteAlertWebhook(
input: {
id: "QWxlcnRXZWJob29rOjczOGNiNTM2LWFhMGMtNGUwNS05ZTBmLTQ5ZDMzZDE5ODYwNA=="
}
) {
alertWebhook {
id
}
}
}