# Alerts

Alerts watch a source for a [query](https://tailcove.dev/docs/query-language) crossing a
threshold within a time window, and notify you when it does, and again
when it drops back down.

## How evaluation works

Each active alert is checked once a minute. On every check, Tailcove counts
how many log lines on the alert's source matched its query within the last
`window_minutes` minutes, and compares that count to `threshold_count`:

- **Count ≥ threshold, and the alert wasn't already triggered:** the alert
  fires: a trigger is recorded and notifications go out on every
  configured channel. If the alert is already triggered (from a previous
  tick), nothing happens; you're notified once per trigger, not every
  minute it stays above threshold.
- **Count < threshold, and the alert has an open trigger:** the alert
  resolves: the trigger is marked resolved and a resolution notification
  goes out.
- **Cooldown:** after a trigger fires, the alert won't fire again until
  `cooldown_minutes` have passed since that trigger, even if it resolves
  and immediately crosses the threshold again in the meantime. This
  prevents a flapping condition from spamming notifications.

### When alerts flap or pile up

Two more limits keep a bad hour from burying you in messages. Both count by the clock hour (UTC).

- **A flapping alert tells you at most three times an hour.** If it fires again after that, the firing is still
  recorded and shows on the alert's page, but nobody is notified and no incident is opened, so the on-call person isn't
  paged again for the same flapping alert. The next hour starts afresh. Monitors work the same way.
- **Each channel gets at most so many alert messages an hour from your team**, across every alert, monitor, issue
  regression and deploy check: 20 emails, 6 texts, 10 GitHub issues and 30 messages to each of Slack, Discord, Teams,
  Telegram and your webhook. When a channel reaches its limit it gets one message saying "Too many alerts" and when
  messages start again, and the rest of that hour's alerts are held there. A held webhook delivery is announced with a
  `notifications.held` event.

A "resolved" or "back up" message never counts toward the limit. It always follows an alert you were told about, and
it's held when the alert it answers was held, so you're never left thinking something is still broken, or told a
problem is over when you never heard it started. PagerDuty and Opsgenie are never held: they group alerts themselves,
and holding a page there could hide an outage from whoever is on call. Escalation pages from an
[on-call policy](https://tailcove.dev/docs/on-call) aren't held either.

## Recommended alerts

A new source's Overview offers the alerts most apps need, already filled in. Tick the ones you want and choose
**Turn on**; each becomes an ordinary alert you can change on the Alerts tab.

| Alert | Fires when | Offered for |
| ----- | ---------- | ----------- |
| Error spike | more than 20 error, critical, alert or emergency lines in 5 minutes | every source |
| Any critical line | a critical, alert or emergency line arrives | every source |
| Stopped sending logs | no line at all for 15 minutes (the [source heartbeat](#no-data-alerts)) | every source |
| Failed queue jobs | 5 or more `Queued job failed` lines in 15 minutes | Laravel |
| Failed scheduled task | a `Scheduled task failed` line | Laravel |
| Server errors | 10 or more lines with `statusCode>=500` in 5 minutes | sources fed by an HTTP drain |

They email the team's members who turned email alerts on; add Slack, PagerDuty or a webhook on each afterwards. An
alert you already have with the same query counts as on, so nothing is offered twice. They count toward your plan's
alert limit, and turning several on is all or none. **Not now** hides the card in your browser.

## Creating an alert

From a source's **Alerts** tab, create an alert with:

| Field     | Description                                                                                                              |
| --------- | ------------------------------------------------------------------------------------------------------------------------ |
| Name      | A label shown in notifications.                                                                                          |
| Query     | Optional. The same [query language](https://tailcove.dev/docs/query-language) used in search. Leave blank to match every line on the source. |
| Threshold | Minimum matching line count to trigger, ≥ 1.                                                                             |
| Window    | How far back to count matches, in minutes (1–1440, i.e. up to 24 hours).                                                 |
| Cooldown  | Minimum minutes between triggers (5–1440).                                                                               |
| Channels  | At least one of the channels below.                                                                                      |

A common pattern: `level:error`, threshold `10`, window `5`: fires if a
source logs 10 or more error-level lines within any 5-minute window.

**Templates.** A new alert can start from a template (error spike, server errors, exceptions, slow requests, failed
logins, no logs for 15 minutes). Each fills the form, and everything stays editable.

**Backtest.** On the **When it fires** step, a log alert is replayed over the source's last 7 days as you set the
threshold, window and cooldown: how many times it would have fired, marked on a chart of the week. It also suggests a
threshold just above the usual busy window (the 99th percentile of the week's windows plus a fifth); **Use** puts it in
the form. The replay uses fixed windows where the alert slides, so its count is an estimate.

**Channels.** On the **Who to tell** step, add where it goes with the **+ Email**, **+ SMS**, **+ Slack**, **+ Teams**…
buttons; each one you add opens its settings, and **×** removes it. A source's default channels (below) are already
added. **Email** and **SMS** need no addresses: they reach the team's members who switched them on (below).

On the same step, switch on **Open an incident** to open an [incident](https://tailcove.dev/docs/incidents) when the
alert fires and page through an [escalation policy](https://tailcove.dev/docs/on-call). Your plan
limits the number of alerts across all of a team's sources: 5 on Free, 20 on
Pro and 30 on Business, where each one more is $1 a month (see
[Billing & Quotas](https://tailcove.dev/docs/billing-quotas#add-ons)).

## An alert's page

Click an alert on a source's **Alerts** tab or on the team-wide **Alerts** page to open it. It shows:

- **Where it stands:** **Firing** (the condition is met now, and for how long), **OK** (watching) or **Off** (switched
  off, never checked). The lists use the same three words.
- **How often it fires:** firings in the last 7 and 30 days, how long a firing usually lasts, and the quiet time after
  each one.
- **History:** every firing of the last 90 days, newest first: when it fired, when it resolved, how many lines
  matched, and for each message (fired and resolved) where it was delivered, or that it is being retried or gave up,
  with the error. **See the logs** opens the Logs tab on the alert's query for that firing's time.

**Edit** and the on/off switch are on the page too; a Viewer sees it read-only.

## Metric alerts

Choose **A metric** to alert on a [metric](https://tailcove.dev/docs/metrics/overview)
instead of log lines:

| Field      | Description                                                                                       |
| ---------- | ------------------------------------------------------------------------------------------------- |
| Metric     | The metric name, for example `cpu.usage`.                                                         |
| Host       | Optional. Leave blank to watch every host: the alert fires when any one series crosses the value. |
| Aggregate  | `avg`, `max`, `min`, `sum` or `last`, taken over the window.                                      |
| Fires when | Above or below the value.                                                                         |
| Value      | The number to compare with.                                                                       |

Window, cooldown and channels work as for log alerts. The aggregate is
computed per series (host and labels) over the window; with several series
the highest is judged for "above" and the lowest for "below". If the window
has no points the alert counts as quiet, so an open alert resolves. To be told
when a metric stops altogether, use a no-data alert (below); a host or service
that stops sending is also a job for a [heartbeat monitor](https://tailcove.dev/docs/monitors), or, for a
server running the Tailcove agent, for a no-data alert on its own
[heartbeat](https://tailcove.dev/docs/sending-logs/agent#heartbeat), `system.agent.up`.

## No-data alerts

**Source heartbeat.** The quickest no-data alert is on a source's **Overview**: **Source heartbeat**, pick how long
it may stay quiet (5 minutes to a day) and **Turn on**. It is a no-data alert on every line of the source, emailing
the team's members who have email alerts on, with an hour between reminders; **Who is told** opens it to add channels. **Pause** switches it off, and it
counts toward your plan's alerts like any other.

Switch on **Fire when nothing arrives** on a log or metric alert to be told about
silence instead of a threshold.

- **Log alert:** fires when no line matching the query arrives for a whole
  window. With an empty query that means the source is silent.
- **Metric alert:** fires when the metric (and host, if you picked one) reports
  no point for a whole window, but only if it reported in the window before, so
  a name that was never sent is not an outage. The Tailcove agent beats on
  `system.agent.up` every 30 seconds, so this on that metric and a host is "tell
  me when this server's agent stops" (the source's Overview has a button that
  fills it in). The alert stays open while the
  silence lasts and resolves when points come back.

It is off by default, and it stays quiet when silence would mean nothing yet: a
source that has never received a line, and an alert that was created, edited or
switched back on less than one window ago. Choose a window longer than the
longest normal gap between lines or points, or it fires on every quiet spell.

## Anomaly alerts

Choose **Log lines far above the usual** to be told about a spike without
picking a threshold. Each check counts the lines matching the query in the
window and compares it with the same window on each of the last 7 days (the
average of the seven). It fires when the count is at least **Times the usual**
(1.5 to 100) that average, and at least **At least (lines)**, so a quiet source
does not alert on 3 lines against 1.

It needs 7 days to compare with, so it can only be set on a source that keeps
logs for at least 7 days (Pro and Business retention), and it stays quiet until
the source is 7 days old. If the average is zero, any count at or above the
minimum fires. It resolves when the count returns to its usual range.

## Notification channels

An alert can notify through any combination of:

- **Email**: every member of the team who has **Email alerts** on in their profile.
- **SMS**: every member who has **SMS alerts** on and a verified phone (Pro and Business). Each text counts toward
  the team's monthly SMS.
- **Slack**: an incoming webhook URL for a Slack channel.
- **Discord**: an incoming webhook URL for a Discord channel.
- **Generic webhook**: a URL of your own, signed so you can verify it
  actually came from Tailcove (see below).
- **GitHub issue**: opens an issue in a repository when the alert triggers (pick the repository once [GitHub is connected](https://tailcove.dev/docs/notifications/github), or give a token)
  or a monitor goes down. Give it `owner/repository` and a fine-grained token
  limited to that repository with Issues: write. The token is stored encrypted
  and never shown again; leave the field blank when editing to keep it.
- **[Microsoft Teams](https://tailcove.dev/docs/notifications/teams)**: a Workflows or connector
  webhook, posted as an Adaptive Card.
- **[Telegram](https://tailcove.dev/docs/notifications/telegram)**: a bot message to a chat.
- **[PagerDuty](https://tailcove.dev/docs/notifications/pagerduty)**: triggers an incident and
  resolves it with the alert.
- **[Opsgenie](https://tailcove.dev/docs/notifications/opsgenie)**: creates an alert and closes it
  with the Tailcove alert.

Monitors use the same channels. Only the channels you configure receive notifications. An alert with just
a Slack webhook set won't also try to send mail.

**The lines that fired it.** When a log alert fires, its Slack, Teams and Discord messages show up to five of the newest
lines that matched its query in its window, with their time and level, so you can see the error without opening
Tailcove. They are shown as code, so nothing in a log line can mention anyone or become a link, and each line is
cut to 200 characters. Metric and no-data alerts have no lines to show. If the lines cannot be read at that
moment, the alert still goes out without them.

### Who gets Email and SMS

Nobody types an address or a number into an alert. Each person decides for themselves under **Settings → Profile →
Notifications**, and the switches apply in every team they belong to:

- **Email alerts** (on by default) send to the address they sign in with, once it is verified.
- **SMS alerts** (off by default) send to their phone, added and verified with a code on the same page. Texts go only
  to numbers in a country on the team's plan, and only where we can text yet (see
  [paging by phone](https://tailcove.dev/docs/on-call#paging-by-phone)); elsewhere incident pages call instead.

The Email and SMS cards on the form say how many members they reach right now. A person who leaves the team stops
getting its alerts at once. Incident pages from an [escalation policy](https://tailcove.dev/docs/on-call) reach the people on call
whatever their switches.

### Default channels for a source

On a source's **Alerts** tab, **Notify by default** sets the channels every new alert on that source starts
with, so you pick them once instead of on each alert. **Apply to all alerts** copies them onto the source's
existing alerts, replacing their channels; each alert can still be changed on its own afterwards. Keys and
tokens are stored encrypted like an alert's and never shown again. Anyone who may create alerts on the
source can set them; a Viewer cannot.

## Webhook payload and signature verification

Every webhook request is a `POST` with a JSON body and a signature header:

```
X-Tailcove-Signature: <hex-encoded HMAC-SHA256 of the raw request body>
```

The signature is computed as `hash_hmac('sha256', $rawBody,
$yourTeamsWebhookSecret)`. To verify a request on your end, recompute the
same HMAC over the **raw, unparsed** request body using your team's
webhook signing secret, and compare it to the header using a
constant-time comparison (e.g. PHP's `hash_equals()`, not `==`) to avoid
timing attacks:

```php
$signature = hash_hmac('sha256', $request->getContent(), $webhookSecret);

if (! hash_equals($signature, $request->header('X-Tailcove-Signature'))) {
    abort(401);
}
```

Each team has its own webhook signing secret, generated automatically when
the team is created; it's the same secret for every webhook-channel alert
on that team.

### `alert.triggered` payload

```json
{
    "event": "alert.triggered",
    "alert": {
        "id": "alr_01jbx5qb8d2f4h6j8k0m2n4p6q",
        "name": "High error rate"
    },
    "source": {
        "id": "src_01jbx5q8k7m3n2p4r6s8t0v1w3",
        "name": "api-production"
    },
    "type": "log",
    "matched_count": 14,
    "threshold_count": 10,
    "metric": null,
    "window_minutes": 5,
    "condition": "threshold",
    "anomaly": null,
    "fired_at": "2026-07-03T14:22:01.000000Z"
}
```

For a metric alert `type` is `"metric"`, `matched_count` is 0 and `metric`
holds `name`, `host`, `aggregate`, `operator` (`gt` or `lt`), `threshold` and
the `value` that breached it. `condition` is `threshold`, `no_data` or
`anomaly`; for an anomaly alert `anomaly` holds the `multiple` and the
`usual_count` it was compared with.

### `alert.resolved` payload

```json
{
    "event": "alert.resolved",
    "alert": {
        "id": "alr_01jbx5qb8d2f4h6j8k0m2n4p6q",
        "name": "High error rate"
    },
    "source": {
        "id": "src_01jbx5q8k7m3n2p4r6s8t0v1w3",
        "name": "api-production"
    },
    "type": "log",
    "matched_count": 3,
    "resolved_at": "2026-07-03T14:41:00.000000Z"
}
```

### `notifications.held` payload

Sent once when your webhook reaches its hourly limit (see [When alerts flap or pile up](#when-alerts-flap-or-pile-up)).
Deliveries resume at `held_until`.

```json
{
    "event": "notifications.held",
    "team": {
        "id": "team_01jbx5q2c4e6g8j0k2m4p6r8t0",
        "name": "Acme"
    },
    "limit_per_hour": 30,
    "held_until": "2026-07-03T15:00:00Z"
}
```

## Live view

Alert triggers and resolutions also appear live in the app: the team's
dashboard shows recent alert activity in real time, in addition to
whichever notification channels you've configured.
