Config changes.

This commit is contained in:
2025-08-30 08:35:54 -04:00
parent 98094c3c37
commit 7117c47bd3
3 changed files with 76 additions and 13 deletions
@@ -0,0 +1,18 @@
[
{
"id": "signoz-alert",
"execute-command": "/opt/webhook_scripts/signoz-alert.sh",
"command-working-directory": "/tmp",
"pass-arguments-to-command": [
{
"source": "entire-payload"
},
{
"source": "value",
"name": "debug",
"default": "false"
}
],
"response-message": "Apprise notification triggered"
}
]
+45
View File
@@ -0,0 +1,45 @@
#!/bin/sh
set -e
# Accept arguments:
# $1 -> payload from SigNoz
# $2 -> debug flag ("true" or "false"), defaults to false
PAYLOAD="$1"
DEBUG="${2:-false}"
# Save raw payload for debugging if debug is true
if [ "$DEBUG" = "true" ]; then
echo "$PAYLOAD" > /tmp/raw_payload.json
fi
# Iterate over each alert in the "alerts" array
printf '%s' "$PAYLOAD" | jq -c '.alerts[]' | while read -r alert; do
# Transform the alert into Apprise-compatible JSON
TRANSFORMED=$(printf '%s' "$alert" | jq -r '
. as $a |
{
title: ($a.labels.alertname // "SigNoz Alert"),
body: (
(
($a.annotations // {})
+ ($a.labels // {} | del(.alertname))
+ {
status: ($a.status // "unknown"),
startsAt: ($a.startsAt // "unknown")
}
+ (if $a.endsAt != null and $a.endsAt != "" then {endsAt: $a.endsAt} else {} end)
) | to_entries | map("\(.key): \(.value)") | join("\n")
)
}
')
# Save transformed alert for debugging if debug is true
if [ "$DEBUG" = "true" ]; then
echo "$TRANSFORMED" | jq . > /tmp/out_$(echo "$alert" | jq -r '.fingerprint').json
fi
# Send to Apprise API
echo "$TRANSFORMED" | jq -c . | curl -s -X POST -H "Content-Type: application/json" -d @- http://192.168.1.254:54995/notify/apprise
done