Add Telegram receiver as default Alertmanager route #41
No reviewers
Labels
No labels
domain:backend
domain:devops
domain:frontend
status:approved
status:in-progress
status:needs-fix
status:qa
type:bug
type:devops
type:feature
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
forgejo_admin/pal-e-platform!41
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "40-add-telegram-alertmanager-receiver"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Adds a Telegram receiver to Alertmanager and makes it the default route when configured. The bot token is injected via
set_sensitive(matching the existing Slack pattern) so it never appears in state or plan output. Also reducesrepeat_intervalfrom 12h to 4h for faster re-notification.Changes
telegramreceiver withtelegram_configs(send_resolved: true, parse_mode: HTML) to the receivers concat list. Changed default route receiver to"telegram"whentelegram_bot_tokenis set (falls back to"default"otherwise). Added dynamicset_sensitiveblock fortelegram_bot_tokenwith computed receiver index (accounts for optional Slack receiver). Changedrepeat_intervalfrom12hto4h.telegram_bot_token(string, sensitive, default"") andtelegram_chat_id(number, default0) variables.Test Plan
tofu fmt-- passes (no changes)tofu validate-- cannot run in worktree (no cached providers), but HCL syntax is valid pertofu fmt -checktelegram_bot_tokenandtelegram_chat_idset, verify Alertmanager config shows telegram as default receivertelegram_bot_token=""to verify fallback to"default"receiverReview Checklist
tofu fmtpassestofu validateattempted (provider cache unavailable in worktree)set_sensitivedynamic block, not yamlencodeCloses #40Related
tofu plan
Cannot run
tofu planin worktree (no provider cache / state). Plan should be run from the main checkout before apply.Self-Review
Verdict: LGTM -- no issues found.
Checked
telegram_bot_tokeninjected viaset_sensitivedynamic block -- matches the existing Slack pattern exactly. Token never appears in yamlencode or plan output.telegram_chat_id(non-sensitive number) correctly placed in yamlencode block.set_sensitivepath uses${var.slack_webhook_url != "" ? 2 : 1}-- correctly accounts for the concat order (default=0, slack=1 when present, telegram shifts accordingly)."telegram"only whentelegram_bot_tokenis set; falls back to"default"otherwise.defaultnull receiver and conditionalslackreceiver are completely unchanged.repeat_intervalchanged from12hto4has specified.tofu fmt -checkpasses with no changes needed.telegram_configsincludessend_resolved: trueandparse_mode: "HTML"as required.PR #41 Review
BLOCKERS
None. The implementation is correct and well-structured.
NITS
No validation on
telegram_chat_id-- Whentelegram_bot_tokenis set buttelegram_chat_idis left at default0, Alertmanager will create a telegram receiver with an invalid chat ID, which could cause delivery errors at runtime. Consider adding a validation block similar to harbor/minio passwords, or gating the telegram receiver on bothtelegram_bot_token != ""ANDtelegram_chat_id != 0. Low severity since the user must consciously set both values.Missing
tofu planoutput -- PR conventions requiretofu planfor Terraform changes. The PR explains this is a worktree limitation (no cached providers/state). Acceptable given the constraint, but the plan should be run from the main checkout before apply.SOP COMPLIANCE
40-add-telegram-alertmanager-receiver-> issue #40)Closes #40set_sensitive, notyamlencode)tofu fmtcompliance confirmed per PR checklistReview Details
Security (PASS): The
telegram_bot_tokenis correctly handled viadynamic "set_sensitive"block (line 311-318 ofmain.tf), exactly matching the existing Slack webhook pattern. The token never entersyamlencodeand will not appear in plan/state output.Receiver index calculation (PASS): The
concat()ordering is[default, slack?, telegram?], making the indexreceivers[1]when Slack is absent andreceivers[2]when Slack is present. The expressionvar.slack_webhook_url != "" ? 2 : 1correctly maps to this.Default route conditional (PASS):
var.telegram_bot_token != "" ? "telegram" : "default"correctly falls back to the null receiver when Telegram is not configured. When both Slack and Telegram are configured, Telegram becomes the default route while Slack handles severity-matched alerts via its sub-route.Existing receivers unchanged (PASS): The
"default"null receiver and"slack"conditional receiver are structurally identical to the pre-PR state. The only change in that block is the trailing comma on] : [],to accommodate the newconcat()segment.repeat_intervalchange (PASS):12hto4his intentional per the PR description. Reasonable for a platform with active alerting.Variable definitions (PASS):
telegram_bot_tokenisstring,sensitive = true, default"".telegram_chat_idisnumber, default0. Both have descriptions. Types and defaults are appropriate.VERDICT: APPROVED