# Alerts and monitoring

> **Field change (2026-10-04):** in application logs the logger name after the level is now the
> field `component`; `message` holds only the text after it. An alert that looked for a
> logger name in `message` no longer matches - TKTail lists such alerts in **Problems** when an
> application log is open or monitored. Change the condition to `component`.

TKTail can watch files for you - while you look at something else, with the window hidden in
the notification area, and also for files you have no tab open for.

## How it fits together

| | |
|---|---|
| **Condition** | what to look for: text or a regular expression, a field condition (`level = ERROR`), or one Performance Counter threshold ([Metrics](https://tktail.dev/help/metrics/), Trial / Pro) - tested on the new, complete lines of the files the alert names, written after the alert exists |
| **Alert** | the saved rule: the condition, a severity (Info, Warning, Error, Critical), how often to notify and which evidence to keep. Every change of its meaning is a new version |
| **Notification** | a Windows notification, the tray icon, a sound or TKTail brought to the front - at most one per second. The status bar and the tray say *2 new alerts · Critical*; nothing interrupts you with a dialog |
| **Incident** | one occurrence of the alert: *New* until you acknowledge it; pin the ones to keep |
| **Evidence** | kept with the incident: the trigger record and the records around it (10 before and 10 after by default; a multi-line record whole), and - when the alert asks for them - the Windows events and the metric samples of that moment. It stays when the log is rotated, truncated or deleted, and after a restart |
| **History** | **Tools > Alert History** lists the alerts that fired, **Tools > Incidents** the incidents |

Not in this version: alerts on sequences, on Windows Event Logs (an event log is evidence only), on
whole folders or on all open files; e-mail, webhook or script actions.

## Creating an alert

1. Select the text you want to be told about in a log (for example `ERROR` or an order id).
2. Choose **Tools > Add Alert...** (Ctrl+Shift+A), or right-click > **Add Alert for
   Selection...**. In the Explorer, right-click a file > **Add Alert...**.
3. In the **Alert** dialog:

*Screenshot: The alert editor: the trigger, the evidence to keep, the behavior and the notification*

| Section | Field | Meaning |
|---|---|---|
| | Name, Severity, Enabled | How the alert is called in notifications and incidents; Info / Warning / Error / Critical; an alert can be kept but switched off |
| Trigger | Text in the file: Watch for | The text to look for (filled with your selection) |
| | Regular expression / Match case | How *Watch for* is matched - the same [regular expressions](https://tktail.dev/help/search/#regular-expressions) as Find |
| | Field condition | Match a parsed field instead of text, e.g. `level = ERROR`, `sc-status >= 500`, `OrdStatus = Rejected` |
| | A performance counter | A Windows Performance Counter (**Choose...** opens the [counter picker](https://tktail.dev/help/metrics/)) over or under a threshold (`90`, `90 %`, `4 GiB`), for a number of seconds without a break (0: one sample decides) - needs the Metrics feature of your license |
| Evidence to keep | Records of the file | The logical records kept before and after the record that matched (a multi-line entry counts once) |
| | Windows events | A log (`System`, `Application`, a channel such as `Microsoft-Windows-PowerShell/Operational`, or a saved `.evtx`), its levels, minutes before and after the trigger |
| | Metrics | A Metric Set (Host Basics, ...), minutes before and after the trigger - an enabled alert keeps them collected, so their history exists when it fires |
| Behavior | Notify | *Every match*; *First match only (until re-armed)*; *At most once per interval*; *First match, then a summary per interval* |
| | Interval (s) | For the interval modes |
| | Fires again within | Matches this many seconds after the last one join the same incident instead of starting a new one (0: never) |
| Notification | Actions | Windows notification, tray icon attention, sound, bring TKTail to front |
| | Show matching text in notifications | Off: notifications then name the alert and file but not the log line (privacy) |

The line under *Evidence to keep* says what the alert will keep, in words. The pattern is checked
when you press OK; an invalid regular expression is reported and the dialog stays open. A line
that makes a pattern hit its complexity limit is skipped for that alert - the other alerts and
lines go on.

Only **new** lines are checked - lines written after the alert exists. A text alert applies to
the file it was created for (for a dated file that TKTail follows: its series); a counter alert fires
once when its condition becomes true and again only after it was false in between (a sample that could
not be read never counts either way).

## Managing alerts

**Tools > Manage Alerts...** lists your alerts with their condition, what each keeps and whether
it is evaluated - *Yes - u_ex261106.log (no tab)* names the file it reads now; *Waiting - ...* says that
its file is not there yet (TKTail opens it when it is); *No - ...* why not (a disabled alert, a condition
TKTail cannot watch live, a missing license feature). Check or uncheck an alert to enable or disable it; **Edit...** opens the Alert
dialog, **Delete...** removes it (its incidents stay), **Incidents** shows its incidents, **New
Metric Alert...** adds a counter alert. An alert created from a search (several conditions) keeps
its condition as it is; its evidence and behavior can be edited. Every saved change of what an
alert means is a new version - an incident names the version that fired.

## When an alert fires

Depending on the alert's actions you get a Windows notification (click it to jump to the
line in TKTail), the TKTail icon in the notification area changes to the alert icon, a sound
plays, or TKTail comes to the front. The notification's title names the alert's severity
("TKTail — Critical: CPU busy"). The status bar shows the number of unread alerts and the highest
severity among the new incidents (*2 new alerts · Critical*; its tooltip has the count of each
severity); the tray icon's tooltip says the same. Nothing opens or takes the focus because an alert
is Critical.

Every alert is written to the **alert history** (`alerts.jsonl` next to the settings, see
[Getting started](https://tktail.dev/help/getting-started/#where-tktail-keeps-its-data)), including the file,
position and a short preview (subject to the privacy option above). The size of the history
is limited by settings. Rotations of monitored files are recorded there too.

An alert made on a file whose name carries the date (`app_2026-10-14.log`) watches the whole
series: when `app_2026-10-15.log` is LIVE, the alert watches it, and its incidents name the file the
line was really written to - also with no tab open and after a restart
([Rotating dated log files](https://tktail.dev/help/rotating-dated-logs/#alerts-incidents-and-monitoring)).

Browse the history in the **Alerts** view of the bottom panel (**Tools > Alert History**, see
[Bottom panel](https://tktail.dev/help/bottom-panel/#alerts)): filter by rule or file, show unread only, open an
alert at its exact position in the right file, mark alerts read. **F8** / **Shift+F8** go to
the next / previous alert in the current file. `tktail alerts history` *(planned)*.

### Incidents

An alert that fires also keeps an **incident**: the record that matched and, by default, the
**10 records before and the 10 after it** in the same file - read when the alert fires and kept as
they were, so they are still there after the log was rotated, truncated or deleted. A record that
grows after the line that matched (a stack trace) is kept whole. Alerts that fire again and again
within a minute are one incident: its match count grows instead of a new copy of the evidence
being kept for each.

*Screenshot: An alert fired: its incident in the Incidents view, Critical, the status bar says so*

Investigate them in the **Incidents** view of the bottom panel (**Tools > Incidents**, see
[Bottom panel](https://tktail.dev/help/bottom-panel/#incidents)): what fired, each piece of evidence with its state -
*Complete*, or *Partial* / *Unavailable* with the reason (the file had fewer records, a counter
was collected for less time than asked, an event log no longer holds the start of the window, a
log does not exist) - and a preview of what was kept.
Acknowledging an incident marks its alert read, and marking alerts read acknowledges their
incidents. **Export** writes an incident as a folder (a README, the kept records as a `.log`,
events and samples as text and CSV, and the machine-readable files) to attach to a ticket.

Incidents are kept in the `Incidents` folder of the data folder (see
[Getting started](https://tktail.dev/help/getting-started/#where-tktail-keeps-its-data)), at most 1,000, 90 days and
512 MB (`alerts.incidentMaxCount`, `alerts.incidentMaxAgeDays`, `alerts.incidentMaxMB` in
settings.ini). They follow the alert history's privacy settings: without a
persistent history (`alerts.persist=0`) no incident is kept, and when the history keeps only the
match or no text (`alerts.preview`) an incident keeps the same and no log records.

Alerts you created with an earlier version moved to the `Alerts` folder the first time this
version started - with the same names, conditions and numbers, and the severity **Warning**
(change it in the alert editor); `settings.ini` keeps the old rules for an earlier version.
An incident keeps the severity its alert had when it fired: making an alert Critical later
does not change the incidents it already has. `tktail alerts list` lists your alerts, their conditions and what each
keeps.

## Monitoring files in the background

An enabled alert keeps its file watched while TKTail runs - with or without a tab, hidden in the
notification area too; for a dated series, its newest file. Disabling or deleting the alert ends that
watch. To keep a file watched for its own sake, with a refresh mode or a format of your choice (and
remembered in the settings):

- Explorer: right-click the file > **Monitor in Background**
  (**Stop Monitoring** reverses it), or
- command line: `tktail monitor add C:\Logs\service.log` (`monitor remove`, `monitor list`).

Closing a tab of a monitored file keeps the file monitored in the background.

A background file is watched the same way as an open one, with the same
[refresh mode](https://tktail.dev/help/large-and-network-files/#files-on-network-shares): an alert on a local file fires as the
line is written; on a network share in Auto, within about a second while the file is being
written and up to ~30 s after a long quiet spell; with Poll, within the chosen interval. To
choose the mode, open the file and change **Monitoring > Refresh** in the Inspector - it is
saved with the background source. A background file on a share that cannot be reached is
checked again with growing pauses (up to a minute) and continues when the share is back.

**Tools > Pause All Monitoring** stops all watching (no alerts) until you resume it; the tray
icon shows the paused state.

An AI assistant can set up and check alerts with you - propose the condition, check it with TKTail, save it only with
**Allow AI to manage alerts** and your yes, then report whether it is running and which file it reads
([Alerts with an assistant](https://tktail.dev/help/ai-assistance/#alerts-with-an-assistant)).

## The notification area (tray)

Alerts run only while TKTail runs. The **Hide to Notification Area** button in the title bar, right before
minimize (the arrow dropping into a tray; also **File > Hide to Notification Area**) takes the window off the desktop
with one click: monitoring, LIVE
tabs and alerts go on, nothing is reloaded, and the icon in the notification area brings the window back. The
icon shows unread alerts and its menu lists them - see
[The notification area](https://tktail.dev/help/windows-integration/#the-notification-area-tray). Exiting while alerts are enabled asks
first - *Closing TKTail stops 4 active alerts*: **Keep Running in the Notification Area** (the default),
**Close and Stop Alerts**, or **Cancel** ([Closing the window](https://tktail.dev/help/getting-started/#closing-the-window)). To start
TKTail there when you sign in: **Settings > Startup** ([Starting with Windows](https://tktail.dev/help/windows-integration/#starting-with-windows)).
Retention of the alert history and incidents: **Settings > Alerts & Incidents** ([Settings](https://tktail.dev/help/settings/#alerts--incidents)).

## What survives a restart?

| | After a restart |
|---|---|
| Your alerts | Kept - the same alerts, enabled or disabled as you left them, with their conditions, evidence and versions. Alerts made by earlier versions of TKTail (1.0.0 - 1.1.0) are read as they are and behave as before |
| Watching | Enabled alerts start watching again by themselves - a dated series on its newest file, also one that appeared while TKTail was not running |
| What was already read | Not read again: a file is watched from its end when TKTail opens it, so nothing fires twice because of a restart. Lines written while TKTail was not running are not checked |
| Incidents and the alert history | Kept, with their evidence, acknowledgements and pins, and the TKTail run that captured them |
| The workspace | Restored: tabs, splits, the active tab, positions, LIVE / PAUSED, Event Log and Metrics views, dated series ([Viewing logs](https://tktail.dev/help/viewing-logs/#when-tktail-starts-again)) |
| Settings, monitored files, Saved Searches, Metric Sets, formats | Kept |
| Evidence packages, pinned searches | Kept: packages until you delete them; up to 20 pinned searches with their results ([Saving evidence](https://tktail.dev/help/saving-evidence/)) |
| Running searches, exports and index jobs, terminal sessions, linked windows | Not resumed: they end with TKTail - run a search again (or pin it first), start a terminal again |

---

The HTML page: https://tktail.dev/help/alerts-and-monitoring/
