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

# Pull logs and metrics

> Fetch and stream logs and metrics for a deployment or an environment from the CLI or Management API for debugging and scripting.

When a deployment misbehaves, start with its logs and metrics. This page
covers reading both from the console, the CLI, and the Management API. For
metric definitions and Prometheus-style export, see
[Metrics](/observability/metrics) and the other Observability pages.

## Fetch and stream logs

Pull logs to debug an incident, grep for an error, or pipe context into an
agent. Fetch a time window (up to 7 days back):

<Tabs>
  <Tab title="UI">
    **To view logs**:

    1. Sign in to your workspace at
       [app.baseten.co](https://app.baseten.co) and choose **Dedicated Inference** in the
       sidebar.
    2. Select your model.
    3. Select the deployment under **Deployments**.
    4. Choose **Logs**.

    Filter by level or replica, search, or follow live output with the
    controls at the top of the logs view.
  </Tab>

  <Tab title="Baseten CLI">
    **To fetch logs**:

    <CodeGroup>
      ```bash Command theme={"system"}
      baseten model deployment logs --model-id <model-id> --deployment-id <deployment-id> --since 1h
      ```

      ```txt Output theme={"system"}
      [2026-07-07 10:33:58]: Deploy was a success.
      [2026-07-07 10:33:44]: (nvsmp) Completed model.load() execution in 6 ms
      [2026-07-07 10:33:44]: (nvsmp) Uvicorn running on http://0.0.0.0:8080 (Press CTRL+C to quit)
      ```
    </CodeGroup>

    The parenthesized prefix on each line is the replica that emitted it.

    **To stream live logs**:

    Pass `--tail` instead of a time window:

    <CodeGroup>
      ```bash Command theme={"system"}
      baseten model deployment logs --model-id <model-id> --deployment-id <deployment-id> --tail
      ```

      ```txt Output theme={"system"}
      [2026-07-07 10:33:44]: (nvsmp) Completed model.load() execution in 6 ms
      [2026-07-07 10:33:58]: Deploy was a success.
      ...
      ```
    </CodeGroup>

    Streaming continues until the deployment leaves a runnable state or you
    interrupt with Ctrl-C. For machine-readable output, add `--output jsonl`
    to stream one JSON log entry per line:

    <CodeGroup>
      ```bash Command theme={"system"}
      baseten model deployment logs --model-id <model-id> --deployment-id <deployment-id> --tail --output jsonl
      ```

      ```json Output theme={"system"}
      {"level":"INFO","message":"Completed model.load() execution in 6 ms","replica":"nvsmp","timestamp":"1783445624380306972"}
      {"level":"INFO","message":"Deploy was a success.","replica":"","timestamp":"1783445638726940011"}
      ...
      ```
    </CodeGroup>

    Narrow the stream with `--jq`: `--jq '.message'` extracts one field per
    line, and `--jq 'select(.level=="ERROR") | .message'` keeps only error
    lines.
  </Tab>

  <Tab title="REST API">
    **To fetch logs**:

    <CodeGroup>
      ```bash Request theme={"system"}
      curl "https://api.baseten.co/v1/models/{model_id}/deployments/{deployment_id}/logs" \
        -H "Authorization: Bearer $BASETEN_API_KEY"
      ```

      ```json Response theme={"system"}
      {
        "logs": [
          {
            "timestamp": "1783445638726940011",
            "message": "Deploy was a success.",
            "replica": "",
            "request_id": null,
            "level": "INFO"
          },
          {
            "timestamp": "1783445624380306972",
            "message": "Completed model.load() execution in 6 ms",
            "replica": "nvsmp",
            "request_id": null,
            "level": "INFO"
          }
        ]
      }
      ```
    </CodeGroup>

    The window defaults to the last 30 minutes; pass `start_epoch_millis`
    to widen it, up to 7 days. Timestamps are epoch nanoseconds. The API
    fetches fixed windows only; to follow logs live, use the CLI's `--tail`.
  </Tab>
</Tabs>

For more information about filters like log level, search patterns, and
request ID, see [`logs`](/reference/cli/baseten/model-deployment#logs)
and the [logs endpoint](/reference/management-api/deployments/get-deployment-logs)
(beta).

## Fetch metrics

Pull metrics to check a deployment's health from a script: replica count,
request volume, and end-to-end latency quantiles.

<Tabs>
  <Tab title="UI">
    **To view metrics**:

    1. Sign in to your workspace at
       [app.baseten.co](https://app.baseten.co) and choose **Dedicated Inference** in the
       sidebar.
    2. Select your model.
    3. Select the deployment under **Deployments**.
    4. Choose **Metrics**.

    The metrics view charts request rates by status code, latency
    percentiles, and replica counts. Set the window with the time-range
    selector at the top.
  </Tab>

  <Tab title="Baseten CLI">
    **To fetch metrics**:

    <CodeGroup>
      ```bash Command theme={"system"}
      baseten model deployment metrics --model-id <model-id> --deployment-id <deployment-id>
      ```

      ```txt Output theme={"system"}
      METRIC                                    QUANTILE  STAT  VALUE
      baseten_replicas_active                                       1
      baseten_end_to_end_response_time_seconds  0.5                 -
      baseten_end_to_end_response_time_seconds  0.9                 -
      baseten_end_to_end_response_time_seconds  0.95                -
      baseten_end_to_end_response_time_seconds  0.99                -
      baseten_end_to_end_response_time_seconds            avg       -
      ```
    </CodeGroup>

    Latency values show `-` until the deployment has served requests in the
    window; once it has, a STATUS column also breaks out request counts per
    response code. The default is a current snapshot; pass `--mode summary`
    or `--mode series` with `--since` to aggregate over a window instead.
  </Tab>

  <Tab title="REST API">
    **To fetch metrics**:

    <CodeGroup>
      ```bash Request theme={"system"}
      curl "https://api.baseten.co/v1/models/{model_id}/deployments/{deployment_id}/metrics" \
        -H "Authorization: Bearer $BASETEN_API_KEY"
      ```

      ```json Response theme={"system"}
      {
        "start_epoch_millis": 1783445679297,
        "end_epoch_millis": 1783445679297,
        "mode": "CURRENT",
        "step_seconds": null,
        "metric_descriptors": [
          {
            "name": "baseten_replicas_active",
            "unit_hint": "COUNT",
            "kind": "GAUGE",
            "label_sets": [{}]
          }
        ],
        "metric_values": [
          {
            "start_epoch_millis": 1783445679297,
            "values": [[1.0]]
          }
        ]
      }
      ```
    </CodeGroup>

    `metric_values` lines up with `metric_descriptors` by position: the
    first value array belongs to the first metric, the second to the second,
    and so on.
  </Tab>
</Tabs>

For more information about modes, windows, and metric selection, see
[`metrics`](/reference/cli/baseten/model-deployment#metrics)
and the [metrics endpoint](/reference/management-api/deployments/get-deployment-metrics)
(beta). For what each metric means, see
[Metrics](/observability/metrics).

## Fetch environment logs and metrics

Deployment scope answers "what is this specific deployment doing?"
Environment scope answers "what is production doing right now?", which is
usually the more useful operational question. An
[environment](/deployment/environments) spans every deployment that has
served it, so environment logs and metrics stay continuous across
promotions: during and after a rollout, one view covers the outgoing and
incoming deployments. Fetch them from any surface:

<Tabs>
  <Tab title="UI">
    **To view an environment's logs and metrics**:

    1. Sign in to your workspace at
       [app.baseten.co](https://app.baseten.co) and choose **Dedicated Inference** in the
       sidebar.
    2. Select your model.
    3. On the model overview, choose **Logs** or **View metrics** for the
       environment.

    You can also reach the same views from any deployment's logs or metrics
    page: choose the environment from the dropdown in the upper left.
  </Tab>

  <Tab title="Baseten CLI">
    **To fetch environment logs**:

    Target the environment by name instead of a deployment ID:

    <CodeGroup>
      ```bash Command theme={"system"}
      baseten model environment logs --model-id <model-id> --environment production --since 1h
      ```

      ```txt Output theme={"system"}
      [2026-07-09 08:49:09]: (w44tt) Application shutdown complete.
      [2026-07-09 08:48:41]: Scaling down replicas due to inactivity
      [2026-07-09 08:34:09]: (67wjm) Terminated
      ...
      ```
    </CodeGroup>

    The same windows and filters as deployment logs apply, including
    `--tail` for live streaming and `--output jsonl` for machine-readable
    output.

    **To fetch environment metrics**:

    <CodeGroup>
      ```bash Command theme={"system"}
      baseten model environment metrics --model-id <model-id> --environment production
      ```

      ```txt Output theme={"system"}
      METRIC                                    QUANTILE  STAT  VALUE
      baseten_replicas_active                                       1
      baseten_end_to_end_response_time_seconds  0.5                 -
      baseten_end_to_end_response_time_seconds  0.9                 -
      baseten_end_to_end_response_time_seconds  0.95                -
      baseten_end_to_end_response_time_seconds  0.99                -
      baseten_end_to_end_response_time_seconds            avg       -
      ```
    </CodeGroup>

    The default is a current snapshot; pass `--mode summary` or
    `--mode series` with `--since` to aggregate over a window. In series
    mode the window splits at each promotion, so every point reflects the
    deployment serving the environment at that time.
  </Tab>

  <Tab title="REST API">
    **To fetch environment logs**:

    <CodeGroup>
      ```bash Request theme={"system"}
      curl "https://api.baseten.co/v1/models/{model_id}/environments/production/logs" \
        -H "Authorization: Bearer $BASETEN_API_KEY"
      ```

      ```json Response theme={"system"}
      {
        "logs": [
          {
            "timestamp": "1783612149447676900",
            "message": "Application shutdown complete.",
            "replica": "w44tt",
            "request_id": null,
            "level": "INFO"
          }
        ]
      }
      ```
    </CodeGroup>

    **To fetch environment metrics**:

    <CodeGroup>
      ```bash Request theme={"system"}
      curl "https://api.baseten.co/v1/models/{model_id}/environments/production/metrics" \
        -H "Authorization: Bearer $BASETEN_API_KEY"
      ```

      ```json Response theme={"system"}
      {
        "start_epoch_millis": 1783968056212,
        "end_epoch_millis": 1783968056212,
        "mode": "CURRENT",
        "metric_descriptors": [
          {
            "name": "baseten_replicas_active",
            "unit_hint": "COUNT",
            "kind": "GAUGE",
            "label_sets": [{}]
          },
          ...
        ],
        "metric_values": [
          {
            "start_epoch_millis": 1783968056212,
            "values": [[1.0]]
          }
        ]
      }
      ```
    </CodeGroup>

    Both endpoints take the same windows and modes as their deployment
    counterparts.
  </Tab>
</Tabs>

For more information, see
[`environment logs`](/reference/cli/baseten/model-environment#logs) and
[`environment metrics`](/reference/cli/baseten/model-environment#metrics),
and the
[environment logs](/reference/management-api/environments/get-environment-logs)
and [environment metrics](/reference/management-api/environments/get-environment-metrics)
(beta) endpoints.

## Next steps

Logs and metrics are the read half of every management workflow: check them
before and after a mutation.

* [Terminate a stuck replica](/troubleshooting/deployments#issue-a-single-replica-is-stuck-or-unhealthy)
  you found misbehaving in the logs.
* [Scale a deployment](/deployment/manage/scaling) if metrics show sustained
  queueing or idle replicas.
* [Metrics](/observability/metrics) for dashboards and metric definitions.
