# Metrics (Windows Performance Counters)

Logs say what an application reported; **metrics** show what the machine and its processes were
doing at the same time - CPU, memory, disk, network, a process's CPU, memory, threads or handles.
TKTail reads them from **Windows Performance Counters** and shows them beside your logs on the same
clock, so an ERROR at 14:32:07 can be compared with the CPU and memory of 14:32:07 - in the same
window, without a separate monitoring tool. Metrics is made for that local investigation: what
happened on this PC around an incident. It is not a monitoring platform - it keeps no long-term
history and collects nothing from other computers.

- **Nothing is collected until you choose counters.** Browsing the list of counters samples
  nothing.
- History is kept **in memory only** - the last 15 minutes by default (5, 15, 30 or 60) - and
  starts when a counter is first collected: there are no metrics for earlier times. Nothing is
  written to disk.
- Metrics need a **Trial, Pro or Developer license**. Without one the commands stay in the menus,
  marked *(Pro)*, and explain this when chosen; the log viewer works as before.

*Screenshot: TKTail with live Host Basics metrics on the left - CPU (total), available memory, committed memory and disk throughput over the last minute - beside the LIVE orders API log on the right, where errors with stack traces appear while the CPU is at 100 %*

## Logs and metrics in one window

A Metrics View is a tab like a log, so the workspace shows both at once: the machine on one side,
the application on the other, both LIVE. Put them side by side the way you split logs:

- open the log, then the metrics (**View > Metrics...** or **Tools > Metrics > Open Metrics: Host
  Basics**) and choose **Layout > Move Tab to New Split > Right** - or drag the Metrics tab to the
  edge of the log's pane ([Tabs and splits](https://tktail.dev/help/viewing-logs/#tabs-and-splits));
- from the command line, a log beside the metrics already open: `tktail open orders-api.log
  --split-right`.

The chart's time axis is this PC's local time: a log written on this PC with local timestamps lines
up with it directly. Splits, tabs and bottom panels work as for logs: a second log, an event log or
the RECORD view below.

**An investigation, step by step:**

1. Open the application log - it follows the file LIVE.
2. Open Metrics beside it (Host Basics, or a set of your own) and keep both LIVE while the problem
   happens.
3. When the log shows errors, look left: was the CPU saturated, memory short, the disk or the
   network busy at that moment?
4. Drag across the interesting part of a chart: the view pauses on that range and every lane shows
   its minimum, average and maximum there.
5. Right-click > **Search Logs and Events in This Range...** - the Advanced Search with that time
   range and your open logs and event logs as sources.
6. Select an ERROR record: the **RECORD** view (**View > Tool Views > Record**) shows its fields;
   from a record, **Show Metrics Around This Time** moves the metrics to its moment (below).
