[ops] slack alerts from syslog errs

This commit is contained in:
Mononaut 2024-11-12 20:16:29 +00:00
parent 3b4eda432f
commit 5e8e1f3dee
No known key found for this signature in database
GPG Key ID: A3F058E41374C04E
3 changed files with 21 additions and 1 deletions

View File

@ -1089,6 +1089,7 @@ case $OS in
echo "[*] Installing syslog configuration" echo "[*] Installing syslog configuration"
osSudo "${ROOT_USER}" mkdir -p /usr/local/etc/syslog.d osSudo "${ROOT_USER}" mkdir -p /usr/local/etc/syslog.d
osSudo "${ROOT_USER}" install -c -m 755 "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/mempool-logger" /usr/local/bin/mempool-logger osSudo "${ROOT_USER}" install -c -m 755 "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/mempool-logger" /usr/local/bin/mempool-logger
osSudo "${ROOT_USER}" install -c -m 755 "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/mempool-slacker" /usr/local/bin/mempool-slacker
osSudo "${ROOT_USER}" install -c -m 644 "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/syslog.conf" /usr/local/etc/syslog.d/mempool.conf osSudo "${ROOT_USER}" install -c -m 644 "${MEMPOOL_HOME}/${MEMPOOL_REPO_NAME}/production/syslog.conf" /usr/local/etc/syslog.d/mempool.conf
echo "[*] Installing redis configuration" echo "[*] Installing redis configuration"

19
production/mempool-slacker Executable file
View File

@ -0,0 +1,19 @@
#!/bin/sh
if [ -z "$SLACK_SYSLOG_WEBHOOK_URL" ]; then
echo "Error: SLACK_SYSLOG_WEBHOOK_URL environment variable is not set" >&2
exit 1
fi
trap "" PIPE
while read input; do
if [ ! -z "${input}" ]; then
escaped_input=$(echo "$input" | sed 's/"/\\"/g')
curl -X POST \
-H 'Content-type: application/json' \
--data "{\"text\":\"\`\`\`${escaped_input}\`\`\`\"}" \
-s \
"$SLACK_SYSLOG_WEBHOOK_URL" \
>/dev/null 2>&1 &
fi
done

View File

@ -1,4 +1,4 @@
local7.>=err |/usr/local/bin/sudo -u mempool /usr/local/bin/mempool-logger mempool.ops alerts local7.>=err |/usr/local/bin/sudo -u mempool /usr/local/bin/mempool-slacker
local7.>=info |/usr/local/bin/sudo -u mempool /usr/local/bin/mempool-logger mempool.ops node100 local7.>=info |/usr/local/bin/sudo -u mempool /usr/local/bin/mempool-logger mempool.ops node100
local7.>=info /var/log/mempool local7.>=info /var/log/mempool
local7.* /var/log/mempool.debug local7.* /var/log/mempool.debug