{"id":16430167,"url":"https://github.com/its-alex/sentry-mattermost-sidecar","last_synced_at":"2025-03-23T07:34:15.676Z","repository":{"id":64318644,"uuid":"401405932","full_name":"Its-Alex/sentry-mattermost-sidecar","owner":"Its-Alex","description":"This tools is a sidecar to use sentry webhook on mattermost","archived":false,"fork":false,"pushed_at":"2023-12-15T15:18:00.000Z","size":254,"stargazers_count":23,"open_issues_count":1,"forks_count":8,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-10-12T08:25:51.879Z","etag":null,"topics":["container","docker","sentry","sidecar"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Its-Alex.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-30T16:07:32.000Z","updated_at":"2024-10-10T10:40:43.000Z","dependencies_parsed_at":"2023-12-15T16:30:59.517Z","dependency_job_id":"a9660568-6e62-43d2-9322-bcd792a273f4","html_url":"https://github.com/Its-Alex/sentry-mattermost-sidecar","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Its-Alex%2Fsentry-mattermost-sidecar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Its-Alex%2Fsentry-mattermost-sidecar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Its-Alex%2Fsentry-mattermost-sidecar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Its-Alex%2Fsentry-mattermost-sidecar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Its-Alex","download_url":"https://codeload.github.com/Its-Alex/sentry-mattermost-sidecar/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":221847140,"owners_count":16890979,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["container","docker","sentry","sidecar"],"created_at":"2024-10-11T08:25:57.199Z","updated_at":"2025-03-23T07:34:15.663Z","avatar_url":"https://github.com/Its-Alex.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# sentry-mattermost-sidecar\n\nThis tools is a sidecar to use sentry webhook on mattermost.\n\n## Roadmap\n\n- [x] Handle sentry Issue alerts with [webhook legacy integration](https://github.com/getsentry/sentry-webhooks)\n- [ ] Handle sentry Metric alerts with [webhook legacy integration](https://github.com/getsentry/sentry-webhooks)\n- Handle [Custom integration - Sentry webhook](https://docs.sentry.io/organization/integrations/integration-platform/webhooks/)\n  - Issues alerts\n    - [ ] `triggered` action\n  - Issues\n    - [x] `created` action\n    - [x] `resolved` action\n    - [x] `assigned` action\n    - [x] `archived` action\n    - [x] `unresolved` action\n  - Comments\n    - [ ] `created` action\n    - [ ] `updated` action\n    - [ ] `deleted` action\n  - Errors \n    - [x] `created` action\n\n## How to use\n\nFirst you must create a [Mattermost incoming webhook](https://docs.mattermost.com/developer/webhooks-incoming.html) integration.\n![mattermost-incoming-webhook-integration-setup](docs/assets/mattermost-incoming-webhook-integration-setup.png)\n\nNext you must deploy the [docker image](https://hub.docker.com/r/itsalex/sentry-mattermost-sidecar) (don't forget to fill `SMS_MATTERMOST_WEBHOOK_URL` environment variable with the Mattermost webhook URL) somewhere and redirect sentry webhook on it with route name defined as Mattermost channel for each projects.\n![sentry-webhook-integration-setup](docs/assets/sentry-webhook-integration-setup.png)\n\nThen you setup [sentry issue alerts](https://docs.sentry.io/product/alerts/) as you like.\n![sentry-issue-alert-creation](docs/assets/sentry-issue-alert-creation.png)\n\n## Getting started\n\n### Requirement\n\n- [`mise`](https://mise.jdx.dev/) (if you want to send real errors to sentry)\n- `docker`\n- `bash`\n- `virtualbox` (if you want to setup local mattermost and sentry instance)\n- `vagrant` (if you want to setup local mattermost and sentry instance)\n\nIf you want to send real errors to sentry, and you have installed\n[`mise`](https://mise.jdx.dev/), you must execute the following commands to\nhave everything working:\n\n```sh\n$ mise trust \u0026\u0026 mise install\n$ pip install -r requirements.txt\n```\n\nThis will install python with a predefined version of sentry-sdk python package\nin an isolated [.venv](https://docs.python.org/3/library/venv.html) folder.\n\n## Hack\n\nTo start you must launch dev environment:\n\n```sh\n$ ./scripts/up.sh\n```\n\nThis will launch images in [`docker-compose.yml`](./docker-compose.yml).\n\nAn image named `workspace` with golang is used as a isolated container to\ndevelop. You can use [`enter-workspace.sh`](./scripts/enter-workspace.sh)\nto enter inside it:\n\n```sh\n$ ./scripts/enter-workspace.sh\n```\n\nFrom outside the container you can build with:\n\n```sh\n$ ./scripts/build.sh\n```\n\nYou can test an example sentry webhook with:\n\n```sh\n$ ./scripts/test-request.sh\n```\n\nThen you can see the converted request that will be send to mattermost using:\n\n```sh\n$ ./scripts/get-last-request-result.sh\n```\n\nThis is an environment aimed to reproduced real use case. If you really want to\nperform tests with Mattermost and Sentry, you can do it locally following\n[Setup VM with Mattermost and Sentry](#setup-vm-with-mattermost-and-sentry).\n\n## Deploy\n\nThis image is automatically deployed and versionned as a docker image at [itsalex/sentry-mattermost-sidecar](https://hub.docker.com/r/itsalex/sentry-mattermost-sidecar).\n\nTo deploy a new tag use [`./scripts/create-and-push-tag.sh`](scripts/create-and-push-tag.sh):\n\n```sh\n$ ./scripts/create-and-push-tag.sh 1.0.0\n```\n\n## Setup VM with Mattermost and Sentry\n\n### Setup\n\nYou can setup a VM with Mattermost and Sentry if you want to perform real tests.\nYou should have at least:\n\n- `16` CPU thread\n- `20GB` RAM\n\nIf you valid those requiremnts, you can launch the VM:\n\n```sh\n$ vagrant up\n```\n\nA server will be launch with Mattermost and Sentry installed, you should now\ncreate Sentry first user:\n\n```sh\n$ vagrant ssh -c \"cd /opt/sentry \u0026\u0026 sudo docker compose run web upgrade\"\n...\nRunning hooks in /etc/ca-certificates/update.d...\ndone.\nRunning migrations for default\nOperations to perform:\n  Apply all migrations: auth, contenttypes, feedback, hybridcloud, nodestore, replays, sentry, sessions, sites, social_auth\nRunning migrations:\n  No migrations to apply.\nCreating missing DSNs\nCorrecting Group.num_comments counter\n17:26:28 [INFO] sentry.outboxes: Executing outbox replication backfill\n17:26:28 [INFO] sentry.outboxes: Processing sentry.ControlOutboxs...\n17:26:28 [INFO] sentry.outboxes: Processing sentry.RegionOutboxs...\n17:26:28 [INFO] sentry.outboxes: done\n\nWould you like to create a user account now? [Y/n]:\n\n```\n\nFollow the instruction to create Sentry default user. Mattermost default user\nwill be asked on the first connection on Mattermost url.\n\nPlease create a Mattermost user by going at http://192.168.56.4:8065/ and follow\ninstructions.\n\nYou're now ready, you can new access services with the following URLs:\n\n- Sentry: http://192.168.56.4:9000/\n- Mattermost: http://192.168.56.4:8065/\n\nThe VM have a static IP so you can always access it with IP `192.168.56.4`.\nYou can find the IP of your computer accessible (most likely `192.168.56.1`)\nfrom the VM using:\n\n```sh\n$ ip a | grep 192.168.56 | awk '{print $2}'\n192.168.56.1/24\n```\n\nYou can now [configure webhooks](#configure-webhooks)\n\n### Configure webhooks\n\nThis step is planned to be automatised, but for now we must do it manually. It\naim to create [Mattermost incoming webhook](https://developers.mattermost.com/integrate/webhooks/incoming/)\nand [Sentry Webhook](https://docs.sentry.io/organization/integrations/integration-platform/webhooks/).\n\nYou can configure\n[Mattermost incoming webhook](https://developers.mattermost.com/integrate/webhooks/incoming/)\non any channel you want. To use it in development, replace\n[the content of the variable in the following line `SMS_MATTERMOST_WEBHOOK_URL=http://requests-catcher:5000`](/docker-compose.yml#L20)\nby your mattermost webhook.\n\nRestart (or start) the container by using:\n\n```sh\n$ docker compose up -d\n```\n\nFinally you must configure [Sentry Webhook](https://docs.sentry.io/organization/integrations/integration-platform/webhooks/).\nThe URL of the webhook should be `http://\u003cyour-ip\u003e:1323/\u003cchannel-name\u003e`, for\nexample, if your IP is `192.168.56.1` and the channel where you want to\npublish is `test` your URL will be: `http://192.168.56.1:1323/test`.\n\nYou can test if everything is working by following\n[Send errors to Sentry](#send-errors-to-sentry) or using your way.\n\n## Send errors to Sentry\n\nThe repository contains a python script that can be used to push errors to sentry.\nMake sure you've followed [the requirements](#requirement) before continue.\n\nYou should update the Sentry DSN in\n[scripts/sentry-trigger-error.py](/scripts/sentry-trigger-error.py#L4) by\nthe DSN of your project.\n\nYou can now trigger an error by using:\n\n```sh\n$ python scripts/sentry-trigger-error.py\nTraceback (most recent call last):\n  File \"/home/alex/Documents/sentry-mattermost-sidecar/scripts/sentry-trigger-error.py\", line 10, in \u003cmodule\u003e\n    division_by_zero = 1 / 0\n                       ~~^~~\nZeroDivisionError: division by zero\n```\n\nAn error should be generated on Sentry.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fits-alex%2Fsentry-mattermost-sidecar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fits-alex%2Fsentry-mattermost-sidecar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fits-alex%2Fsentry-mattermost-sidecar/lists"}