7. Keep what worked: **Save as Metric Set...** for the counters, and an [alert](https://tktail.dev/help/metrics/#metric-alerts)
   that watches a counter or the log for next time.

*Screenshot: TKTail with Host Basics metrics top left, the orders API log top right and the RECORD view below: an ERROR record parsed into time, exception, component, thread and message*

### From a log to metrics

Right-click a record (or an event in an event tab) > **Show Metrics Around This Time** (also
**Tools > Metrics**). TKTail opens a Metrics View beside the log, paused on that record's time with
the cursor on it - or moves a Metrics View already shown beside it. The new view shows the METRICS
panel's counters, or Host Basics when that list is empty. Records need a complete date and time; a
time older than the history kept says so.

*Screenshot: Show Metrics Around This Time: the Metrics View beside the log paused at the record's time, the cursor on it; the METRICS panel below*

### From metrics to logs

Drag a range in a Metrics View (for example a CPU spike), right-click > **Search Logs and Events
in This Range...**: the **Advanced Search** opens in the bottom panel with that time range and the
open files and event logs as sources. Choose what to look for, then **Search**. With only a cursor,
the search covers the 30 seconds before and after it.

Metrics and searches meet by **time**, never by a condition: a search looks for records, not for
counter values - there is no "ERROR and CPU over 90 %". Put the two side by side, or search the
range a chart shows.

## What you can watch

TKTail ships five Metric Sets - saved selections of counters - and you can make your own from any
Windows Performance Counter on the PC. The built-in sets cannot be changed or deleted; **Save As**
makes your own copy.

| Scenario | Metric Set | Counters (as the lanes name them) | Asks for |
|---|---|---|---|
| Host | **Host Basics** | CPU (total), Available memory, Committed memory, Disk throughput | - |
| System | **System Pressure** | CPU (total), Processor queue length, Available memory, Committed memory, Paging, Context switches | - |
| Process | **Process Diagnostics** | CPU (a share of the machine, as Task Manager shows it), private bytes, working set, threads, handles, I/O throughput | a process |
| Disk | **Disk & I/O** | Read throughput, Write throughput, Reads, Writes, Read latency, Write latency, Queue length | a disk (all disks preselected) |
| Network | **Network** | Network throughput, Received, Sent, Packets | a network interface |
| Custom | **your own** | any counters you pick, of any objects | - |

Units follow the counter: a count, percent, bytes, bytes per second, per second or seconds - bytes
shown as KiB, MiB or GiB.

### Host Basics

The quick health check of the PC, one click away (**Tools > Metrics > Open Metrics: Host Basics**):

| Lane | Counter | What it tells you |
|---|---|---|
| CPU (total) | `\Processor Information(_Total)\% Processor Time` | How busy all processors are. A saturated CPU slows every request on the machine |
| Available memory | `\Memory\Available Bytes` | Memory free for new work now. When it runs low, Windows pages and everything slows down |
| Committed memory | `\Memory\% Committed Bytes In Use` | How much of the commit limit (memory plus page file) is promised to processes. Near 100 %, new allocations fail |
| Disk throughput | `\PhysicalDisk(_Total)\Disk Bytes/sec` | Bytes read and written per second, all physical disks together |

### Process metrics

**Process Diagnostics** (**Tools > Metrics > Open Metrics: Process Diagnostics...**) watches one
process: its CPU, private bytes, working set, threads, handles and I/O throughput. It asks which
process (the running ones are listed; type to filter):

- **Follow by name** (the default) keeps the series when the process restarts: a new process of that
  name continues the same lanes, the restart is marked, and the METRICS panel says *restarted
  (another process)*. A rate is never computed across two processes - the first sample of the new
  one is a warm-up. A name that is not running yet is collected when it starts.
- **Pin this process** watches exactly that PID: when it exits, the series ends (*unresolved* in the
  picker - **Choose Process** binds it to a running one).

*Screenshot: Process Diagnostics of the process writing the orders log, followed by name: CPU fitted to its data, private bytes, working set, threads, handles and I/O throughput, each restart of the process marked, beside the log it writes*

CPU of one process is a share of the whole machine: on a PC with many cores even a busy process can
stay at a few percent. **Fit Percent Lanes to Their Data** (right-click the view) scales a percent
lane to its values.

### Network metrics

**Network** asks for the network interface (a disk set asks for the disk the same way) and shows
its traffic in bytes per second - **Network throughput** (received and sent together),
**Received**, **Sent** - and **Packets** per second.

*Screenshot: The Network Metric Set on this PC's active network interface - network throughput, received, sent and packets per second - beside the LIVE orders API log*

## Opening metrics

**View > Metrics...** opens the counter picker (*Metrics - Windows Performance Counters*). The
quickest way is a Metric Set:

1. Choose a set in **Metric Set** at the top - a built-in one or one of yours.
2. **Load** puts its counters into **Selected** (nothing is collected yet). A set that observes a
   process, a disk or a network interface asks which one first.
3. Adjust the selection (and the colors) if you like, then **Open** (or **Add** - see below).

With nothing selected, **Open** applies the chosen set at once. **Host Basics** and **Process
Diagnostics...** at the bottom do the same in one click.

**Picking counters yourself**: an **Object** (*Processor Information*, *Memory*, *Process*, ...),
one or more **Counters** and, where the object has them, **Instances** (Ctrl / Shift for several).
Names appear in this Windows's language, in English or both (**Show names** - see *Counter names*
below); **Find** matches either, whichever is shown - *Private Bytes* finds *Bajty prywatne* on a
Polish Windows.
**Add to Selection** (or double-click a counter or an instance) puts them into **Selected**; with
nothing in Selected, Open takes what the lists show.

**Selected** lists every counter with its **Color** (a swatch: Auto or yours - click it to change
it) and its **State**: *available*, *not running now* (a process
followed by name - collected when it starts), *unresolved* (pinned to a PID that is gone - select
it and use **Choose Process** to bind it to a running process), or *not on this computer* (the
counter, its object or its instance does not exist here - another computer may have it; it stays
in the set and is simply not collected). **Remove** (Delete) and **Clear Selection** change the
selection only, never a saved set.

