> For the complete documentation index, see [llms.txt](https://metalbear.com/mirrord/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://metalbear.com/mirrord/docs/faq/troubleshooting/utilities.md).

# Utilities

### Response Header Injection

Indicate whether the request was handled by mirrord.

{% hint style="info" %}
This feature requires at least mirrord-agent version **3.163.0**.
{% endhint %}

#### Use Case

When debugging, it’s often useful to know how a response was handled by mirrord after being intercepted. This option helps verify mirrord’s routing decisions and understand whether the intercepted traffic was forwarded to the local process or passed through to its original destination.

#### Header behavior

When enabled, the mirrord agent automatically adds a `mirrord-agent` header to HTTP responses handled by mirrord.

**Possible values for the header:**

* `forwarded-to-client`: The mirrord agent intercepted the request, sent it to the local process, and then passed back the response (mirrord handled it).
* `passed-through`: The mirrord agent intercepted the request, sent it to its original destination, and then passed back the response (the request was not handled by the local process). For example, if a request doesn’t match active filters, it will be passed to the original destination.

Header injection is disabled by default. You can enable it with the following configuration in the `mirrord.json` file:

```json
{
  "agent": {
    "inject_headers": true
  }
}
```

You can see all the agent configuration options [here](https://metalbear.com/mirrord/docs/config#agent).

### Latency Diagnose

The `mirrord diagnose latency` command helps identify network latency issues between your local environment and the target workload. It measures round-trip time (RTT) across multiple iterations and reports latency statistics, making it useful when mirrord feels slow or requests take longer than expected.

#### When to use this

Use this command if you experience:

* Slow request/response times when using mirrord
* Unexpected delays compared to running locally or in-cluster
* Network issues between your machine and the Kubernetes cluster

```bash
mirrord diagnose latency [OPTIONS]
```

Options

`-f, --config-file <CONFIG_FILE>`: Specify a config file to use.

`-h, --help`: Print help information.

**Example**

```bash
mirrord diagnose latency
```

```bash
...
* 89/100 iterations completed, last iteration took 397ms
...
✓ Latency statistics: min=40ms, max=397ms, avg=47ms
  ✓ using operator
    ✓ operator license valid
    ✓ user credentials prepared
    ✓ session started
      ✓ connected to the target

```

**Iterations:** mirrord performs multiple RTT checks to smooth out transient spikes.

**min / max / avg:**

* `min` represents best-case latency
* `max` highlights potential spikes or instability
* `avg` is usually the most useful indicator for overall performance


---

# 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://metalbear.com/mirrord/docs/faq/troubleshooting/utilities.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.
