application/json together with any other headers you specify.
To create a custom webhook notifier, follow these steps:
- Click the Monitors tab, and then click Manage notifiers on the right.
- Click New notifier on the top right.
- Name your notifier.
- Click Custom webhook.
- In Webhook URL, enter the URL where you want to send the POST request.
- Optional: To customize the content of your webhook, use the Go template syntax to interact with these variables:
.Actionhas valueOpenwhen the notification corresponds to a match monitor matching or a threshold monitor triggering, and has valueClosedwhen the notification corresponds to a threshold monitor resolving..MonitorIDis the unique identifier for the monitor associated with the notification..Bodyis the message body associated with the notification. When the notification corresponds to a match monitor, this is the matching event data. When the notification corresponds to a threshold monitor, this provides information about the value that gave rise to the monitor triggering or resolving..Descriptionis the description of the monitor associated with the notification..QueryEndTimeis the end time applied in the monitor query that gave rise to the notification..QueryStartTimeis the start time applied in the monitor query that gave rise to the notification..Timestampis the time the notification was generated..Titleis the name of the monitor associated with the notification..Valueis the value that gave rise to the monitor triggering or resolving. It’s only applicable if the notification corresponds to a threshold monitor..MatchedEventis a JSON object that represents the event that matched the criteria of the monitor. It’s only applicable if the notification corresponds to a match monitor..GroupKeysand.GroupValuesare JSON arrays that contain the keys and the values returned by the group-by attributes of your query. They’re only applicable if the APL query of the monitor groups by a non-time field. You can fully customize the content of the webhook to match the requirements of your environment.
- Optional: Add headers to the POST request sent to the webhook URL.
- Click Create.
JSON-safe template variables
When you embed template variables inside a JSON string value, the variable’s content must be valid JSON. If the value contains characters like double quotes ("), backslashes (\), or newlines, the resulting payload will be malformed JSON and your receiving service won’t parse it.
To safely embed a free-text variable in a JSON string, wrap it in the built-in js function, which JSON-encodes the value and strips the surrounding quotes so you can place it inside your own quotes:
js function is the Go template standard JSON-encoding helper. Use it any time the variable could contain user-generated text, log lines, or other content that might include special characters.
Variables that render as structured JSON rather than plain strings ({{.Value}}, {{jsonObject .MatchedEvent}}, {{jsonArray .GroupKeys}}, {{jsonArray .GroupValues}}) don’t need the js wrapper because they produce valid JSON on their own.
Examples
The example below is the default template for a custom webhook notification:deduplication_key.