Skip to content

Commit b5a54b7

Browse files
Update alerts documentation for webhooks (#333)
Update the alerts documentation with some information about configuring webhook alerts. --------- Co-authored-by: Tom Faulhaber <github1_com@infolace.com>
1 parent 24dcca1 commit b5a54b7

File tree

1 file changed

+45
-1
lines changed

1 file changed

+45
-1
lines changed

docs/docs/guide/9-alerts.md

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,48 @@ Consider configuring a "no queries submitted" alert to monitor system health. If
2424

2525
## Alert Mediums
2626

27-
Groundlight supports the following alerts via Email, Text Message (SMS), and Webhooks.
27+
Groundlight supports alerts via Email, Text Message (SMS), and Webhooks.
28+
29+
### Webhooks
30+
31+
By setting up a webhook alert for your Groundlight detector, you can integrate Groundlight's computer vision technology with your existing messaging platform, other tech stack, or even a custom application.
32+
33+
You can either set up an alert using one of our default templates (currently available for Slack, more platforms to come) or build your own.
34+
35+
#### Custom Templates
36+
37+
We use Jinja2 to manage and render templates. See the ([Jinja template documentation](https://jinja.palletsprojects.com/en/stable/templates/)) for information on how to construct your template.
38+
The template will need to be a valid Jinja template which renders to valid JSON to be used as a payload for your webhook alert.
39+
40+
We provide a set of variables which you can use to put information about your detector and alert into your template.
41+
The available variables are:
42+
43+
- `detector_name`: The name of the detector that the alert was triggered on
44+
- `detector_query`: The detector's query.
45+
- `detector_id`: The detector's unique ID
46+
- `confidence_threshold`: The current confidence threshold for the detector.
47+
- `detector_mode`: The detector's mode (binary, count, multiclass, etc). Currently, alerts are only available for binary detectors.
48+
- `image_query_id`: The id of the image query which triggered the alert
49+
- `time_repr`: A human readable string of the time the alert was triggered in UTC. Does not include the date.
50+
- `activation_time`: The time and date the alert was triggered in UTC.
51+
- `condition_repr`: The condition the alert is configured with, put into a human-readable string (eg. " returned a YES answer at ").
52+
- `image_url`: An image URL to access the image which triggered the alert. Only available if the alert was configured with `include_image` set to True.
53+
54+
For example, the template below could be used as a custom payload to configure a Slack alert which includes a basic message and the triggering image.
55+
```
56+
"""{
57+
"text": "Alert activated on Groundlight detector {{ detector_name }} (Query: {{ detector_query }}). Detector {{ condition_repr }} {{ time_repr }}",
58+
"attachments": [
59+
{
60+
"fallback": "Optional image attachment for the detector alert.",
61+
"image_url": "{{ image_url }}",
62+
"title": "Related Image"
63+
}
64+
]
65+
}"""
66+
```
67+
68+
#### Headers
69+
70+
Optionally, you can also configure the headers for your webhook alert POST request. This is particularly useful if your application requires a specific security token to be present to accept incoming POST requests.
71+
If your application requires headers, you can provide them as a JSON dictionary. If not, you can configure your template and leave the headers blank.

0 commit comments

Comments
 (0)