Sign inSign up

tuanngocptn/sentry-telegram-webhook

By tuanngocptn

•Updated 10 months ago

Webhook for Sentry which allows sending notification via Telegram messenger.

Image
Message queues
API management
Web servers
0

2.0K

tuanngocptn/sentry-telegram-webhook repository overview

⁠Sentry Telegram Webhook

⁠Table of Contents
  1. Requirements⁠
  2. Installation⁠
  3. Environment variables⁠
  4. Custom Integrations Configuration⁠
  5. Running the app (normal)⁠
  6. Running the app with docker (Recommended)⁠
  7. License⁠

Description: Webhook for Sentry which allows sending notification via Telegram messenger.

  • Github Repository: HERE⁠.

  • Docker Hub: HERE⁠.

  • The result will look like this:

Sentry Telegram Webhook Result

⁠Requirements

  • Nodejs 18+ (recommend: 20+)

⁠Installation

$ npm install

⁠Environment variables

NameIs RequireTypeNoteValue
LANGUAGEYesstringThe language of message when sendvi,en,ru
TELEGRAM_BOT_TOKENYesstringThe token from @BotFather telegram check HERE⁠ for see how to get this.
TELEGRAM_GROUP_IDYesnumberThe id of your telegram group. You can use telegram API for check that through Postman. Check HERE⁠ for more detail. Normally, that start with -100...
TELEGRAM_TOPIC_IDNonumberThe id of you topic if you enable Topics in group setting.
SENTRY_URLNostringYour Sentry URL (e.g. https://sentry.io⁠ or https://sentry.example.com⁠ for self-hosted). Defaults to https://sentry.io⁠
SENTRY_INTEGRATION_TOKENYesstringThe token that geneate by sentry. Check HERE⁠ for more detail.
SENTRY_ORGANIZATION_SLUGYesstringThe organization slug in your sentry organization setting
SENTRY_PROJECT_SLUG_ALLOW_LISTNostringyour Project slug list (Not require - split with comma , character)setting

⁠Custom Integrations Configuration

  • Create the new integrations check HERE⁠ for more detail.

  • After you create the new integration then you need config some parts like below image

Note: <your-server-here.domain> is your webhooks server (Full Webhook Urls is https://<your-server-here.domain>/sentry/webhooks). If you are running locally. You can use Ngrok⁠ for generate this.

sentry internal integration config detail

  • And permission, that allow you trigger to you webhook.

sentry internal integration config permission

⁠Running the app (normal)

  1. Clone .env.template file

    cp .env.template .env
    
  2. Edit .env file with your value.

    LANGUAGE=en
    TELEGRAM_BOT_TOKEN=<get from bot father>
    TELEGRAM_GROUP_ID=<your telegram group id or telegram channel id>
    TELEGRAM_TOPIC_ID=<not require - your telegram topic (when enable Topics in group setting)>
    SENTRY_URL=<your Sentry URL, e.g. https://sentry.io or https://sentry.example.com for self-hosted>
    SENTRY_INTEGRATION_TOKEN=<token in Custom Integrations in Sentry Setting>
    SENTRY_ORGANIZATION_SLUG=<your Sentry org slug>
    SENTRY_PROJECT_SLUG_ALLOW_LIST=<your Project slug list (Not require - split with comma `,` character)>
    
  3. Run with npm

    # development
    $ npm run start
    
    # watch mode
    $ npm run start:dev
    
    # production mode
    $ npm run start:prod
    

Note: You don't need run npm install and setup nodejs.

  1. Run direct from docker hub: (don't need clone the repository)
  • Docker run - run direct with this command:

    docker run \
      -v /tmp/sentry-telegram-hook/logs:/code/logs \
      -p 3000:3000 \
      -e LANGUAGE=en \
      -e TELEGRAM_BOT_TOKEN=<TELEGRAM_BOT_TOKEN> \ #get from bot father
      -e TELEGRAM_GROUP_ID=<TELEGRAM_GROUP_ID> \ #your telegram group id or telegram channel id
      -e TELEGRAM_TOPIC_ID=<TELEGRAM_TOPIC_ID> \ #not require - your telegram topic when enable Topics in group setting
      -e SENTRY_URL=<SENTRY_URL> \ #your Sentry URL (e.g. https://sentry.io or https://sentry.example.com for self-hosted)
      -e SENTRY_INTEGRATION_TOKEN=<SENTRY_INTEGRATION_TOKEN> \ #token in Custom Integrations in Sentry Setting
      -e SENTRY_ORGANIZATION_SLUG=<SENTRY_ORGANIZATION_SLUG> \ #your Sentry org slug
      -e SENTRY_PROJECT_SLUG_ALLOW_LIST=<SENTRY_PROJECT_SLUG_ALLOW_LIST> \ #your Project slug list (Not require - split with comma `,` character)
      tuanngocptn/sentry-telegram-webhook:latest
    
  • Docker compose - create the compose file with below information. More details HERE⁠.

    Note: If you would like to use Gihub Container Registry (ghcr) instead of Docker hub. Please following THIS⁠ before run below docker compose

    services:
      app:
        # Docker hub package
        image: tuanngocptn/sentry-telegram-webhook:latest
        # Github container registry (ghcr)
        # image: ghcr.io/tuanngocptn/sentry-telegram-webhook:latest
        environment:
          - LANGUAGE=en
          - TELEGRAM_BOT_TOKEN=<get from bot father>
          - TELEGRAM_GROUP_ID=<your telegram group id or telegram channel id>
          - TELEGRAM_TOPIC_ID=<not require - your telegram topic (when enable Topics in group setting)>
          - SENTRY_URL=<your Sentry URL, e.g. https://sentry.io or https://sentry.example.com for self-hosted>
          - SENTRY_INTEGRATION_TOKEN=<token in Custom Integrations in Sentry Setting>
          - SENTRY_ORGANIZATION_SLUG=<your Sentry org slug>
          - SENTRY_PROJECT_SLUG_ALLOW_LIST=<your Project slug list (Not require - split with comma `,` character)>
        ports:
          - 3000:3000
        volumes:
          - ./logs:/code/logs
    
  1. For running locally (debug):
  • Clone docker-compose-template.yml

    cp docker-compose-template.yml docker-compose.yml
    
  • Edit environment variables:

    environment:
      - LANGUAGE=en
      - TELEGRAM_BOT_TOKEN=<get from bot father>
      - TELEGRAM_GROUP_ID=<your telegram group id or telegram channel id>
      - TELEGRAM_TOPIC_ID=<not require - your telegram topic (when enable Topics in group setting)>
      - SENTRY_URL=<your Sentry URL, e.g. https://sentry.io or https://sentry.example.com for self-hosted>
      - SENTRY_INTEGRATION_TOKEN=<token in Custom Integrations in Sentry Setting>
      - SENTRY_ORGANIZATION_SLUG=<your Sentry org slug>
      - SENTRY_PROJECT_SLUG_ALLOW_LIST=<your Project slug list (Not require - split with comma `,` character)>
    
  • Run with docker:

    docker compose up
    
  1. For running production (release):
  • Clone docker-compose-prod-template.yml

    cp docker-compose-prod-template.yml docker-compose.yml
    
  • Edit environment variables:

    environment:
      - LANGUAGE=en
      - TELEGRAM_BOT_TOKEN=<get from bot father>
      - TELEGRAM_GROUP_ID=<your telegram group id or telegram channel id>
      - TELEGRAM_TOPIC_ID=<not require - your telegram topic (when enable Topics in group setting)>
      - SENTRY_URL=<your Sentry URL, e.g. https://sentry.io or https://sentry.example.com for self-hosted>
      - SENTRY_INTEGRATION_TOKEN=<token in Custom Integrations in Sentry Setting>
      - SENTRY_ORGANIZATION_SLUG=<your Sentry org slug>
      - SENTRY_PROJECT_SLUG_ALLOW_LIST=<your Project slug list (Not require - split with comma `,` character)>
    
  • Run with docker:

    docker compose up
    

⁠License

Nest is MIT licensed⁠.

Tag summary

Content type

Image

Digest

sha256:510274393…

Size

145.8 MB

Last updated

10 months ago

docker pull tuanngocptn/sentry-telegram-webhook