Send Modal Logs and Metrics

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

Open in Claude

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. 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 or the MCP server. Don't create a dataset named modal: a dataset with the exact name in the URL would take every signal.

$ 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

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, 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.
  2. Select OpenTelemetry.
  3. In Name, type telemetry-machine.
  4. In Key, type OTEL_HEADER_Authorization.
  5. In Value, type Bearer, a space, and the Telemetry Machine API key.
  6. Select Done.

Then turn on the integration:

  1. Open Modal's settings, then Metrics integrations.
  2. Under OpenTelemetry (OTEL) integration, turn on Enable OTEL integration.
  3. In Push URL, type the URL below.
  4. In Credentials secret, select telemetry-machine.
  5. Select Connect.
  6. 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.

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