# Alerts

*Settings > Alerts* makes qKVM watch the machines and tell you when one goes offline, loses
its picture, has its login rejected or its certificate changed, reports a critical fault (a
server), and when that is over. A change counts once it has lasted about half a minute, so
one hiccup stays quiet.

- **Where they go:** to the destinations you add (*Add destination*, at the top right), as
  many as you like (fifty at the most), each of these kinds:
  - **Email (SMTP):** your own mail server, or Gmail. Always encrypted: STARTTLS on port 587
    or TLS on 465 (no other port), with the server's certificate checked; a server that does
    not offer STARTTLS on 587 is sent nothing. For Gmail: `smtp.gmail.com`, 587, your address
    as the user name, and an *app password* (Google Account, Security, App passwords), never
    the password of the account. Up to ten addresses to send to. The password is kept as it
    is typed, blanks at its ends too. One of fewer than four characters (those blanks not
    counted) is refused, typed or saved: what the server says back is shown with the password
    taken out, and one that short could not be told apart from the server's own words.
  - **Email (Resend):** mail through Resend, by its API key; the sender is of a domain you
    verified there.
  - **Slack:** an incoming webhook, or a service that takes Slack's messages.
  - **Microsoft Teams:** a Workflows webhook (in Teams, *Workflows*, "Post to a channel when
    a webhook request is received"), sent an Adaptive Card with a button to the wall. The
    Office 365 connectors (addresses on `outlook.office.com` and `webhook.office.com`) were
    retired by Microsoft, take nothing any more, and are refused with a sentence saying so.
  - **Telegram:** a bot (from BotFather) and the chat it writes to: its number (`-100...` for
    a group or a channel) or a channel's `@name`.
  - **Discord:** a webhook (Server Settings, Integrations, Webhooks). It may mention nobody.
  - **PagerDuty:** an integration of the Events API v2, by its routing key, in the US or the
    EU region. A problem opens an incident and "back to normal" resolves it: one incident per
    machine and kind of trouble (down, login, a problem, the screen), so a machine that goes
    offline and then answers without a picture stays one incident.
  - **ntfy:** a topic on ntfy.sh or on a server of your own, with an access token where it
    asks for one. A tap on the notification opens the wall at the tile.
  - **Webhook (JSON):** anything that takes a JSON POST, signed (below).
- Every address, key, token and password of a destination is stored encrypted with the
  saved passwords, and never shown again: the list shows where it goes by its host only. A
  password, token or key goes only where it was saved for: where a destination is to be
  reached elsewhere (another host or port in its address, another mail server or port,
  PagerDuty's other region), it is typed again, and the box asks for it.
- **Edited to send elsewhere, a destination starts with nothing known:** another address (a
  webhook's, a chat's or ntfy's, its path and topic included), another Telegram chat, another
  PagerDuty routing key or region, other recipients of a mail, or another mail server. What
  the receiver before was told is not carried over: the new one is told no "back to normal",
  no reminder and no "Backups are made again" of a trouble it never heard, and what waited for
  the destination is dropped (its log says "Not sent"). A trouble still open at the receiver
  before (a PagerDuty incident, a message in a channel) is closed there by hand, and a machine
  already in trouble is told to the new receiver at its next trouble. Its name, the events it is
  told, the machines it hears of, its quiet hours, its login, token or signing secret keep what it knows.
- **Each destination is told what it asked for.** *Tell it* ticks the events; *From* sets
  how serious one has to be (below); *KVMs* is all machines (new ones too), or chosen
  machines and groups, as an account is limited to some (a group's machines whichever are in
  it on the day). The kinds under *Tell me when* are the wall's: what is not ticked there is
  told to no destination and no browser.
- **Send test** on each tries it at once and says what its service answered, in its own
  words: a mail server's `535 5.7.8 Username and Password not accepted`, Slack's
  `invalid_token`, Telegram's `chat not found`, with every secret of the destination taken
  out. A machine's secret (a token, a key, a signing secret, and of an address its path, its
  query, and the name and password in it), whatever its letters, goes whole and in part.
  Whole in any case and spelling: its other signs changed or left out, and read through JSON's
  escapes, an address's percent escapes and HTML's character references (`&amp;`, `&#38;`); a
  percent escape is read as one byte, so a letter of two bytes written that way (`%C3%A4`) is
  not read as that letter. In part wherever six of its signs stand together as the text has
  them (not read through escapes), in any case, also within a word of the service's (an ntfy
  topic `office-alerts` takes `alerts` with it). What stands between an address's slashes in
  small letters alone is taken for a word of the address, such as `services` or `manual`,
  which qKVM cannot tell from the service's own words: it goes only where it stands as a word
  of its own, and so does a topic or an id written that way. A mail login's password is a
  person's: it goes whole only, in any case and spelling as above, composed or not, with the
  blanks at its ends or without them, and only where it stands whole, so that the server's own
  words stay. One of fewer than six letters and digits goes so only where it has two runs of
  them or more (`x9!Q#z`) and the text shows them in as many; with one run (`Mail!`), only as
  it is spelt, in any case. Its host is shown as it
  is (the list shows it too): a receiver that carries its token in its host name has it shown
  there. **Log** shows the last fifty deliveries since qKVM started: when, what, and how each
  went, after how many attempts.
- Every change is also written to the activity log, with or without a destination.
- **An alert says where to look.** *Link in alerts* is the address of the wall as you reach
  it; an alert then carries a link that opens the wall at the tile it is about. Leave it
  empty for alerts without one.
- **One machine can be left out:** *Settings > KVMs > Edit > Send alerts about this one*. For
  a test bench that is switched on and off all day, or a machine that sleeps.
- **A machine's screen can be watched** (below): *Settings > KVMs > Edit*, *No signal for* and
  *Screen unchanged for*, in minutes.
- **On a phone:** *Settings > Alerts > This browser* has them told to the browser it is pressed
  in, by Web Push ([below](https://qkvm.com/docs/alerts#on-a-phone)): for any account, of the machines it may see.
- **Pause for maintenance:** *Pause alerts*, for an hour or for four, sends nothing new while
  machines are worked on, restarts included; the daily seal of the activity log is no alert of
  a machine and goes within a pause too ([Activity log](https://qkvm.com/docs/activity-log)). When the pause is
  over, what is not as it was before it is told then, so nothing that went wrong meanwhile
  stays unseen; what went wrong and was put right within the pause is not mentioned. The
  changes are in the activity log all the same. An alert already on its way when the pause
  begins is sent as it would have been ([How they are delivered](https://qkvm.com/docs/alerts#how-they-are-delivered)).
- **Quiet hours** of a destination recur, every day or on the days ticked, by this wall's
  clock (a container's is often UTC: set `TZ`). A window past midnight belongs to the day it
  starts on. Nothing new is sent there meanwhile; when they end, what is not as it was when
  they began is told, as after a pause, and as a pause they stop nothing that was already on its
  way. (A restart within them forgets what they held. A screen watch that goes off within them
  is not told there, nor then its end; one told there before them that is over within them is
  told over when they end, and after a pause, where the screen is still back then.)
- **Reminders** (off by default): every 30 minutes up to once a day, a destination is told
  again of a machine that is still offline, without a picture or with a problem ("Still: ...",
  and for how long). Not while alerts are paused, nor within its quiet hours.
- While alerts are on, qKVM keeps watching after everyone has signed out, and after a restart
  (see below). What each machine was last seen as is written down, so a machine that does not
  come back when qKVM does (after a power cut, most of all) is told about: two minutes after
  the start, which is the time qKVM gives its own network to come up before it believes
  that anything is gone.
- A JetKVM that is not on screen is only checked for answering, because looking at its
  picture would take its one viewer slot.
- For a [server](https://qkvm.com/docs/servers), "lost its picture" means it was switched off, and a critical
  fault reported by its controller is told as one. So it does for a KVM whose power board
  says the computer is off: the alert says it is off or asleep (its power light is out, which
  rules out a cable that came loose). Without a board, or with one that says the computer is on
  (its screen asleep), it says the picture is gone.
- **After a restart qKVM goes on alerting by itself**, as it goes on watching. Not where it
  is started with `--locked-start`: the destinations are saved encrypted, and so are the
  devices' passwords, and until somebody signs in qKVM can then neither look at a device nor
  tell anybody. `GET /healthz` says `"locked": true` for as long as that lasts (both under
  [Keeping it running](https://qkvm.com/docs/keeping-it-running)).

### How serious each event is

| Event | Severity |
|---|---|
| Offline (the KVM or the server's controller stopped answering) | critical |
| Server critical fault (its controller says so) | critical |
| Certificate changed | error |
| Login rejected | error |
| Other problem (what the tile shows as a problem) | error |
| Backup failed (a backup of the wall was not made: see [Backups](https://qkvm.com/docs/backups)) | error |
| Picture lost (no video signal; a server switched off) | warning |
| Screen unchanged (a watch, below) | warning |
| Back to normal | info |

*From* "Critical only" tells offline and faults; "Errors and worse" adds the certificate, the
login, other problems and a backup not made; "Warnings and worse" adds the picture and the screen. "Back to
normal" is told exactly where the trouble it ends was told (whatever came between), so an
incident opened is closed; it is written down, so after a restart too. PagerDuty
is sent the severity as it is; ntfy is sent high priority for trouble, default for what is
over. A machine told as offline that answers again without a picture is not told "picture
lost" where it was told as offline (it had none to lose); a destination that was not told it
was offline (it does not hear offline) is told the picture is lost. Its "back to normal" comes
with the picture.

### How they are delivered

- Each destination is sent to by itself, in the order things happened: one that is slow or
  away holds up neither the watching nor another destination.
- **Many changes at once are one message.** A switch that dies takes its machines with it in
  the same look: an email, a chat or ntfy is sent one message listing them (thirty by name,
  then a count). So such a destination waits one look (about fifteen seconds) before the first
  message of a run, for the machines a look behind the others, and is left alone for one look
  more after a message of several. Between two messages to one destination there is a second at the least
  (Discord two, Telegram three), within what each service allows. The JSON webhook and
  PagerDuty are sent each change by itself: a program, or an incident per machine.
- **Tried again** after 5, 30 and 120 seconds where the service was busy (429, and then after
  its own `Retry-After`, ten minutes at the most), broken (5xx) or did not answer in time;
  never where it said no (any other 4xx: a wrong token is not sent again and again). A mail
  server's yes to the end of the message is the delivery: the line lost after it is no
  failure, and the mail is not sent again. One that takes the mail for some of its addresses
  and refuses the others is not tried again either (the others have it): the delivery log
  says it was not delivered, and which addresses were refused, in the server's words, and
  the destination counts as failing (below). A hundred alerts wait for one destination at the
  most; the oldest give way. A machine's
  trouble that was not delivered counts as told there all the same, so that its end goes there
  too: one given up on after all its tries, one refused at its one try, one that gave way when
  a hundred waited (no try at all), and one whose destination could not be sent to (the saved
  passwords locked, its settings that do not open).
- **Switched off, what waits is dropped.** Before each try, and once more right before it goes
  (after its turn and its name's lookup), what waits for a destination is held to its switches:
  the destination on, and alerts on (the daily seal of the activity log: the destination on),
  and neither switched off at any moment since it was handed over, even where it is on again
  by its next try; once a message of it went, the rest of it goes (PagerDuty is sent a change
  between two kinds of trouble as two events). Switched off, it is dropped: not sent, then or later. Its line in
  the delivery log says "Not sent" and why (`withheld`), and the destination is not counted as
  failing. A machine's trouble dropped so, a screen watch's too, is as if it never went there:
  that destination is not reminded of it, nor told that the machine is back to normal (an end
  or a reminder of it that waits behind it is dropped too), and the machine's next trouble is
  told there as any other. So it stays over a restart, but for the end of a screen watch that
  went off before it ([Watching a screen](https://qkvm.com/docs/alerts#watching-a-screen)). That backups are made again is
  the one thing owed after it: where a failure was told, until it is delivered there (over a
  restart too), and told once alerts are on again; a destination switched off is owed nothing.
- **A pause or quiet hours stop new alerts only.** They are judged when an alert is routed. An
  alert already handed to a destination when they begin (waiting to be tried again, or being
  gathered with others for one message) is delivered as it would have been, or given up on as
  any other. Its tries stay bounded: four at the most, after 5, 30 and 120 seconds, each given
  fifteen seconds where the service does not answer (each of PagerDuty's two events of one
  change as much), so the last ends some three and a half minutes after its own first began
  (some four and a half for PagerDuty's two); a wait is longer only where the service itself
  asked to be left alone, ten minutes at the most each time. Alerts that wait for one
  destination go in turn (the JSON webhook and PagerDuty are sent one alert at a time), so
  while its service is away each one's first try comes after the tries of those before it.
  What changes while they are on is held and told when they end, as above. A test (*Test*)
  goes whatever the switches say.
- **Across a restart** (a known limit): an alert still waiting to be tried again when qKVM
  stops is not sent after it starts, though the wall counts it as told there, so a machine still
  down then is not told again. The one exception is that backups are made again, which stays
  owed until it is delivered.
- **A destination that fails** is written to the activity log when it begins to fail, with
  its service's words, and once more when it is delivered to again: not a line for every
  alert. The list shows its last error until then.

### What leaves the wall, and what never does

- An alert carries the machine's name, what happened and when, the machine's address (as
  the tile shows it), the text the tile shows for a problem, and the link. **Never** a
  password, a token, a picture, or anything of the wall but the link you gave. *Minimal
  content* on a destination leaves out the address and the text: the machine's name, what
  happened and the link.
- The words are fixed, with fixed places for the name, the event and the link: there are no
  templates, and nothing a name or a device sends can run. A machine named `<!channel>` does
  not call a Slack channel together, Discord is told to mention nobody, and a name with a line
  break in it cannot add a header to a mail.
- **Where qKVM may send.** Before every send the name is looked up, and every address it
  leads to is checked; the connection then goes to the address that was checked, with the
  name where the service looks for it (and its certificate checked for that name). No
  redirect is followed, no proxy is used, and no more of an answer is read than says how it
  went. Never sent to, whatever is ticked: the wall itself (the port qKVM listens on, at any
  of its addresses and on this computer's loopback), link-local addresses (169.254.0.0/16,
  where clouds keep their metadata service, and fe80::/10), the metadata services that sit in
  private ranges (`fd00:ec2::254`, `100.100.100.200`), the unspecified address, multicast and
  ranges kept for other uses; nor any of those written inside an IPv6 address (IPv4-mapped,
  NAT64, 6to4); nor an IPv6 address that names an interface of this computer (a zone, `%1` or
  `%25eth0` after it), which is refused where it is typed as well. The computer's own
  addresses are judged as `127.0.0.1` is, whatever the wall listens on: on Linux each interface's (its first IPv4 address, and every IPv6 one), on
  Windows every address the computer's name leads to, and everywhere the addresses of its
  routes out. Not known as its own: a second IPv4 address on a Linux interface, the interfaces
  of a Mac beyond those, and the host's addresses seen from a container. This computer
  (`127.0.0.1`, `localhost`, `::1`) and your own network's addresses (10.x, 172.16 to 31.x,
  192.168.x, fc00::/7, and 100.64.0.0/10, where Tailscale's are) only where the destination's
  *May be a private address* is ticked, which is off for a new one. The same holds for a mail
  server. So a self-hosted ntfy on the network, over a tailnet, or on the same computer as
  qKVM (at another port than qKVM's) needs that tick.
- A webhook's JSON, as 0.3.2 sent it, with three fields more:
  `{"app": "QKVM", "event": "offline", "device": "Build server", "address": "192.168.1.20",
  "state": "offline", "previous": "online", "title": "...", "message": "...", "link": "...",
  "time": "2026-11-16T09:00:00Z", "id": "msg_...", "what": "offline", "severity": "critical"}`.
  `event` is `offline`, `no_signal`, `problem`, `unchanged`, `recovered` or `test`; `what`
  is the event as above (`offline`, `no_signal`, `unchanged`, `auth`, `certificate`, `fault`,
  `problem`, `recovered`, `test`).
- **The signature** (Standard Webhooks): each request has `webhook-id`, `webhook-timestamp`
  (Unix seconds) and `webhook-signature`: `v1,` and the base64 of HMAC-SHA256, keyed with the
  secret after `whsec_` (base64), over `webhook-id.webhook-timestamp.body`. The secret is
  shown once, when the webhook is added; *Make a new one*, under *Signing secret* in its
  *Edit* box, makes another, and the old one stops working. The libraries of standardwebhooks.com check it; a receiver should also
  refuse a timestamp more than five minutes off. *Send without a signature* is for a
  receiver that cannot check one.

### From 0.3.2

A wall of 0.3.2 had one address. It is its first destination after the update, of the kind
its *Service* said ("Work it out from the address" still does), with *May be a private
address* ticked, since every address could be one then: an address on `127.0.0.1` or
`localhost` (a relay or an ntfy on the same computer) keeps working. Two things are new for
it: link-local addresses and the wall itself (qKVM's own port) are refused, and a JSON webhook
carried over is sent unsigned until *Make a new one* in its *Edit* box makes it a secret.

**Alerts go through no proxy any more.** 0.3.2 posted them through the proxy the environment
named (`HTTPS_PROXY`, `HTTP_PROXY`); 0.4.0 connects to the address it has checked, directly, so
that a proxy cannot be made to carry an alert somewhere the rules above refuse. A wall that
reaches the internet only through a proxy stops alerting after the update (the activity log
and the list say why). Behind such a proxy, let the firewall pass the wall's connections to
the services it alerts (HTTPS on 443 to their hosts, the mail server on 587 or 465), or send
the alerts to a service on your own network (an ntfy or a mail relay of your own, with *May be
a private address* ticked), which passes them on.

Until the first destination is changed in 0.4.0, its address is also kept where 0.3.2 reads it:
a wall that goes back to 0.3.2 (an update that did not start, `qkvm --roll-back`) finds it there
and goes on alerting. `GET` and `PUT
/api/v1/alerts` and `POST /api/v1/alerts/test` keep their fields and their meaning: they
speak of the first destination (`webhook`, `format`, `forget_webhook`, `has_webhook`,
`last_sent`, `last_error`; `private` is new). The rest is under
`/api/v1/alerts/destinations` (see [The API](https://qkvm.com/docs/the-api)).

### Watching a screen

A machine whose tile shows a screen has two watches on its *Edit*, each in minutes (empty is
off, a day the most). Each is told through the alerts, with the picture that set it off kept
on the wall, and again when it is over ("back to normal"), where it was told.

- **No signal for N minutes:** the KVM's own signal flag has said "no signal" for that long,
  as the alert round sees it (every fifteen seconds, settled over two looks). The computer
  sends no picture: it is off, asleep, its screen switched off, or its cable out. A machine
  with this watch has no "no video signal" alert at the half minute; it is told after its
  minutes, and "a picture again" only where that was told (and not dropped by a switch: see
  [How they are delivered](https://qkvm.com/docs/alerts#how-they-are-delivered)). Where that was told is kept in memory:
  after a restart, the end of a watch that went off before it is told wherever "back to normal"
  is heard. A KVM that stops answering ends the run; what was told stands until a picture comes.
- **Screen unchanged for N minutes:** every picture the wall had of the machine in that time
  looked the same. These are the pictures the wall gets anyway, while the tile is on a screen
  somewhere (a wall screen, a browser): no session is opened for it and nothing is asked of
  the device, so with nobody looking nothing is compared and nothing is said. Each picture is
  shrunk to 64 by 36 squares, each the average brightness of its part of the screen, and
  counts as another where two squares differ by more than 10 of 255 from the first picture of
  the run: the noise of a capture and of JPEG does not count, a pointer that moves, a clock
  that ticks or a line of text does. Eleven minutes without a new picture, or the KVM's own
  "no signal" picture, starts the run again.
- **What they do not mean.** "Unchanged" is not "hung": a screen nobody uses looks the same
  too (a login screen, a console at its prompt), and a hung computer whose cursor blinks or
  whose clock ticks has a screen that changes. "No signal" is not "off": a screen that sleeps
  sends nothing either. Neither tells a crash screen from another, and no text is read.
- **What they cost:** nothing for a machine without them. With "unchanged", at most one
  picture every fifteen seconds is compared, where a new one came: decoded in the video worker
  (the process of its own, without the saved passwords, that every picture a device sends is
  decoded in; one while any machine has the watch) and shrunk in a thread, about 10 ms of one
  core for a tile's picture and 25 ms for one of 1920 by 1080. A PNG is not compared.
- **The picture kept** is the last one of each machine (the next alert's takes its place), in
  `alert-pictures` in the data folder, the owner's alone, for 30 days, and it goes with the
  machine when that leaves the wall. For "no signal" it is the last picture with a signal the
  wall had, and none where nobody looked at the machine. The alert's line in the activity log
  has *Picture*, for an admin (in *Settings > Activity*, and under *Done to it* beside the
  machine's history; for a program, `GET /api/v1/devices/{id}/alert-picture/{stamp}` in
  [The API](https://qkvm.com/docs/the-api)). It is never sent with an alert.
- As every alert: nothing goes off while alerts are paused (what is so when the pause ends is
  told then; one already on its way when it begins is sent), nor for a machine whose alerts are
  off. A watch is told whatever kinds are
  ticked in *Settings > Alerts*, since it was asked for on the machine itself; its "back to
  normal" only where *It is over* is ticked; and each destination as it asked (*Screen
  unchanged*, *Picture lost*, *Back to normal*). A webhook's JSON has `event`
  `unchanged` for a screen that looked the same, `no_signal` for no signal and `recovered`
  for either being over. Which watches stand is written down (`screens.json`), so that the
  "back to normal" comes after a restart too. The minutes go into an export with the machine.

### On a phone

*Settings > Alerts > This browser* has the alerts told to the browser it is pressed in, by Web
Push: on a phone, a notification, and a tap on it opens the wall at the tile it is about. Any
account may do so for its own browsers, and is told about the machines it may see; the list
under it shows the account's browsers, and to an admin everybody's, each with when an alert
last reached it, or why not, and *Remove*. A browser told another account's alerts is turned on
for this one once that account or an admin has removed it (an admin may take it over).

- **What it needs.** The wall reached over HTTPS, with a certificate the phone trusts: a name
  of the wall's own with a certificate from a public authority, or from one the phone was given.
  The certificate qKVM makes itself, which a browser warns about, does not do. On an iPhone or
  iPad (iOS 16.4 or later) the wall has to be added to the Home Screen (*Share*, *Add to Home
  Screen*), opened from there, and turned on there. And alerts on (*Watch the KVMs and send
  alerts*): the browsers are told what the destinations are, with or without a destination.
- **Through whom.** A browser is reached through its maker's push service: Apple's for Safari,
  Google's for Chrome and most browsers on Android, Mozilla's for Firefox, Microsoft's for
  Edge. The wall posts each alert there, and the service carries it to the phone without being
  able to read it: it is encrypted for that browser alone (RFC 8291) and signed with the wall's
  own key (RFC 8292), which the wall makes the first time a browser is turned on and keeps
  sealed with the saved passwords. The service sees that an alert went to the browser, when,
  and how long it is (padded). As whose the alerts are, the wall gives `https://qkvm.com`,
  which names nothing of it: never its address.
- **What an alert carries:** the machine's name and what happened, as the webhook says it, and
  which tile it is about. Never a password, a token, a machine's address or a picture.
- **When.** As every alert: not for a machine whose alerts are off, of the kinds ticked; a pause
  stops new ones, and what is not as it was when it ends is told then. What waits for a browser
  (its push service away) is held to the switch before each try and right before it goes:
  alerts switched off, now or at any moment since it was put in, it is dropped; one already on
  its way when a pause begins is sent. A
  suspended account's browsers are told nothing; an account that is removed takes its browsers
  with it. A phone that is off gets, when it is on again, what came within a day.
- **A known limit:** the wall keeps no record of what each browser was told, as it does for a
  destination. Where alerts were switched off while a machine's trouble waited for a browser,
  so that the trouble was dropped, that browser may be told later that the machine is back to
  normal, without the trouble before it.
- **Sending** holds up neither the watching, nor a destination, nor another browser: each
  browser's alerts go in the order they happened, eight sends at a time from the whole wall,
  each given 15 seconds, tried again after 5, 30 and 120 seconds where its push service was
  away, and 20 waiting for one browser at the most (the oldest give way). A browser its push
  service says is no longer subscribed is taken off the list.
- **Where it may send:** only to the address the browser's push service gave it, which has to
  be https on port 443 to a name on the internet; and every address that name leads to has to
  be one of the internet's (not loopback, a private range, link-local, site-local, nor an IPv4
  address of those inside an IPv6 one, nor the local-use NAT64 prefix `64:ff9b:1::/48`), and the connection goes to the
  address that was looked at. A name
  that leads into the wall's own network is not sent to, and its browser says so.
- *Send a test* tries this browser (one test every five seconds for an account). A wall whose
  clock is far out is refused by the push services (its signature runs out by that clock).
