# Send Modal Logs and Metrics

> Export the logs and container metrics of a Modal workspace to Telemetry Machine with Modal's OpenTelemetry integration.

Modal can export the logs and metrics of a workspace over OpenTelemetry. It sends them all to one URL, with the same headers, so you name one dataset in the URL without its signal, and Telemetry Machine [infers each dataset from that name](https://telemetrymachine.com/docs/send-opentelemetry#inferring-the-dataset-from-the-name). Logs go to `modal-logs`, and metrics go to `modal-metrics`.

## Before you start

- To create a dataset or an API key in Telemetry Machine, you must be an owner or an admin of the organization.
- You need access to your Modal workspace's settings.

## Create the datasets

Create a logs dataset named `modal-logs`, a metrics dataset named `modal-metrics`, and one ingest key that can write to both, with [tm-cli](https://telemetrymachine.com/docs/quick-start#tm-cli) or the [MCP server](https://telemetrymachine.com/docs/quick-start#option-1-set-up-with-a-coding-agent). Don't create a dataset named `modal`: a dataset with the exact name in the URL would take every signal.

```console tab="tm-cli"
$ tm-cli datasets create --name modal-logs --type logs
$ tm-cli datasets create --name modal-metrics --type metrics
$ tm-cli api-keys create --name modal --dataset modal-logs --dataset modal-metrics
```

```json tab="MCP"
create_dataset { "name": "modal-logs", "signal_type": "logs" }
create_dataset { "name": "modal-metrics", "signal_type": "metrics" }
create_ingest_key { "name": "modal", "datasets": ["modal-logs", "modal-metrics"] }
```

tm-cli shows the key once, in `api_key.api_key`. Over MCP, your agent gets it once, for the Modal Secret below. In the app, [create each dataset](https://telemetrymachine.com/datasets/new), then one key for both under **API keys** in your organization's settings. Don't use the key that creating a dataset shows you: it can write to that dataset only.

## Connect Modal

First, put the key in a Modal Secret:

1. In Modal, open **Secrets** and select **Create secret**.
1. Select **OpenTelemetry**.
1. In **Name**, type `telemetry-machine`.
1. In **Key**, type `OTEL_HEADER_Authorization`.
1. In **Value**, type `Bearer`, a space, and the Telemetry Machine API key.
1. Select **Done**.

Then turn on the integration:

1. Open Modal's settings, then **Metrics integrations**.
1. Under **OpenTelemetry (OTEL) integration**, turn on **Enable OTEL integration**.
1. In **Push URL**, type the URL below.
1. In **Credentials secret**, select `telemetry-machine`.
1. Select **Connect**.
1. Select **Send test**.

```text
https://api.telemetrymachine.com/datasets/modal
```

Modal adds `/v1/logs` and `/v1/metrics` to this URL, so its logs go to `modal-logs` and its metrics to `modal-metrics`. Modal sends the Secret's entry as the `Authorization` header. A Secret's keys may hold only letters, digits and underscores, so `OTEL_HEADER_X-API-Key` is refused; `Authorization: Bearer` is the same key in a header Modal can send.

The test sends one log, `Hello from Modal! 🚀`, from the service `modal.test_logs`. Find it in `modal-logs`. If Modal shows `400 Bad Request` instead, check that `modal-logs` exists and that the key can write to it. Telemetry Machine remembers a refusal for up to 5 minutes, so wait that long after a fix before you test again.

Under **Telemetry signals**, you can choose what Modal sends. If you send custom traces through Modal, also create a traces dataset named `modal-traces` and add it to the key: Modal forwards them to the same URL.

## Query the data

Modal names its metrics `modal.*`, such as `modal.cpu.utilization` and `modal.memory.usage`, with more for GPUs, containers, functions and inputs. See Modal's [list of metrics](https://modal.com/docs/guide/otel-integration).

The logs dataset holds the output of your Functions and Sandboxes, and your workspace's audit logs.

---

All pages: https://telemetrymachine.com/docs/llms.txt