*Screenshot: The counter picker with names in English: the user's Metric Set Orders Investigation loaded - CPU, memory and disk of the PC, the CPU and private bytes of the process writing the orders log, network received and sent - all available*

**Your own Metric Sets**:

- **Save As...** keeps the selection as a new set with a name and an optional description - for
  example *Orders Investigation*: CPU, available memory and disk throughput of the PC, the CPU and
  private bytes of the service's process, and the network traffic. Next time: View > Metrics...,
  choose it, Open.
- **Save** writes the changed selection and its colors back into the loaded set (a set with unsaved
  changes shows `*` after its name above the selection). A built-in set is never saved over.
- **Manage...**: Revert to Saved (the loaded set's counters and colors again), Rename, Duplicate,
  Delete (with a confirmation), Open Metric Sets Folder.
- Your sets are listed under *My Metric Sets*, below the built-in ones, and kept in
  `metric-sets.json` in TKTail's data folder. They are stored by their English counter names, so
  they work on another computer and in another Windows language (see *Counter names*); a process,
  disk or interface that does not exist there shows as unavailable or unresolved.

The picker can be resized and maximized - the three lists share the extra width, the selection the
extra height - and a name that does not fit shows in full in a tooltip. TKTail remembers its size
and position (on a monitor that still exists).

The counters open in a new **Metrics View** tab named after the set (*Metrics: Host Basics*,
*Metrics: PaymentService*, *Metrics: Orders Investigation*). If a Metrics View is the active
tab, the picker's button says **Add** and adds to it instead. The same entries are in **Tools >
Metrics** (*Open Metrics: Host Basics*, *Open Metrics: Process Diagnostics...*, *Add
Counters...*), and the **SYSTEM** panel has a Metrics button. **Tools > Metrics > Open Metric
Set...** lists the built-in sets and yours and opens one directly.

### Counter names

Windows names its counters in its own language: *Bajty prywatne* on a Polish Windows is *Private
Bytes* on an English one. TKTail shows them the way you choose - **System language** (the default),
**English**, or **System language + English** (*Bajty prywatne [Private Bytes]*, handy when you
follow English documentation). Choose it in the picker (**Show names**), in **Tools > Metrics >
Counter Names**, or from the right-click menu of a Metrics View or the METRICS panel; every open
view follows at once. It changes only the names you see - the counters, their history and your
sets stay as they are.

Hover a series name in a Metrics View, a row of the METRICS panel or an entry in the picker for
both names and the counter path. Labels of the built-in sets (*CPU (total)*, *Available memory*)
are TKTail's own names and stay the same in every form. Process, disk and interface names (the
instances) are names of things, never translated. A provider that has no English names keeps its
own and says so.

To give a series a name of your own - *Qlik Engine RAM* for a process's private bytes -
right-click it > **Series Name...** (in a Metrics View, or on a row of **Selected** in the picker).
The name is saved with the Metric Set, like its color; leave it empty to go back to the counter's
name.

**Your sets on another computer.** A Metric Set keeps the language-neutral identity of every
counter (the English name, and the GUID where Windows has one), never the names of your Windows's
language. Made on a Polish Windows, it opens on an English one with the same counters - shown in
English there; a counter that computer does not have shows as *not on this computer*.

## The Metrics View

Each counter gets a **lane** on one shared time axis: its name and current value, and the minimum,
average, maximum and change of what is visible (or of the selected range). Series of different
units never share a scale. A gap in collection is drawn as a gap, a sample that could not be read is
marked below the line, and **no earlier data** marks the time before collection started.

The header shows **LIVE / PAUSED**, the time window, the cursor or range, and how often the view
collects. The tab names what it shows (*Metrics: Host Basics*, *Metrics: Host Basics +
PaymentService*, *Metrics: 9 counters*) and follows when you add or remove counters.

**Time windows.** The header's buttons choose how much of the past the view shows: **30 s**,
**1 min**, **5 min**, **15 min**, **30 min** or **60 min**. LIVE keeps the newest sample at the right
edge; scroll back in time as far as the history kept (**Keep History** in the METRICS panel: 5, 15,
30 or 60 minutes) - a window longer than what was collected shows *no earlier data* for the rest.
How often counters are read is **Collect Every** 1 (the default), 2, 5, 10 or 30 seconds.

