> ## Documentation Index
> Fetch the complete documentation index at: https://aeros-c1d071c8.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Failure alerts

> Send a Discord, Telegram, ntfy, or JSON webhook when a managed service fails, using systemd OnFailure=.

AerosPanel does not watch your services. When alerts are on, it adds an `OnFailure=` hook to each managed unit, and `systemd` itself starts a short notification job when a unit enters the `failed` state. The panel can be idle, or even stopped, and alerts still fire.

> [!NOTE]
>
> Alerts need Linux with `systemd`. On other hosts, `GET /api/settings/alerts` reports `"supported": false` and saving returns `409`.

## Configure

**1. Open Settings**

Go to **Settings > SYSTEMD\_FAILURE\_ALERTS**.

**2. Pick a provider and URL**

Choose a **PROVIDER** and paste the **WEBHOOK\_URL**. See [providers](#providers) for the URL format each one expects.

**3. Enable and save**

Set **STATUS: ENABLED** and press **SAVE\_ALERT\_CONFIG**.

**4. Send a test**

Press **TEST**. The panel posts a test message to the saved URL and shows an error if the endpoint does not answer with a `2xx` status.

Once saved, the URL is never sent back to the browser. To change providers or URLs, enter a new one. Saving with the same provider and an empty URL keeps the stored URL.

## Providers

| Provider | URL | Request |
| :- | :- | :- |
| Discord | A channel webhook URL, `https://discord.com/api/webhooks/<id>/<token>` | `POST` JSON `{"content": "...", "allowed_mentions": {"parse": []}}` |
| Telegram | `https://api.telegram.org/bot<token>/sendMessage?chat_id=<chat-id>` | `POST` JSON `{"chat_id": "...", "text": "..."}`. `chat_id` is moved from the query string into the body. |
| ntfy | A topic URL, such as `https://ntfy.sh/<topic>` or your own server | `POST` plain text message body |
| JSON webhook | Any HTTP or HTTPS endpoint | `POST` JSON, see below |

`chat_id` is required for Telegram. It can be a numeric ID (negative for groups) or an `@channelname`.

The message is `AerosPanel: <service>.service failed.` for a real failure and `AerosPanel: test alert.` for a test.

### JSON webhook payload

```json Failure theme={null}
{
  "event": "service.failed",
  "service": "discord-bot.service",
  "message": "AerosPanel: discord-bot.service failed.",
  "timestamp": "2026-11-21T18:00:00.000Z"
}
```

```json Test theme={null}
{
  "event": "alert.test",
  "service": null,
  "message": "AerosPanel: test alert.",
  "timestamp": "2026-11-21T18:00:00.000Z"
}
```

### URL rules

* `http://` or `https://` only, 4096 characters at most.
* No embedded credentials (`user:pass@`), no `#fragment`, and no whitespace or control characters.
* Redirects are refused, and requests time out after 10 seconds.

## What gets written

Saving an enabled configuration writes three kinds of files:

| Path | Mode | Contents |
| :- | :- | :- |
| `/etc/aeros-panel/alerts.env` | `0600` (directory `0700`) | `AEROS_ALERTS_CONFIG=<base64 JSON>` with the provider, URL, and enabled flag. |
| `/etc/systemd/system/aeros-notify@.service` | `0644` | The template unit that sends the notification. |
| `/etc/systemd/system/<service>.service.d/10-aeros-alerts.conf` | `0644` | A drop-in for each managed project. |

Files are written to a temporary file and renamed into place, then the panel runs `systemctl daemon-reload`.

The drop-in adds one line to each project unit:

```ini /etc/systemd/system/discord-bot.service.d/10-aeros-alerts.conf theme={null}
[Unit]
OnFailure=aeros-notify@%n.service
```

The notification unit runs the panel's compiled `alerts.js` with Node, with a sandbox:

```ini /etc/systemd/system/aeros-notify@.service theme={null}
[Unit]
Description=AerosPanel failure notification for %i

[Service]
Type=oneshot
ExecStart=:"/usr/bin/node" "/opt/aeros-panel/backend/dist/system/alerts.js" %i
TimeoutStartSec=15s
NoNewPrivileges=yes
ProtectSystem=strict
ProtectHome=read-only
PrivateTmp=yes
UMask=0077
```

When `discord-bot.service` fails, `systemd` starts `aeros-notify@discord-bot.service.service`. The script reads `alerts.env` and sends one request.

> [!WARNING]
>
> The webhook URL often contains a token (Discord, Telegram). It lives only in `alerts.env`, which only root can read. It is never stored in SQLite or logged.

## New and deleted projects

* Creating a project while alerts are enabled installs its drop-in right away.
* Deleting a project removes its drop-in.
* Disabling alerts removes every `10-aeros-alerts.conf` drop-in. `alerts.env` stays so you can re-enable without re-entering the URL.

## When does a unit fail?

`OnFailure=` fires each time the unit enters the `failed` state: the main process exits with a non-zero code, is killed by a signal (including the OOM killer when it hits `MemoryMax=`), or fails to start. Project units use `Restart=always` with the default `RestartMode=normal`, so a crashing service passes through `failed`, sends an alert, and is restarted 5 seconds later. A service in a crash loop sends one alert per crash.

A clean exit with code `0` and a `systemctl stop` do not trigger an alert.

To check the hook on a unit:

```bash theme={null}
systemctl show -p OnFailure discord-bot
journalctl -u 'aeros-notify@*' -n 20
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.