> ## Documentation Index
> Fetch the complete documentation index at: https://cockroachlabs.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# cockroach debug merge-logs

export const InternalLink = ({version, path = "", children, ...props}) => {
  let detectedVersion = version || "stable";
  if (typeof window !== 'undefined' && !version) {
    const match = window.location.pathname.match(/\/docs\/([^/]+)/);
    if (match) {
      detectedVersion = match[1];
    }
  }
  const normalizedPath = path.startsWith("/") ? path.slice(1) : path;
  return <a href={`/docs/${detectedVersion}/${normalizedPath}`} {...props}>
      {children}
    </a>;
};

The `cockroach debug merge-logs` <InternalLink path="cockroach-commands">command</InternalLink> merges log files from multiple nodes into a single time-ordered stream of messages with an added per-message prefix to indicate the corresponding node. You can use it in conjunction with logs collected using the <InternalLink path="cockroach-debug-zip">`debug zip`</InternalLink> command to aid in debugging.

<Danger>
  The file produced by `cockroach debug zip` can contain highly <InternalLink path="configure-logs#redact-logs">sensitive, identifiable information</InternalLink>, such as usernames, hashed passwords, and possibly your table's data. You can use the [`--redact`](#example) flag to redact the sensitive data out of log files and crash reports before sharing them with Cockroach Labs.
</Danger>

## Subcommands

While the `cockroach debug` command has a few subcommands, users are expected to use only the <InternalLink path="cockroach-debug-zip">`zip`</InternalLink>, <InternalLink path="cockroach-debug-encryption-active-key">`encryption-active-key`</InternalLink>, <InternalLink path="cockroach-debug-merge-logs">`merge-logs`</InternalLink>, <InternalLink path="cockroach-debug-list-files">`list-files`</InternalLink>, <InternalLink path="cockroach-debug-tsdump">`tsdump`</InternalLink>, and <InternalLink path="cockroach-debug-ballast">`ballast`</InternalLink> subcommands.

We recommend using the <InternalLink path="cockroach-debug-encryption-decrypt">`encryption-decrypt`</InternalLink> and <InternalLink path="cockroach-debug-job-trace">`job-trace`</InternalLink> subcommands only when directed by the <InternalLink path="support-resources">Cockroach Labs support team</InternalLink>.

The other `debug` subcommands are useful only to Cockroach Labs. Output of `debug` commands may contain sensitive or secret information.

## Synopsis

```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
$ cockroach debug merge-logs [log file directory] [flags]
```

## Flags

Use the following flags to filter the `debug merge-logs` results for a specified regular expression or time range.

| Flag       | Description                                                                                              |
| ---------- | -------------------------------------------------------------------------------------------------------- |
| `--filter` | Limit the results to the specified regular expression                                                    |
| `--from`   | Start time for the time range filter.                                                                    |
| `--to`     | End time for the time range filter.                                                                      |
| `--redact` | Redact <InternalLink path="configure-logs#redact-logs">sensitive data</InternalLink> from the log files. |

## Example

Generate a debug zip file:

```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
$ cockroach debug zip ./cockroach-data/logs/debug.zip --insecure
```

Unzip the file:

```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
$ unzip ./cockroach-data/logs/debug.zip
```

Merge the logs in the debug folder:

```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
$ cockroach debug merge-logs debug/nodes/*/logs/*
```

Alternatively, filter the merged logs for a specified time range:

```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
$ cockroach debug merge-logs debug/nodes/*/logs/* --from="220713 18:36:28.208553" --to="220713 18:36:29.232864"
```

You can also filter the merged logs for a regular expression:

```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
cockroach debug merge-logs debug/nodes/*/logs/* --filter="RUNNING IN INSECURE MODE"
```

You can redact sensitive information from the merged logs:

```shell theme={"theme":{"light":"catppuccin-mocha","dark":"catppuccin-mocha"}}
cockroach debug merge-logs --redact debug/nodes/*/logs/*
```

## See also

* <InternalLink path="support-resources">Support Resources</InternalLink>
* <InternalLink path="cockroach-commands">`cockroach` Commands Overview</InternalLink>
* <InternalLink path="troubleshooting-overview">Troubleshooting Overview</InternalLink>