| Action | How |
|---|---|
| Pause / go live | Click **LIVE** in the header, **Space**, **Shift+F5** / **F5**, or **End** (go live). Pausing stops the display only - collection continues |
| Time cursor | Click in a chart; the values at that time are what **Ctrl+C** copies |
| Select a range | Drag in a chart (the view pauses); its statistics show in every lane; **Esc** clears cursor and range |
| Move in time | Mouse wheel (up = older), **Left** / **Right** (Ctrl: further), **Home** (the oldest kept) |
| Time window | The buttons in the header, **Ctrl+wheel**, **+** / **-** |
| Many lanes | **Shift+wheel** or the scroll bar; **Up** / **Down** select a series |

Right-click the view for: *Search Logs and Events in This Range...* (above), *Copy the Values* /
*Copy the Range's Statistics*, *One Lane per Unit* (series of one unit together), *Fit Percent
Lanes to Their Data*, **Series Color** (below), *Hide the Selected Series* / *Show All Series*,
*Remove the Selected Series*, *Add Counters...*, *Collect Every* 1 / 2 / 5 / 10 / 30 s, and the
Metric Set commands (below).

### Series colors

*Screenshot: One lane per unit: total CPU in red and committed memory in teal, colors chosen with Series Color; the tab's * says the view differs from its set*

Every series starts in **Auto**: a color of TKTail's palette, by its place in the view - the same
set opens with the same colors, and series sharing a lane never get the same one. To give a
series a color of its own, right-click its name (or its lane) > **Series Color** and pick one of
the ten preset colors, **Custom...** (the Windows color dialog) or **Auto** to go back; **Reset All
Series to Auto** is at the end of that menu. In the picker, click a row's swatch in **Selected**
(or right-click the row) for the same choices before you open the set.

A color only changes how the series is drawn - the counter, its history and its collection stay as
they are. A chosen color stays yours in both themes; one too close to the background (yellow on
white) gets a thin outline instead of being replaced. Colors tell series apart; states never
depend on them alone (warming up, missing and errors are drawn as patterns and named in the lane).

### Saving a view as a Metric Set

What a Metric Set remembers: its counters in their order, the process / disk / interface they
observe, each series' color (Auto or yours) and *One Lane per Unit*. What it never remembers: the
time window, the cursor or range, LIVE / PAUSED, hidden series - those belong to the open view.

- **Save as Metric Set...** keeps the view as a new set (name, optional description); the view
  belongs to that set from then on.
- A view opened from one of your sets shows `*` on its tab once its counters, colors or lanes
  differ from the set. **Save to "&lt;set&gt;"** writes them back; **Revert to Saved Set** brings the
  set's counters and colors back.
- A view of a built-in set (Host Basics, ...) is never saved over: **Save as Metric Set...** makes
  your own copy, for example *My Host Basics* with CPU in red.

Two sets of the same counters open as two tabs, each with its own colors - and still one
collection per counter.

