/zabbix-slack-node

Zabbix alert script for Slack, using Node.js featuring rich messages

Primary LanguageJavaScript

zabbix-slack-node

A custom media type for Zabbix that will deliver PROBLEM / RESOLVED alerts to Slack.

  • Graph links and acknowledge buttons are probably broken

Preview

Preview

Acknowledgements:

Acknowledgements

Setup

  1. Clone this repo into your Zabbix servers "AlertScriptsPath"

  2. Run npm install inside the cloned repo

  3. Log into Zabbix, go to Administration -> Media Types -> Create media type

  4. Set the following values:

    Key Value
    Type Script
    Script name zabbix-slack-node/slack.sh
    Script parameters {ALERT.SENDTO}
    {ALERT.SUBJECT}
    {ALERT.MESSAGE}
    https://your.zabbix.website.example
    Your slack webhook URL
  5. Create a new user with sufficient permissions to view problems for all hosts

  6. Add a media to the user, with Type => Slack and Send to => #your-slack-channel

  7. Go to Configuration -> Actions -> Create action and ensure that the operation is defined like so:

Key Value
Default subject {HOST.NAME1} {TRIGGER.STATUS}: {EVENT.NAME}
Default message
Host: {HOST.NAME1}
Event: {ITEM.KEY1}
Item ID: {ITEM.ID}
Event ID: {EVENT.ID}
Trigger ID: {TRIGGER.ID}
Severity: {TRIGGER.SEVERITY}
Status: {TRIGGER.STATUS}
Trigger: {EVENT.NAME}
Ack: {EVENT.ACK.STATUS}
Service: {TRIGGER.HOSTGROUP.NAME}
Value: {ITEM.VALUE1}
Text: {TRIGGER.STATUS}: {EVENT.NAME}
Tags: {EVENT.TAGS}
IP: {HOST.IP1}
Template: {TRIGGER.TEMPLATE.NAME}: {TRIGGER.EXPRESSION}
When: {EVENT.DATE} {EVENT.TIME}
                
Operations
  • New
  • Send to users: Slack
  • Send only to: Slack
9. Now configure the recovery operation:
Key Value
Default subject {TRIGGER.STATUS}: {EVENT.NAME}
Default message
Host: {HOST.NAME1}
Event: {ITEM.KEY1}
Item ID: {ITEM.ID}
Event ID: {EVENT.ID}
Severity: {TRIGGER.SEVERITY}
Status: {TRIGGER.STATUS}
Trigger: {EVENT.NAME}
Trigger ID: {TRIGGER.ID}
Ack: {EVENT.ACK.STATUS}
Service: {TRIGGER.HOSTGROUP.NAME}
Value: {ITEM.VALUE1}
Text: {TRIGGER.STATUS}: {EVENT.NAME}
Tags: {EVENT.TAGS}
IP: {HOST.IP1}
Template: {TRIGGER.TEMPLATE.NAME}: {TRIGGER.EXPRESSION}
When: {EVENT.DATE} {EVENT.TIME}
Recovered: {EVENT.RECOVERY.DATE} {EVENT.RECOVERY.TIME}
                
Operations Notify all involved
10. Now configure the update operation:
Key Value
Default subject {USER.FULLNAME} acknowledged: {EVENT.NAME}
Default message
message: {ACK.MESSAGE}
acknowledgement: yes
status: {EVENT.STATUS}
Severity: {TRIGGER.SEVERITY}
                
Operations Send message to users: Slack (Slack) via Slack
11. Save action