Sentry Issue Notifications via Mattermost Webhooks

We’ve just started making use of Sentry‘s On Premise offering in our environment, and were looking forward to integrating it into our Mattermost chat platform to alert developers of any issues.

Unfortunately, the only third party plugin I could find was a few years out of date and didn’t seem like it was compatible with newer versions of Sentry.

After a bit of playing around, I figured the easiest way was to just write an intermediary API to accept webhooks from Sentry, format a message, and pass it onto Mattermost. This is now working nicely in our environment.

The code for my middleman can be found: sentry_mattermost_webhook.php

Setting this up is fairly easy:

  • Place the script on a web server, edit it to replace the placeholder variables I’ve left in.
  • In Sentry, go to Settings > Developer Settings > New Internal Integration. Give it a name, and set the ‘Webhook URL’ to the location of the above script. Grant the ‘Read’ permission for ‘Issue & Event’ and enable the ‘issue’ webhook trigger.
  • In Mattermost, create a new ‘Incoming Webhook‘ and add its URL to the script on line 39.

And you’re away! While it’d have been nice for us to have a native solution within Sentry, I didn’t want to spend the time writing my own Sentry plugins. This way seemed more flexible.