Zmjjeff7 opened a new pull request, #4132:
URL: https://github.com/apache/hertzbeat/pull/4132

   ### What is changed and how it works?
   
   This PR adds [ntfy](https://ntfy.sh) as a new alert notification channel
   (type=15) to HertzBeat. ntfy is a popular open-source HTTP-based
   push-notification service that is widely used in self-hosting communities,
   and it works well for receiving HertzBeat alerts on mobile devices and
   desktops without depending on third-party platforms.
   
   #### Backend changes
   - New handler `NtfyAlertNotifyHandlerImpl` in `hertzbeat-alerter`,
     extending `AbstractAlertNotifyHandlerImpl` with type id `15`
   - Three new fields on `NoticeReceiver`: `ntfyServerUrl`, `ntfyTopic`,
     `ntfyToken`
   - New configurable property `alerter.ntfy-default-server-url`
     (default: `https://ntfy.sh`)
   
   #### Feature highlights
   - **Priority mapping** — alert severity is mapped to ntfy priority levels
     (`critical`=5, `warning`=4, `info`/unknown=3, resolved alerts=2)
   - **Emoji tags** — status- and severity-aware tags
     (`rotating_light` + `skull` for critical firing, `warning` for warning,
     `white_check_mark` for resolved); the alertname is also appended as a
     plain-text tag
   - **Bearer token auth** — supports self-hosted ntfy instances with
     access-control tokens
   - **Click action** — notifications carry a click URL pointing to the
     HertzBeat console
   - **Markdown body** — alert content is rendered in Markdown for
     better readability on ntfy clients
   
   #### Frontend changes
   - Added ntfy option to the notification receiver type dropdown
   - Three new form fields: server URL (optional, default
     `https://ntfy.sh`), topic (required), access token (optional)
   - Display tag in the receiver list table
   - i18n translations for en-US, zh-CN, zh-TW, ja-JP, pt-BR
   
   #### Tests
   Added `NtfyAlertNotifyHandlerImplTest` with 16 test cases covering:
   - Successful send / non-2xx response / network errors
   - URL building (custom server, default server fallback,
     trailing-slash handling)
   - Bearer token header injection
   - Priority mapping for all severity levels and resolved state
   - Tag generation for critical/warning/info/resolved cases
   - Header presence and values (Priority, Tags, Click, Markdown)
   
   ### Checklist
   
   - [x] I have read the [Contribution 
Guidelines](https://github.com/apache/hertzbeat/blob/master/CONTRIBUTING.md)
   - [x] I have self-reviewed my code
   - [x] I have added unit tests covering the new feature
   - [x] My change follows the existing alert handler conventions
         (Gotify/ServerChan style)
   - [x] No HIP is required (new notification channel — small enhancement)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to