Custom webhook notifier
This page explains how to create and configure a custom webhook notifier.
Use a custom webhook notifier to connect your monitors to internal or external services. The webhook URL receives a POST request with a content type of application/json together with any other headers you specify.
To create a custom webhook notifier, follow these steps:
- In Axiom, click Notifiers in the sidebar.
- 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. The URL must use HTTPS. Axiom rejects
http://URLs when you save or test the notifier. - 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, a new values monitor finding a new value, or a threshold or anomaly monitor triggering, and has valueClosedwhen a threshold or anomaly monitor resolves..MonitorIDis the unique identifier for the monitor associated with the notification..MonitorURLis a link to the monitor in Axiom..Queryis the APL or MPL query of the monitor associated with the notification..QueryURLis a link that opens the query of the monitor in Axiom over the time range of the notification. It’s empty if Axiom can’t build the link..Nameis the name of the monitor..MonitorTypeis the type of the monitor..Labelsis an array of labels associated with the notification..Thresholdand.Operatorare the monitor’s configured threshold and comparison operator..Rangeand.Intervalare the query range and run interval in minutes..IDis the notification event ID..UUIDis a UUID generated for the webhook message..Bodycontains the notification message. For match monitors, it containsEvent Matchedand a rate-limit note when applicable. For new values monitors, it contains the accompanying text orNew Valueif none was provided. For threshold or anomaly monitors, it describes the value that triggered or resolved the alert. Use.MatchedEventto read the matching event or new value row..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 notification title..Valueis the value that gave rise to the monitor triggering or resolving. It applies to threshold and anomaly monitors. When a threshold or anomaly monitor resolves because its query stops returning data for a series (for example, a grouped series that goes idle or drops out), there’s no current value to report and.Valueis0..MatchedEventis a JSON object. It’s only applicable if the notification corresponds to a match monitor or a new values monitor. For a match monitor, it’s the event that matched the criteria of the monitor. For a new values monitor, it’s one row of the query results that holds the new value..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: In Webhook headers, add headers to the POST request. For sensitive values such as authentication tokens, use Webhook secret headers. Axiom encrypts these values and hides them when you edit the notifier.
- Click Create.
Template functions
Use jsonObject to include .MatchedEvent as a JSON object, and jsonArray to include arrays such as .GroupKeys or .Labels.
Use jsonString to quote a string as JSON, for example "name": {{jsonString .Name}}. To include the matched event as a string, use "event": "{{escapedJSON .MatchedEvent}}".
Examples
The example below is the default template for a custom webhook notification:
Using the template above, the body of a POST request sent to the webhook URL for a threshold monitor triggering:
The example template below formats the webhook message to match the expectations of incident.io using the monitor ID as the deduplication_key. To use the native integration, see incident.io notifier.
The example template below sends the query and the links that your own automation needs to start an investigation when a monitor alerts: