Push notifications¶
The messaging service can send push notifications through ntfy or a self-hosted ntfy-compatible server.
Use push notifications when LogMan.io notifications should appear on subscribed mobile devices, desktop clients, browser sessions, or other ntfy subscribers.
Prerequisites¶
Before configuring push notifications, make sure that:
- an ntfy server is available, for example
https://ntfy.shor a self-hosted ntfy server - the LogMan.io server can reach the ntfy server over HTTPS
- a topic name is available for the notifications
- subscribers are configured for the topic in the ntfy mobile app, desktop app, web app, CLI, or another compatible client
- the topic name is not easy to guess if the ntfy server allows public unauthenticated topics
- a default topic is available if notification requests should be allowed to omit
topic
Note
This configuration uses ntfy topic-based publishing. The configured topic is part of the delivery address, so the topic name must match the ntfy server policy.
Required configuration fields¶
| Field | Description |
|---|---|
url |
Base URL of the ntfy server, for example https://ntfy.sh. |
Optional configuration fields¶
| Field | Description |
|---|---|
default_topic |
Topic used when a notification request does not provide topic. |
timeout |
HTTP request timeout in seconds. The default is 10. |
Configuration sample¶
Edit model.yaml to configure the asab-iris service:
define:
type: rc/model
services:
asab-iris:
instances:
- node1
asab:
config:
push:
url: "https://ntfy.sh"
default_topic: "logman-alerts"
timeout: 10
ntfy setup¶
- Choose the ntfy server that will receive notifications.
- Choose a topic name, for example
logman-alerts. - Subscribe the required devices or clients to the topic.
- Copy the ntfy server base URL to
push.url. - Set
push.default_topicif notifications should use a default topic. - Set
push.timeoutif the default timeout is not suitable for the deployment. - Update
/Site/model.yaml. - Apply the model from the Library, or run the deployment apply command used by the installation.
- Send a test push notification.
Warning
On public ntfy servers, anyone who knows the topic name may be able to subscribe to that topic. Use a non-obvious topic name, or use a self-hosted ntfy server with the access controls required by the deployment.
Verify the configuration¶
The configuration is ready when:
- the service starts without push notification configuration errors
- the LogMan.io server can connect to the configured ntfy server
- a test notification appears on a client subscribed to the expected topic
- the service logs do not contain ntfy API or network errors
Push templates¶
Push notification templates must be stored in the /Templates/Push/ directory in the Library.
Example template:
TITLE: {{ severity }} notification
{{ message }}
The optional TITLE: line is used as the notification title and is removed from the message body before sending.
Web request example¶
{
"body": {
"template": "/Templates/Push/alert.md",
"params": {
"severity": "High",
"message": "New security notification"
}
}
}
If topic is not provided, the service uses push.default_topic.
Kafka notification example¶
When sending through Kafka, set type to push.
{
"type": "push",
"body": {
"template": "/Templates/Push/alert.md",
"params": {
"severity": "High",
"message": "New security notification"
}
}
}
Notification metadata¶
Push notifications can include optional display metadata in body.params.
| Parameter | Description |
|---|---|
title |
Notification title. Overrides a TITLE: line in the template. |
priority |
ntfy notification priority. |
tags |
ntfy tags shown by compatible clients. |
click |
URL opened when the notification is clicked. |
Example:
{
"topic": "logman-alerts",
"body": {
"template": "/Templates/Push/alert.md",
"params": {
"title": "High CPU",
"priority": "high",
"tags": "warning,monitoring",
"click": "https://grafana.example.com/d/abc123",
"message": "CPU usage above 90% on node ant-3"
}
}
}
If click is not provided, the service uses the first URL found in the rendered message, if one is present.