Monitoring and alerts
You can watch AFTAB from four places: the pages of the panel, alerts that reach you in Telegram, webhooks and metrics that feed your own tools, and the server’s command line. This page goes through them.
The Activity page, Settings → Integrations (where Telegram, webhooks, Prometheus metrics and the support bundle are) and the API tokens card in Settings → Security are hidden until you turn on Selling and operator tools in Settings → Panel (the full_mode setting). Anything already in use still shows.
The Overview
Section titled “The Overview”Overview shows the server’s load (CPU, memory, disk and uptime), the clients online, how many inbounds are up, the traffic of the last 14 days, Needs attention, Recent activity and Background jobs. Needs attention counts the clients that end within 7 days, the clients out of traffic and the clients new today, and lists the ones that end soon. Background jobs says whether every job ran on time, or how many need a look. The Logs button next to Backup and Restart shows the panel’s recent log. On a phone these three are in the General actions menu.
A dot beside a page in the menu means something waits there: orders to approve in the shop, an inbound that is not up, a bridge that is offline, an exit that is down, or an update. Each account chooses its own dots under Dots in the menu in Settings → Account. The dot for clients that ran out is off unless you switch it on.
The activity log
Section titled “The activity log”Activity lists who did what and when: sign-ins, changes made in the panel, clients running out of traffic, backups, updates. Filter it by Sign-ins, Clients, Network, Shop or System, or search it. It loads 50 events at a time, and new ones appear by themselves. The panel keeps the last 90 days and at most 50000 events. A reseller sees only what they did and what happened to their own clients.
The log is a chain: each event is tied to the one before it, so changing or removing one breaks the chain. The top of the page says whether it is unbroken, with the number of events checked. If it says the log was changed, compare it with the copies that your webhooks or Telegram alerts keep: each event there carries the same code that starts with #.
Alerts in Telegram
Section titled “Alerts in Telegram”In Settings → Integrations → Telegram, create a bot with @BotFather, paste its token, send /start to the bot, press Find my chat and add yourself, save, and press Send a test message. Only the chats you list get alerts and answers; other chats get nothing. The tg_alerts setting chooses the groups, under Alerts:
- Bridges and Iran: a bridge goes offline or comes back, an exit goes down or comes back (with or without a backup), a fleet server stops reporting or comes back, an inbound is blocked from Iran or reachable again, an exit fails over.
- Security: an address is blocked after failed sign-ins, two-factor sign-in is turned off, the admin login changes, an API token is made, the database is restored.
- System: the panel starts or updates, a new version is out, an update or backup fails, an update is rolled back, the panel crashes, the connection table is almost full, a bridge, exit or fleet server goes back to an older build, a certificate renewal fails, and the health alerts below.
- Clients: a client runs out of traffic or time. It can be many messages.
The first three are on from the start. Alerts that come together are sent as one message. Commands answers /status, /online, /client with a name and /backup, only in the admin chats.
Alerts for clients (tg_clients) lets each client link their own Telegram chat from their subscription page and get a message at 80% and 95% of their traffic and 3 days and 1 day before the end. Each alert goes once, until the condition has cleared and returned.
Health alerts
Section titled “Health alerts”The panel checks, every 10 minutes, what an owner can fix from a phone, and each problem is an event that the System alerts send. Each is told once, and again after a day while it lasts:
- The disk has less than 1 GB free, or less than 10% free.
- The database has grown to 1 GB, or has doubled in a week and grown by at least 100 MB.
- No automatic backup has been made for 48 hours.
- The panel or subscription certificate is not being renewed and is close to its end.
- A bridge, exit or fleet server runs an older agent than the panel.
- A bridge, exit or fleet server reports its connection table at least 80% full. The report also counts connections the kernel dropped.
- Bridges’ tunnels to this server are down.
aftab-dnsis not running while routing rules need it, oraftab-tlsis not running while TLS bridges need it.- The way to a bridge or exit loses more than 5% of packets over ten minutes. A bridge counts the packets that cross it: pings through its tunnel, pings to the panel when it only forwards, and retransmitted segments of its TLS connection.
If the panel stops without warning, a report is kept in /etc/aftab/crash/, the next start records a crash event, and nothing leaves the server unless you download the support bundle.
Webhooks
Section titled “Webhooks”Webhooks, in Settings → Integrations, send panel events as signed JSON to your own address. Add the address and choose the categories: sign-ins and security, clients, network, Shop, or system. The address must use https:// and reach a public host; redirects are not followed. Shop covers orders and payments. Health alerts are in system. With none ticked you get every event. You can have up to 10 webhooks. Test sends a test event. Each request carries X-Aftab-Event, X-Aftab-Delivery (the event’s id), X-Aftab-Timestamp and X-Aftab-Signature, which is a SHA-256 HMAC of the timestamp, a dot and the body, made with the webhook’s signing secret. Accept a delivery only when the signature matches and the timestamp is recent. A delivery that fails is tried again after 10 seconds, 1 minute and 5 minutes; deliveries still waiting when the panel stops are lost. The body carries the event’s code in the chain.
Metrics, logs and a support bundle
Section titled “Metrics, logs and a support bundle”Prometheus metrics, in Settings → Integrations, gives clients, traffic per client and inbound, the health and delay of exits, bridges, whether each fleet server is reporting and when it last did, how each background job last ended, the age of the newest automatic backup, the days left on the HTTPS certificates, whether an update is waiting, whether aftab-dns and aftab-tls run (only while something needs them), CPU, memory and disk in Prometheus’s text format, at api/v1/metrics under the panel’s address. Prometheus signs in with an API token that has the Read only access, which you make under API tokens in Settings → Security. On a large panel add ?clients=0 to leave out the per-client series.
On the server, sudo aftab status says whether the panel is running and how many WireGuard links are up, sudo aftab log follows the panel’s log, and sudo aftab health says whether the panel is up and answering, with exit status 0 when it is.
When you ask someone for help, Support bundle, in Settings → Integrations, gives one file with versions, settings, network state, recent logs, interfaces, routes and the firewall, and the crash reports. Keys, tokens, secret paths and subscription links are removed, and it has no client names or traffic per client. Press Download support bundle.
What can go wrong
Section titled “What can go wrong”- No alerts arrive. Telegram is off, the chat is not in the list, or the group is off under Alerts. Press Send a test message.
- Too many client alerts. Turn off the Clients group: it sends a message for every client that runs out.
- A webhook shows “Failed”. The panel shows how many deliveries failed in a row. Check the address and that your server answers with a 2xx status.
- The activity log says it was changed. See Security.
- An update did not work. See Updates and rollback.