# Stats Dump Tool

This page lists the usage info for the Talon stats dump tool.

This tool can read a binary transaction log containing XVM heartbeats emitted by a Talon XVM and write them out in a human readable format. Computing and tracing statistics from the running application process results in CPU overhead and garbage. As a lower cost alternative, Talon XVM can be configured to log its [XVM heartbeats to a transaction log](/talon/developing-applications/configuring-the-runtime/monitoring/xvm-heartbeats.md#binary-logging-configuration), and this tool can be used to compute and trace the binary stats in a separate process (possibly on another host).

{% hint style="info" %}
**Since 3.4**: Up until the 3.4 release the StatsDumpTool was maintained in [GitHub](https://github.com/neeveresearch/nvx-platform-tools/tree/master/nvx-stats-dump-tool). This was done to make it easier to keep the tool up to date with new stats added to the platform.
{% endhint %}

## Overview

Each heartbeat message includes the following stats:

**System Stats:**

* Basic information - Server/hostname and process PID
* GC stats - Heap size and collection time
* JIT Information
* System load average
* Thread count
* Thread stats
* Pool stats

**Application Stats:**

* Engine
* User stats
* Event Multiplexer
* Store binding
* Store binding persister
* Store binding ICR sender
* Bus binding stats

The platform allows fairly granular control over which portions of the above stats are collected to provide the ability to control the associated overhead with collecting them. See [Engine Stats](/talon/operating-applications/monitoring/engine-statistics.md) for information on enabling collection of these statistics.

## Basic Usage

{% hint style="info" %}
**Requirement**: In order to use this tool, [Binary Heartbeat Logging](/talon/developing-applications/configuring-the-runtime/monitoring/xvm-heartbeats.md#binary-logging-configuration) must have been enabled on the microservice in question. Even if you have enabled stats collection, but did not enable the heartbeat logging, you will not be able to retrieve said statistics at a later date.
{% endhint %}

```
StatsDumpTool [-h] [-o] [-s] [-e] <transactionLog>

[<-h|--help> Displays this help message (default='false')]
[<-o|--outFile> Name of output file name. Default file name is 'stats.txt]
[<-s|--startDate> Start date of the query. The date must be in yyyy-MM-dd HH:mm:ss format]
[<-e|--endDate> End date of the query. The date must be in yyyy-MM-dd HH:mm:ss format]
<transactionLog> Path of the stats transaction log to read
```

## Running the Tool

### From a distribution

```bash
# Linux/OSX
bin/xstatsdumptool.sh path/to/some/statsdump.log

# Windows
bin\xstatsdumptool.bat path\to\some\statsdump.log
```

### From a jar only distribution

```bash
cd path/to/logs/dir
java -cp nvx-core-all.jar:<your-app-classes> com.neeve.tools.StatsDumpTool

# or

java -cp nvx-talon-all.jar:<your-app-classes> com.neeve.tools.StatsDumpTool
```

### Querying records within a time range

You can query for records in a time range by specifying --startDate or --endDate or both:

* If **only --startDate is specified**, stats records are dumped from startDate to the end of the file is reached
* If **only --endDate is specified**, stats records are dumped from beginning of the file till the endDate
* If **both --startDate and --endDate are specified**, stats are dumped in between the given start and end dates

The format for specifying the timestamps used with --startDate and --endDate is **yyyy-MM-dd HH:mm:ss**.

{% hint style="info" %}
**Tip**: Be careful when specifying these timestamps! Leading/trailing spaces or additional spaces between date and time block might cause them to not be parsed correctly.
{% endhint %}

## Examples

### All records

Here is the output of running the stats dump tool on a sample transaction log file:

```
bin\xstatsdumptool.bat target\test-classes\com\neeve\tools\statsdumptest.log

<10,2224,Ironman> 20160218-20:59:34:555 (inf)...[RogLog->'statsdumptest'] Live transaction log file is 'statsdumptest.log'...
<10,2224,Ironman> 20160218-20:59:34:696 (inf)...[RogLog->'statsdumptest'] Scavenging old log files....
<10,2224,Ironman> 20160218-20:59:34:700 (inf)...[RogLog->'statsdumptest'] ....scavenged 0 files (0 failed).

Writing 2619 records to C:\sources\neeve\github\nvx-platform-tools\nvx-stats-dump-tool\target\test-classes\com\neeve\tools\stats.txt

Done ...
```

The output shows that the tool has read 2,619 records and written them to the output file (*stats.txt*). Note that the output file is created in the same directory as the input file.

### All records within a date range

Here is an example of how using --startDate can be used filter out records.

```
bin\xstatsdumptool.bat target\test-classes\com\neeve\tools\statsdumptest.log --startDate "2016-01-26 00:00:00"

<10,11784,Ironman> 20160218-21:46:02:211 (inf)...[RogLog->'statsdumptest'] Live transaction log file is 'statsdumptest.log'...
<10,11784,Ironman> 20160218-21:46:02:297 (inf)...[RogLog->'statsdumptest'] Scavenging old log files....
<10,11784,Ironman> 20160218-21:46:02:300 (inf)...[RogLog->'statsdumptest'] ....scavenged 0 files (0 failed).

Writing 99 records to C:\sources\neeve\github\nvx-platform-tools\nvx-stats-dump-tool\target\test-classes\com\neeve\tools\stats.txt

Done ...
```

Notice that because we specified --startDate here, only 99 records are written (of the 2,619 records in the transaction log).

You can further filter records by specifying a time range with a particular --startDate and --endDate. In the example below we are querying records starting between "2016-01-27 00:00:00" and "2016-01-27 01:26:39":

```
bin\xstatsdumptool.bat target\test-classes\com\neeve\tools\statsdumptest.log --startDate "2016-01-27 00:00:00" --endDate "2016-01-27 01:26:39"

<10,8248,Ironman> 20160218-22:25:06:957 (inf)...[RogLog->'statsdumptest'] Live transaction log file is 'statsdumptest.log'...
<10,8248,Ironman> 20160218-22:25:07:043 (inf)...[RogLog->'statsdumptest'] Scavenging old log files....
<10,8248,Ironman> 20160218-22:25:07:046 (inf)...[RogLog->'statsdumptest'] ....scavenged 0 files (0 failed).
Writing 8 records to C:\sources\neeve\github\nvx-platform-tools\nvx-stats-dump-tool\target\test-classes\com\neeve\tools\stats.txt

Done ...
```

Notice only 8 records are written to the output file.

## Related Topics

* \[Configure Heartbeat Logging] (../../../developing-applications/configuring-the-runtime/monitoring/xvm-heartbeats.md#binary-logging-configuration) - Configure Heartbeat Logging
* [Heartbeat Tracing](/talon/operating-applications/monitoring/xvm-heartbeats.md) - Output metrics in heartbeats to trace log
* [Engine Stats](/talon/operating-applications/monitoring/engine-statistics.md) - Engine metrics collected in heartbeats
* [Exposing Application Stats](/talon/developing-applications/authoring-user-code/monitoring/exposing-application-statistics.md) - Custom statistics included in heartbeats

## Next Steps

1. Enable binary heartbeat logging in your XVM configuration
2. Run your application and collect heartbeat data
3. Use Stats Dump Tool to convert binary logs to human-readable format
4. Analyze statistics to identify performance trends or issues


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.xplatform.com/talon/operating-applications/analysis-and-troubleshooting/tools/stats-dump-tool.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
