Zabbix & Better Stack integration

This integration allows you to create Better Stack incidents from Zabbix automatically.

Connecting Zabbix and Better Stack

  1. Go to Integrations and click the Importing data tab.
  2. Find the Zabbix card and click Add.
  3. Name your Zabbix integration (e.g., Backend service) and click Save changes.
  4. Copy the script from the integration settings. You will need it in a moment.

In Zabbix

Create a media type

  1. Go to your Zabbix dashboard.
  2. In the upper right corner, click Create media type.
  3. For Name, enter Better Stack.
  4. For Type, select Webhook.
  5. Remove all parameters except Message: {ALERT.MESSAGE}.
  6. Paste the script from your Better Stack integration settings into the Script field.

    Zabbix Media type Script
    // Make a POST request to the Better Stack Zabbix Webhook
    
    var request = new HttpRequest();
    request.addHeader('Content-Type: application/json');
    
    var response = request.post('https://uptime.betterstack.com/api/v2/zabbix/webhook/sHvzVfzMofxz6eD4XdZEEqdF', value);
    if (request.getStatus() != 200) {
      throw 'Response code: ' + request.getStatus();
    }
    
    console.log(response);
    

    The integration settings also offer a Script with debug logging variant for troubleshooting.

  7. Ensure Enabled is checked and click Add.

Create a user

  1. Go to Administration > Users and click Create user.
  2. For Alias, enter Better Stack user.
  3. Add this user to a group and enter any password.
  4. Go to the Permissions tab and grant the user read permissions for the necessary hosts.
  5. Go to the Media tab and add Better Stack as a new media type.
  6. In the Send to field, enter any value (it is required but not used).
  7. Select the severities you want to report to Better Stack.
  8. Click Add to save the media, then Add again to save the user.

Create an action

  1. Go to Configuration > Actions and click Create action.
  2. For Name, enter Better Stack Action.
  3. (Optional) Add conditions to restrict the action.
  4. Go to the Operations tab.
  5. Set Default operation step duration to 1m.
  6. Under Operations, click Add.
  7. In Send to Users, select Better Stack user.
  8. In Send only to, select Better Stack.
  9. Check Custom message and paste the operational message from your Better Stack integration settings into the Message field.
  10. Click Add to save the operation.
  11. Repeat the steps above for Recovery operations and Update operations, using their respective messages.
  12. After configuring all operations, click Add to save the action.

You're done. Now, when Zabbix triggers an alert, an incident will be created in Better Stack.