Skip to main content

Plugin for Sentry which allows sending notifications to a self-hosted Mattermost instance.

Project description

sentry-mattermost-plugin

A Sentry plugin that sends issue notifications to a self-hosted Mattermost instance via the Mattermost Bot API.

Official Repo seems to be outdated. So here's alternative.

Inspired by sentry-telegram.

Requirements

  • Sentry (self-hosted)
  • Python 3.8+
  • A Mattermost Bot account with a token

Installation

Install the package into Sentry's Python environment:

pip install sentry-mattermost-plugin

Or in development mode from source:

git clone https://github.com/masstek/sentry-mattermost-plugin
cd sentry-mattermost
pip install -e .

Restart Sentry after installation so the entry point is picked up.

Configuration

  1. In Sentry, go to Project Settings → Legacy Integrations.
  2. Find Mattermost Notifications and click Configure plugin.
  3. Fill in the fields:
Field Description
Mattermost Host Base URL of your Mattermost instance, e.g. https://mattermost.company.com
Bot Token Access token for the Mattermost Bot account
Channel IDs One channel ID per line. Find IDs via Mattermost → channel name → View Info
Message Template Optional. Supports {project_name}, {url}, {title}, {message}, {tag[key]}
Verify SSL Certificate Uncheck if your instance uses a self-signed certificate
  1. Click Save changes.
  2. Click Test Plugin to send a test notification to all configured channels.

Creating a Mattermost Bot

  1. In Mattermost go to Main Menu → Integrations → Bot Accounts.
  2. Click Add Bot Account, give it a name, and save.
  3. Copy the generated token — this is the Bot Token for the plugin.
  4. Add the bot to the channels it needs to post in.

Message Template

The default template is:

*[Sentry]* {project_name} | {title}
{url}
{message}

Available variables:

Variable Description
{project_name} Sentry project name
{url} Link to the Sentry issue
{title} Error title (truncated to 500 characters)
{message} Error message
{tag[key]} Value of a Sentry tag by key, e.g. {tag[environment]}. Returns [NA] if absent.

Mattermost Markdown is supported in the template.

Running Tests

pip install pytest pytest-cov requests django
pytest tests/ --cov=sentry_mattermost_plugin --cov-report=term-missing

No Sentry installation is required to run the tests.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sentry_mattermost_plugin-0.1.1.tar.gz (7.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sentry_mattermost_plugin-0.1.1-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file sentry_mattermost_plugin-0.1.1.tar.gz.

File metadata

File hashes

Hashes for sentry_mattermost_plugin-0.1.1.tar.gz
Algorithm Hash digest
SHA256 769d62a2273157c890bdca7e6f2b7c40c9e13959b27210cd5410b6933ccc5781
MD5 d1fa733291b3efa45d7c3cdf7db26c37
BLAKE2b-256 9a1d6a3f811e30e475e2324c3d66e2f47024036e423f2ce8d99612803c4a4fb9

See more details on using hashes here.

File details

Details for the file sentry_mattermost_plugin-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for sentry_mattermost_plugin-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 e0d4a74be7efdbf4a12b287209aeb90b9f0544af9828c00c149b3d24e4fbfb27
MD5 f0b62c7fb4e0273c36e17d8dcc3cf4b7
BLAKE2b-256 91e1159d9f241ce4dae396f61b87c503c3b7e5b2b938ada4450d00eb615fcee1

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page