The status bar shows LIVE / PAUSED, the cursor or range, how many metrics the view collects and
how often (the tooltip adds the collection's memory and its last duration).

## Metric alerts

An alert can watch a counter instead of a log: **Tools > Manage Alerts... > New Metric Alert...**
(or *A performance counter* in the Alert dialog). Choose the counter (**Choose...** opens the
picker), a comparison (`>`, `>=`, `<`, `<=`, `=`, `!=`) with a threshold (`90`, `90 %`, `4 GiB`) and
how many seconds it must hold without a break (0: one sample decides) - for example *CPU (total)
> 90 % for 30 s*. It fires once when the condition becomes true and again only after it was false
in between; a sample that could not be read never counts either way. Any alert - one on a log too -
can keep a Metric Set's samples of the minutes around the moment as **evidence** in its incident.
Details: [Alerts and monitoring](https://tktail.dev/help/alerts-and-monitoring/).

## The METRICS panel

**View > Tool Views > Metrics** (or **Tools > Metrics > METRICS Panel**) shows a table of every
counter being collected: its current value, minimum / average / maximum and a sparkline of the
last 5 minutes, its state, and which views collect it (*Collected for*).

The panel has its **own list** too: counters you add here are collected from TKTail's start for
as long as they stay on the list (it is saved with your settings) - useful for "always show me
CPU and the service's memory". The panel's buttons and right-click menu: **Add counters** (+ - the
picker with its Metric Sets), *Add Host Basics*, *Add Process Diagnostics...*, **Open in New
Metrics View** (Enter), **Pause** the display, **Remove** (Delete), *Remove Stopped Metrics*,
**Copy**, *Collect Every*, and *Keep History* 5 / 15 / 30 / 60 minutes (for all metrics).

**From the panel into a Metrics View.** Select one or several rows (Ctrl+click, Shift+click,
Ctrl+A) and:
- right-click > **Add to Active Metrics View** - the Metrics View in front, else the one you used
  last, else a new one;
- right-click > **Add to Metrics View** > one of the open Metrics Views, or *New Metrics View*;
- **Open in New Metrics View** (Enter) - a view of just those metrics;
- or **drag** the rows: onto a Metrics View they join it; onto a log pane, an empty area or a pane's
  edge they open in a new Metrics View there ([Drag sources into the
  workspace](https://tktail.dev/help/viewing-logs/#drag-sources-into-the-workspace)).

A metric that is in the view already is not added twice (it is selected instead), and the view keeps
collecting through the same stream - adding a view never starts a second collection of a counter,
and the history TKTail kept is shown at once. A *stopped (history kept)* metric can be added too: the
view shows its history and its state, never a value it does not have. Where the new series is drawn
follows the view: with **One Lane per Unit** it joins the lane of its unit, otherwise it gets a lane
of its own - a value never lands on another unit's axis (the status bar says which while you drag).
The rows stay selected, so the next view is one more click. Adding to a view opened from one of your
Metric Sets marks it changed (`*`): **Save to "&lt;set&gt;"** keeps the change, **Revert to Saved Set**
undoes it; a built-in set never changes - **Save as Metric Set...** makes it yours.

**Removing metrics.** Select one or several rows - Ctrl+click, Shift+click, Ctrl+A - and press
**Delete** (or right-click > *Remove Metrics*; a right-click on a selected row keeps the
selection). The selection stays on the same metrics while the table updates every second.
- A counter on the panel's own list leaves it.
- A stopped metric (*stopped (history kept)* - for example the counters of a process whose view
  you closed) is removed with its history; **Remove Stopped Metrics** does that for all of them.
- A metric a Metrics View still collects stays for that view (the status bar names it) - remove it
  in the view, or close the view.

Removing rows never changes a saved Metric Set: open the set again and its counters come back.

| State | Meaning |
|---|---|
| ok | Read at the last collection |
| waiting for the first sample | Nothing has been read yet |
| warming up | Rates (CPU, bytes/s) need two readings - the first value comes one interval later |
| stale | No new sample for longer than expected |
| restarted (another process) | A followed process was restarted; the series continues, marked |
| not running | The process (the counter's instance) is not running now |
| access denied | Windows does not let this user read the counter |
| unavailable | The counter cannot be read now (the tooltip says why) |
| stopped (history kept) | Nothing collects it any more; what was collected stays until it ages out |

## Metrics for an AI assistant

An assistant connected over [MCP](https://tktail.dev/help/mcp/) can read the same metrics: list the Metric Sets and the
metrics TKTail keeps, a metric's current value and its samples, and a summary of an interval - for
example the CPU of the minutes around an error it is looking at. It reads only what TKTail already
collects; with your permission it can also save or delete your Metric Sets. These tools need the
Metrics feature of your license, like the views. How metrics fit into an investigation with an assistant:
[AI assistance](https://tktail.dev/help/ai-assistance/#metrics-and-windows-events); the tools and their arguments:
[MCP tool reference](https://tktail.dev/help/mcp-tools/).

## Linked windows

The METRICS panel's own list is collected once, by the main window; a linked window says so in
its panel and **Open in Metrics View** shows the list there. Metrics Views opened in a linked
window collect in that window. See [Linked windows](https://tktail.dev/help/windows/).

## What it costs

Counters are read on a background thread, once per interval for all views together - three views
of the same counter are one collection. A hidden Metrics View does not draw; a visible one draws
when new samples arrive.

What matters is **which kind of counter**, not how many: Windows reads a whole counter object at
a time. Processor, memory and disk counters (Host Basics) cost next to nothing. Counters of the
**Process** object (Process Diagnostics, any process counter) and of the **System** object
(System Pressure's queue length and context switches) make Windows gather the list of all running
processes at every collection, so their cost grows with how busy
the PC is - measured from about 4 ms of CPU time per collection (450 processes) to about 60 ms
(820 processes with 38,000 threads), i.e. from under 1 % to about 6 % of one CPU core at *every 1
s*, the same for one or twenty such counters. When you watch process counters for longer on a busy
PC, **Collect Every** 2-5 s lowers that in proportion. A hidden Metrics View costs nothing; a
visible one redraws once per collection. Measured numbers:
PERFORMANCE.md.

---

The HTML page: https://tktail.dev/help/metrics/
