Skip to content

notify: Adds support for gotify open-source notification service.#5380

Open
TheSp1der wants to merge 6 commits into
prometheus:mainfrom
TheSp1der:main
Open

notify: Adds support for gotify open-source notification service.#5380
TheSp1der wants to merge 6 commits into
prometheus:mainfrom
TheSp1der:main

Conversation

@TheSp1der

Copy link
Copy Markdown

Fixes #2120

Summary

This PR adds a new Gotify receiver integration.

  • Adds notify/gotify notifier implementation using Gotify’s /message API with X-Gotify-Key authentication.
  • Adds gotify_configs to the Alertmanager configuration and wires it into receiver integration building.
  • Adds default templates for gotify.default.title and gotify.default.message.
  • Includes unit tests covering:
    • JSON payload formatting and headers.
    • Optional extras.client::display.contentType for markdown delivery.
    • Reading URL and token from files and ensuring secrets are not leaked in errors.

Which user-facing changes does this PR introduce?

[FEATURE] Notify: Add Gotify receiver integration.

TheSp1der added 3 commits July 8, 2026 17:00
Signed-off-by: nhyatt <nhyatt@smoothnet.org>
Signed-off-by: nhyatt <nhyatt@smoothnet.org>
Signed-off-by: nhyatt <nhyatt@smoothnet.org>
@TheSp1der TheSp1der requested a review from a team as a code owner July 8, 2026 22:02
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: d636e772-f482-487d-9d84-50db40d6118c

📥 Commits

Reviewing files that changed from the base of the PR and between 70e1fbc and f198235.

📒 Files selected for processing (1)
  • notify/gotify/gotify.go
💤 Files with no reviewable changes (1)
  • notify/gotify/gotify.go

📝 Walkthrough

Walkthrough

This PR adds Gotify as a supported Alertmanager notification receiver. It introduces Gotify config parsing and wiring, implements HTTP delivery and template rendering, and adds validation and notifier tests.

Changes

Gotify Receiver Support

Layer / File(s) Summary
Gotify config schema and validation
notify/gotify/config.go, notify/gotify/config_test.go, config/config.go
Defines GotifyConfig with defaults and validation for url/url_file and token/token_file, adds Receiver.GotifyConfigs, and propagates HTTPConfig settings during config loading.
Receiver integration wiring
config/receiver/receiver.go
Registers Gotify notifier construction in BuildReceiverIntegrations for each configured Gotify entry.
Notifier implementation, templates, and tests
notify/gotify/gotify.go, notify/gotify/gotify_test.go, template/default.tmpl
Implements Gotify request rendering and HTTP POST delivery, adds tests for headers/body/content-type/file-based secrets, and defines default Gotify title/message templates.

Estimated code review effort: 3 (Moderate) | ~25 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding Gotify notification support.
Description check ✅ Passed The description covers the summary, user-facing change, linked issue, and release-note entry expected by the template.
Linked Issues check ✅ Passed The PR implements the requested Gotify receiver integration from #2120, including config wiring and notifier support.
Out of Scope Changes check ✅ Passed The changes are focused on Gotify integration, tests, and templates, with no obvious unrelated additions.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@notify/gotify/gotify.go`:
- Line 143: The Gotify auth header is incorrectly passing the token through the
template engine, which can mutate an opaque credential and bypass template
errors already checked earlier. Update the Gotify notifier logic in the function
that builds the request header to use the raw token directly in the X-Gotify-Key
header, matching the other notifier implementations that send credentials
without templating.
- Around line 106-108: Check tmplErr before parsing priority in gotify.Notify so
template failures are not masked by strconv.Atoi. In the priority handling
block, make sure the result of tmplText(n.conf.Priority) is accompanied by an
immediate tmplErr check before calling strconv.Atoi, and return that template
error directly if present. Keep the existing priority parsing path in Notify and
the later tmplErr handling consistent, but ensure the early priority parse
cannot turn a template failure into an "invalid syntax" error.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: b8b87b8f-4049-4f3c-843b-2bd1be89a778

📥 Commits

Reviewing files that changed from the base of the PR and between 963ed72 and 9bb0878.

📒 Files selected for processing (7)
  • config/config.go
  • config/receiver/receiver.go
  • notify/gotify/config.go
  • notify/gotify/config_test.go
  • notify/gotify/gotify.go
  • notify/gotify/gotify_test.go
  • template/default.tmpl

Comment thread notify/gotify/gotify.go
Comment thread notify/gotify/gotify.go Outdated
TheSp1der and others added 3 commits July 8, 2026 17:17
Prevent token from being processed by template engine.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: Nicolaas Hyatt <39059405+TheSp1der@users.noreply.github.com>
Updates return message to more accurately represent error instead of possible confusing "invalid syntax".

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Signed-off-by: Nicolaas Hyatt <39059405+TheSp1der@users.noreply.github.com>
Signed-off-by: nhyatt <nhyatt@smoothnet.org>
@TheMeier

Copy link
Copy Markdown
Contributor

This looks like a simple stateles JSON post to me. So two questions:

  • could this simply with a custom payload in the native webhook notifier
  • why not use nofity.PostJSON()

@TheSp1der

Copy link
Copy Markdown
Author

That's a good question:

  • A webhook can approximate this, but it pushes Gotify-specific schema/auth/templating onto every user. A native receiver makes the common case safe and easy, consistent with existing receiver integrations. (Alertmanager already has receivers that do the same thing. Discord, Slack webhook mode, Incident.io, etc.)
  • I didn’t use notify.PostJSON() because we need to set the X-Gotify-Key header. PostJSON currently doesn’t accept custom headers. I'm happy to update this if there’s an existing helper that supports headers, or I can add one, but that seemed out of scope for this.

@TheMeier

Copy link
Copy Markdown
Contributor

That's a good question:

  • A webhook can approximate this, but it pushes Gotify-specific schema/auth/templating onto every user. A native receiver makes the common case safe and easy, consistent with existing receiver integrations. (Alertmanager already has receivers that do the same thing. Discord, Slack webhook mode, Incident.io, etc.)

So the auth should be not an issue. The native webhhok supports many authentications ans cusomtizations. Especially setting a header is easy https://prometheus.io/docs/alerting/latest/configuration/#http_header
Regarding the template, a working template could be added to the default templates, docs and examples.

  • I didn’t use notify.PostJSON() because we need to set the X-Gotify-Key header. PostJSON currently doesn’t accept custom headers. I'm happy to update this if there’s an existing helper that supports headers, or I can add one, but that seemed out of scope for this.

You can use a custom roundtripper to acheive that, see eg here https://github.com/prometheus/alertmanager/blob/main/notify/rocketchat/rocketchat.go#L77-L115

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature suggestion: Add Gotify as receiver

2 participants