Zabbix can use the script to send the alerts to Grafana OnCall. Please use the format below
Body Fields Format:
alert_uid [char][not required] - unique alert ID for grouping;
title [char][not required] - title;
image_url [char][not required] - url for image attached to alert;
state [char][not required] - could be "ok" or "alerting", helpful for auto-resolving;
link_to_upstream_details [char][not required] - link back to your monitoring system;
message [char][not required] - alert details;
Script example:
#!/bin/bash
# This is the modification of original ericos's shell script.
# Get the url ($1), subject ($2), and message ($3)
url="$1"
subject="${2//$'\r\n'/'\n'}"
message="${3//$'\r\n'/'\n'}"
# Alert state depending on the subject indicating whether it is a trigger going in to problem state or recovering
recoversub='^RECOVER(Y|ED)?$|^OK$|^Resolved.*'
if [[ "$subject" =~ $recoversub ]]; then
state='ok'
else
state='alerting'
fi
payload='{
"title": "'${subject}'",
"state": "'${state}'",
"message": "'${message}'"
}'
# Alert group identifier from the subject of action. Grouping will not work without AMIXR_GROUP in the action subject
regex='AMIXR_GROUP: ([a-zA-Z0-9_\"]*)'
if [[ "$subject" =~ $regex ]]; then
alert_uid=${BASH_REMATCH[1]}
payload='{
"alert_uid": "'${alert_uid}'",
"title": "'${subject}'",
"state": "'${state}'",
"message": "'${message}'"
}'
fi
return=$(curl $url -d "${payload}" -H "Content-Type: application/json" -X POST)
Next steps:
-
1. Add the routes and escalations in
Escalations settings
-
2. Check grouping, auto-resolving, and rendering templates in
Alert Templates Settings
-
3. Make sure all the users set up their
Personal Notifications Settings
on the Users Page