> ## Documentation Index
> Fetch the complete documentation index at: https://docs.neuro-tech.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Query runtime counters

> Read live counters, compare snapshots, and build operational reports

Runtime counters are maintained in memory and periodically persisted. Use the Script counter functions for current values; querying the database alone can return an older value.

## Read counters

Each persisted `RuntimeCounter` has `ObjectId`, `Key`, and `Counter`. List keys and fetch their live value:

```text theme={null}
SELECT
  Key,
  GetCounter(Key) AS Value
FROM RuntimeCounter
ORDER BY Key
```

If you query the collection name `RuntimeCounters`, quote it because the same name is also a .NET namespace:

```text theme={null}
SELECT count(*) FROM "RuntimeCounters"
```

Useful functions include `GetCounter`, `GetCounters`, `IncCounter`, `DecCounter`, and the counter flush function available in the installed build.

## Compare snapshots

Create a dictionary keyed by counter name:

```text theme={null}
Sample1:={};
foreach Counter in (SELECT Key FROM RuntimeCounter) do
  Sample1[Counter]:=GetCounter(Counter);
```

Take the second sample later and subtract the dictionaries:

```text theme={null}
Sample2:={};
foreach Counter in (SELECT Key FROM RuntimeCounter) do
  Sample2[Counter]:=GetCounter(Counter);

Diff:=Sample2-Sample1;
[P in [foreach P in Diff:P]:P.Value!=0]T
```

Dictionary subtraction treats a missing key as the additive zero value, making it suitable when counters appear between samples.

## Counter reports

The administrative **Sources & Nodes** view can expose file-based reports for labelled snapshots and comparisons. Standard reports include general counter comparison and a billable-counter view.

Typical business counters include account creation, remote login, legal-identity states, contract/template states, and KYC provider operations. Treat the exact keys as versioned runtime output: discover them from the server instead of hard-coding an exhaustive list.

## Reporting guidance

* Record snapshot time, Neuron identity, build, and counter prefix.
* Use monotonically increasing counters for rates by comparing two labelled snapshots.
* Expect resets after database restoration or deliberate counter maintenance.
* Do not use counters as a financial ledger; use auditable domain events for settlement.
* Alert on rates and trends, not a single cumulative value.

See [Reports and automation](/script/reports-and-automation) to turn these queries into reusable operator reports.
