> For the complete documentation index, see [llms.txt](https://docs.rumi.systems/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.rumi.systems/rumi-cli/commands/tools/txnstats/query.md).

# query

The `query` subcommand executes a SQL-like query against transaction logs and joins the results with per-transaction statistics, outputting to CSV.

{% hint style="warning" %}
**Note**: This tool is experimental and still in incubation.
{% endhint %}

## Usage

```bash
rumi tools txnstats query [options]
```

## Options

| Option                       | Description                                                    |
| ---------------------------- | -------------------------------------------------------------- |
| `-l, --log <file>`           | **(Required)** Path to the main recovery transaction log       |
| `-q, --query <sql>`          | **(Required)** SQL-like query to execute                       |
| `-o, --output <file>`        | Output CSV file (default: `txnstats.csv`)                      |
| `-m, --include-message-logs` | Include inbound/outbound message logs in query (default: true) |

## Prerequisites

The query command expects these related log files in the same directory as the main log:

| File                  | Description                     |
| --------------------- | ------------------------------- |
| `<name>.log`          | Main recovery transaction log   |
| `<name>.txnstats.log` | Per-transaction statistics log  |
| `<name>.in.log`       | Inbound message log (optional)  |
| `<name>.out.log`      | Outbound message log (optional) |

## Example

```bash
rumi tools txnstats query \
  -l /path/to/myapp.log \
  -q "SELECT simpleClassName, timestamp FROM logs WHERE timestamp BETWEEN 'today at 3pm' AND 'today at 3:05pm'" \
  -o results.csv
```

The output CSV will contain:

* Fields selected in the query
* Transaction timing statistics joined by transaction ID
* Inbound and outbound message timing details (when applicable)

## Compatibility

{% hint style="info" %}
**3.x Compatibility**: For logs created with Rumi 3.x, use the `--3x` flag before the command:

```bash
rumi --3x tools txnstats query -l /path/to/myapp.log -q "SELECT * FROM logs"
```

{% endhint %}

## See Also

* [txnstats](/rumi-cli/commands/tools/txnstats.md) - Transaction stats tools overview
* [txnstats dump](/rumi-cli/commands/tools/txnstats/dump.md) - Dump transaction stats to CSV
* [Configuring Per-Transaction Statistics](/rumi-core/guides/developing-applications/configuring-the-runtime/monitoring/per-transaction-statistics.md) - How to enable per-transaction stats logging
* [Querying Transaction Logs](/rumi-core/guides/operating-applications/analysis-and-troubleshooting/querying-transaction-logs.md) - Understanding the query syntax


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.rumi.systems/rumi-cli/commands/tools/txnstats/query.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
