Sentry issue alerts in a Telegram chat, with enough detail to know what broke before you open Sentry.
sentrygram is a small HTTP service that receives the webhooks of a Sentry internal integration and posts one Telegram message per new issue and per issue that comes back (a regression or a reopen). Every other event (each new error, assignments, resolves, Seer) is answered and dropped, so a bad deploy that throws ten thousand errors is one message per issue, not ten thousand.
It is one static Go binary with no dependencies outside the standard library, shipped as a distroless image: ghcr.io/rahacloud/sentrygram.
sentrygram = Sentry + Telegram. That is all it does.
- Features
- How it works
- What a message looks like
- Quick start
- Setting it up
- Configuration
- Behaviour worth knowing
- Self-hosted Sentry
- Development
- Who is behind sentrygram
- License
- π― One message per issue, not per error. Only
createdandunresolvedissue webhooks are posted; a flood of events is one alert. - π Context without a click. With an API token it reads the issue's latest event and adds the environment, release, the in-app line of code that raised, the request, server and runtime.
- π Locked down. A secret path token, optional
Sentry-Hook-Signature(HMAC-SHA256) checks, and the bot token never reaches a log line. - π§Ή Noise filter. Drop issues by culprit prefix, such as a Django management shell.
- β‘ Answers Sentry at once. Sentry waits only one second for a webhook and retries one that took longer, so sentrygram answers first and delivers in the background, with its own retries.
- π Degrades gracefully. If Sentry's API is slow or down, the message still goes out, without the extra details.
- πͺΆ Tiny. Standard library only, one static binary, a distroless non-root image, a
GEThealth check on any path.
flowchart LR
S[Sentry<br>internal integration] -- "issue webhook<br>/hooks/telegram/TOKEN" --> R[sentrygram]
R -- "latest event<br>(optional, event:read)" --> A[Sentry API]
R -- "sendMessage (HTML)" --> T[Telegram chat]
π¨ ERROR Β· orders Β· production
ValueError: order 42 has no total
π app/orders/views.py:58 in retrieve
return Response(total(order))
π GET https://api.example.com/api/v1/orders/42/
π· release 1.4.2 Β· python Β· π₯ unhandled Β· high priority Β· server web-1 Β· CPython 3.14.0
π 3 events Β· 2 users Β· first seen 2026-11-10 13:42 UTC
ORDERS-7 β
| Line | Where it comes from |
|---|---|
| π¨ level, project, environment | the issue (π and "back again" when an issue returns); the environment from its latest event |
| exception | the issue's grouping metadata (type: value), else its title |
| π where, and the line of code | the latest event's innermost in-app frame of the exception that was raised, else its innermost frame; without the event, the issue's file and function, else its culprit |
| π request | the latest event's request method and URL, without the query string or fragment, which can carry tokens; else its transaction |
| π· facts | release, platform, handled or unhandled, priority, server, runtime, browser and OS, whichever are known |
| π counts | events, users and first seen, from the issue |
| link | the issue in Sentry |
Without an API token sentrygram still posts the issue's own details: everything above except the environment, release, line of code, request, server and runtime.
docker run -d --name sentrygram -p 8080:8080 \
-e TELEGRAM_BOT_TOKEN=123456:ABC... \
-e TELEGRAM_CHAT_ID=-1001234567890 \
-e RELAY_PATH_TOKEN="$(openssl rand -base64 24 | tr '+/' '-_')" \
-e SENTRY_URL=https://sentry.example.com \
-e SENTRY_API_TOKEN=... \
ghcr.io/rahacloud/sentrygram:mainGET on any path answers 200, for health checks. In production pin an immutable tag (sha-<commit>) rather than main.
- Create a bot with @BotFather (
/newbot) and keep its token. - Add the bot to the group or channel the alerts go to. In a channel it must be an administrator that may post.
- Find the chat id: send a message in the chat and read
https://api.telegram.org/bot<token>/getUpdates, or callgetChatwith the id you expect. Basic groups have ids like-123456789; supergroups and channels like-1001234567890.
- In Sentry: Settings βΊ Developer Settings βΊ Custom Integrations βΊ Create New Integration βΊ Internal Integration.
- Webhook URL:
https://<where sentrygram is reachable>/hooks/telegram/<RELAY_PATH_TOKEN>. Any path works; sentrygram only checks its last segment. - Permissions: Issue & Event β Read. This is the
event:readscope the API token needs. - Webhooks: tick issue. Leave error off; sentrygram would drop those anyway.
- Save, then under Tokens create a token and pass it as
SENTRY_API_TOKEN. Optionally pass the integration's Client Secret asSENTRY_CLIENT_SECRETso that every webhook's signature is checked.
A test issue has to be new: Sentry groups events with the same message into the existing issue, and only a new issue sends created. Give the test event its own fingerprint, for example with the Python SDK:
import uuid, sentry_sdk
sentry_sdk.init(dsn="https://<key>@sentry.example.com/<project>")
with sentry_sdk.new_scope() as scope:
scope.fingerprint = [f"sentrygram-test-{uuid.uuid4()}"]
sentry_sdk.capture_message("sentrygram test", level="error")
sentry_sdk.flush()sentrygram logs one JSON line per decision (posted, dropped noise, refused an unauthorized request, posting without the event's details, telegram failed, retrying, telegram failed, message lost), so docker logs sentrygram tells you what happened to each webhook.
Everything is an environment variable.
| Variable | Required | Meaning |
|---|---|---|
TELEGRAM_BOT_TOKEN |
yes | the bot's token |
TELEGRAM_CHAT_ID |
yes | the chat to post to; the bot must be a member |
RELAY_PATH_TOKEN |
when reachable from the internet | the last path segment every webhook must carry; any other request gets a 404 |
SENTRY_CLIENT_SECRET |
no | the integration's client secret; checks Sentry-Hook-Signature (HMAC-SHA256 of the body) |
SENTRY_API_TOKEN |
no | the integration's token (event:read); adds the latest event's details |
SENTRY_URL |
no | Sentry's address, for the API and for links when a payload carries none; default https://sentry.io |
SENTRY_ORG |
no | the organization slug; by default it is read from the issue's link (/organizations/<slug>/) |
NOISE_CULPRITS |
no | comma-separated culprit prefixes whose issues are dropped, e.g. django.core.management.commands.shell |
ADDR |
no | listen address; default :8080 |
- What is posted: webhooks with
Sentry-Hook-Resource: issueand actioncreatedorunresolved. These get a 202 as soon as they are checked, and the message is sent in the background. Everything else gets a 200 and no message. - Why it answers first: Sentry gives a webhook one second (
sentry-apps.webhook.timeout.sec), retries a timeout three times five minutes apart, and counts timeouts toward disabling the integration. Reading the event and calling Telegram can take longer than that, so neither happens while Sentry waits. - Failures: a message that Telegram cannot take is tried 4 times, 2, 4 and 8 seconds apart, or after the
retry_afterTelegram asks for when it rate-limits. A permanent refusal (a wrong chat, a bot that is not a member) is not retried. Every failure is logged (telegram failed, retrying, andtelegram failed, message lostwhen it gives up). If reading the event from Sentry fails or takes more than 5 seconds, the message goes out without the event's details rather than not at all. - Shutdown: on
SIGTERMsentrygram stops taking webhooks and waits up to 25 seconds for the messages it has already accepted. - No authentication is a warning: with neither
RELAY_PATH_TOKENnorSENTRY_CLIENT_SECRETset, anyone who can reach the address can post to the chat, and sentrygram says so at startup. - Secrets: the bot token never reaches a log line; an error that would carry it has it replaced by
<token>. Request URLs lose their query strings before they are posted. - Formatting: messages use Telegram's HTML mode and everything that comes from Sentry is escaped. Long titles, culprits and lines of code are clipped.
-
Private addresses are refused. Since 25.9, self-hosted Sentry does not send webhooks to private or reserved addresses (
SENTRY_DISALLOWED_IPS), and its taskworker logssend_and_save_webhook_request.restricted_ip. So sentrygram cannot be reached ashttp://sentrygram:8080on Sentry's own compose network. Publish it behind your reverse proxy under a public name, and keepRELAY_PATH_TOKEN(orSENTRY_CLIENT_SECRET) set. -
The
internalproject sends no integration webhooks. Sentry skips its own project (id 1); test with another one. -
Running it next to Sentry: add it to Sentry's
docker-compose.override.yml, published on an internal address your proxy reaches:services: sentrygram: image: ghcr.io/rahacloud/sentrygram:sha-<commit> restart: unless-stopped ports: - "10.0.0.5:9001:8080/tcp" environment: - TELEGRAM_BOT_TOKEN=... - TELEGRAM_CHAT_ID=... - RELAY_PATH_TOKEN=... - SENTRY_URL=https://sentry.example.com - SENTRY_API_TOKEN=...
Then route the webhook path to it, for example with Traefik's file provider:
http: routers: sentrygram: rule: "Host(`sentry.example.com`) && PathPrefix(`/hooks/telegram/`)" entrypoints: [websecure] service: sentrygram tls: certResolver: letsencrypt services: sentrygram: loadBalancer: servers: - url: "http://10.0.0.5:9001"
You need Go 1.27 and just.
just test # go test -race with coverage
just lint # golangci-lint
just build # ./sentrygram
just image # docker buildThe code is three packages. internal/relay decides what is posted and writes the message, with no I/O. internal/sentry reads an issue's latest event from Sentry's API. internal/telegram sends to the Bot API. cmd/sentrygram wires them together from the environment. The tests use synthetic payloads in internal/sentry/testdata/; never commit a real event, which carries URLs, file paths and user data.
CI lints and tests every push and pull request. Every push to main and every v* tag publishes a linux/amd64 + linux/arm64 image tagged with the branch or version and with sha-<commit>.
sentrygram is built and maintained by Raha Cloud, an infrastructure and DevOps consulting team. We run it in production for Hatchup Capital, where it relays Sentry issues to the team's Telegram chat. If you would rather have someone set up and operate your Sentry, monitoring or deployments for you, get in touch.