

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# Lambda Web 函數的系統日誌事件結構描述
<a name="web-functions-logging-system-log-schema"></a>

Lambda 會將下列系統事件寫入 Web 函數的日誌群組。每個事件都是 JSON 物件，其中包含中所述的信封欄位，[事件信封](#web-functions-logging-system-log-schema-envelope)以及欄位取決於事件類型的`record`物件。每個事件的層級會決定 Lambda 是否交付它。如需詳細資訊，請參閱[系統日誌](web-functions-logging.md#web-functions-logging-system-logs)。


| 事件類型 | 記錄物件 | 說明 | 
| --- | --- | --- | 
| platform.initStart | PlatformInitStart | 環境初始化已開始。 | 
| platform.initReport | PlatformInitReport | 環境初始化的報告，無論是成功還是失敗。 | 
| platform.invokeStart | PlatformInvokeStart | 環境開始處理請求。 | 
| platform.requestComplete | PlatformRequestComplete | 一個 HTTP 請求已完成。僅在 DEBUG 記錄。 | 
| platform.invokeSummary | PlatformInvokeSummary | 環境活動摘要，大約每 60 秒發出一次。 | 
| platform.invokeReport | PlatformInvokeReport | 環境整個服務期間的報告，會在停止服務時發出。 | 
| platform.spinDownStart | PlatformSpinDownStart | 環境關閉已開始。 | 
| platform.spinDownReport | PlatformSpinDownReport | 環境關閉的報告。 | 
| platform.logsDropped | PlatformLogsDropped | 日誌記錄遭到捨棄，因為日誌的產生速度超過交付速度。 | 

在此頁面上的欄位清單中，欄位名稱後面的問號 (`?`) 表示欄位可能不存在。不是 JSON 類型的類型，例如 `InitType`、 `Status`或 `InvokeSummaryMetrics`，是在 中定義[共用物件類型](#web-functions-logging-system-log-schema-types)，每個類型都會連結至其定義。

## `platform.initStart`
<a name="web-functions-logging-system-log-schema-initstart"></a>

環境初始化階段已開始。

關卡： `INFO`

`record` 物件包含以下欄位：
+ `functionName` (`String`) – 函數的名稱。
+ `revisionId` (`String`) – 環境執行的修訂。
+ `instanceId` (`String`) – 執行環境的識別符。
+ `initializationType` ([`InitType`](#web-functions-logging-system-log-schema-inittype)) – Lambda 如何初始化環境。
+ `runtimeVersion` (`String`) – 環境執行的執行時間版本。
+ `runtimeVersionArn` (`String`) – 執行時間版本的 Amazon Resource Name (ARN)。

```
{
  "timestamp": "2026-09-25T11:12:30.893Z",
  "level": "INFO",
  "type": "platform.initStart",
  "region": "us-east-1",
  "record": {
    "runtimeVersion": "nodejs24.x:nodejs.web24.v51",
    "runtimeVersionArn": "arn:aws:lambda:us-east-1::runtime/nodejs24.x/version/nodejs.web24.v51",
    "functionName": "my-web-app",
    "revisionId": "rev-fs0fq",
    "instanceId": "52754708-44f1-407a-a1fd-6d2a98175a45",
    "initializationType": "native-http"
  }
}
```

## `platform.initReport`
<a name="web-functions-logging-system-log-schema-initreport"></a>

初始化階段的整體報告。

層級：狀態成功`INFO`時、失敗`WARN`時。

`record` 物件包含以下欄位：
+ `status` ([`Status`](#web-functions-logging-system-log-schema-status)) – 初始化階段的結果。
+ `errorType?` (`String`) – 當狀態失敗時出現。值，例如 `Runtime.ImportCodeError`、 `Application.InitCodeError`和 `Runtime.InitTimeout`。
+ `initializationType` ([`InitType`](#web-functions-logging-system-log-schema-inittype)) – Lambda 如何初始化環境。
+ `metrics` ([`InitReportMetrics`](#web-functions-logging-system-log-schema-initreportmetrics)) – 初始化階段的指標。

成功範例：

```
{
  "timestamp": "2026-09-25T11:12:31.143Z",
  "level": "INFO",
  "type": "platform.initReport",
  "region": "us-east-1",
  "record": {
    "status": "success",
    "initializationType": "native-http",
    "metrics": {
      "totalDurationMs": 304.000,
      "totalCpuTimeMs": 143.000,
      "maxMemoryUsageMb": 142
    }
  }
}
```

失敗範例，其中處理常式模組無法載入：

```
{
  "timestamp": "2026-09-25T11:16:04.164Z",
  "level": "WARN",
  "type": "platform.initReport",
  "region": "us-east-1",
  "record": {
    "status": "failure",
    "errorType": "Runtime.ImportCodeError",
    "initializationType": "native-http",
    "metrics": {
      "totalDurationMs": 320.000,
      "totalCpuTimeMs": 137.000,
      "maxMemoryUsageMb": 138
    }
  }
}
```

## `platform.invokeStart`
<a name="web-functions-logging-system-log-schema-invokestart"></a>

環境已完成初始化並開始處理請求。Lambda 在每個環境發出此事件一次，而不是每個請求一次，而且只有在初始化成功時。

關卡： `INFO`

`record` 物件包含以下欄位：
+ `functionName` (`String`) – 函數的名稱。
+ `revisionId` (`String`) – 環境執行的修訂。
+ `instanceId` (`String`) – 執行環境的識別符。

```
{
  "timestamp": "2026-09-25T11:12:31.144Z",
  "level": "INFO",
  "type": "platform.invokeStart",
  "region": "us-east-1",
  "record": {
    "functionName": "my-web-app",
    "revisionId": "rev-fs0fq",
    "instanceId": "52754708-44f1-407a-a1fd-6d2a98175a45"
  }
}
```

## `platform.requestComplete`
<a name="web-functions-logging-system-log-schema-requestcomplete"></a>

一個 HTTP 請求完成，是否成功。

層級：`DEBUG`，因此 Lambda 只會在 `systemLogLevel`為 時交付`DEBUG`。

`record` 物件包含以下欄位：
+ `requestId` (`String`) – 請求 ID。
+ `endpointName` (`String`) – 提供請求的端點。
+ `result` (`Integer`) – 傳回用戶端的 HTTP 狀態碼。
+ `errorType?` (`String`) – 當 Lambda 失敗請求時出現。值，例如 `Runtime.RequestTimeout`和 `Platform.InvalidRequest`。
+ `metrics` ([`RequestCompleteMetrics`](#web-functions-logging-system-log-schema-requestcompletemetrics)) – 請求的指標。

成功範例：

```
{
  "timestamp": "2026-09-25T11:12:31.154Z",
  "level": "DEBUG",
  "type": "platform.requestComplete",
  "region": "us-east-1",
  "record": {
    "requestId": "KXH25FBDZ33GP4TQ4ARAUYSTSA",
    "endpointName": "default",
    "result": 200,
    "metrics": {
      "durationMs": 4.484,
      "responseBytes": 40
    }
  }
}
```

逾時範例：

```
{
  "timestamp": "2026-09-25T11:12:34.926Z",
  "level": "DEBUG",
  "type": "platform.requestComplete",
  "region": "us-east-1",
  "record": {
    "requestId": "5SXHGVX2GD64ND6NQVEBAY235Q",
    "endpointName": "default",
    "result": 504,
    "errorType": "Runtime.RequestTimeout",
    "metrics": {
      "durationMs": 3001.229,
      "responseBytes": 0
    }
  }
}
```

## `platform.invokeSummary`
<a name="web-functions-logging-system-log-schema-invokesummary"></a>

總結環境活動約 60 秒的一個時段。Lambda 會為每個即時環境發出它，包括閒置時段，其中 `requests`為 0。

關卡： `INFO`

`record` 物件包含以下欄位：
+ `startTime` (`String`) – 摘要時段的開始 (RFC 3339)。
+ `instanceId` (`String`) – 執行環境的識別符。
+ `metrics` ([`InvokeSummaryMetrics`](#web-functions-logging-system-log-schema-invokesummarymetrics)) – 視窗的指標。

```
{
  "timestamp": "2026-09-25T11:13:31.143Z",
  "level": "INFO",
  "type": "platform.invokeSummary",
  "region": "us-east-1",
  "record": {
    "startTime": "2026-09-25T11:12:31.144547426Z",
    "instanceId": "52754708-44f1-407a-a1fd-6d2a98175a45",
    "metrics": {
      "requests": 4,
      "concurrentRequests": 1,
      "cpuTimeMs": 420.000,
      "maxMemoryUsageMb": 154
    }
  }
}
```

## `platform.invokeReport`
<a name="web-functions-logging-system-log-schema-invokereport"></a>

環境服務期間的整體報告，從 invokeStart 到停止服務為止。Lambda 會在關閉時在每個環境發出一次。

層級：狀態成功`INFO`時、失敗`WARN`時。

`record` 物件包含以下欄位：
+ `status` ([`Status`](#web-functions-logging-system-log-schema-status)) – 服務期間的結果。
+ `errorType?` (`String`) – 當狀態失敗時出現。值，例如 `Runtime.Exit`、 `Runtime.ExitError`和 `Runtime.OutOfMemory`。
+ `instanceId` (`String`) – 執行環境的識別符。
+ `metrics` ([`InvokeReportMetrics`](#web-functions-logging-system-log-schema-invokereportmetrics)) – 服務期間的指標。

請求逾時不會使服務期間失敗。會`status`保留 `success`。

成功範例：

```
{
  "timestamp": "2026-09-25T11:19:11.858Z",
  "level": "INFO",
  "type": "platform.invokeReport",
  "region": "us-east-1",
  "record": {
    "status": "success",
    "instanceId": "52754708-44f1-407a-a1fd-6d2a98175a45",
    "metrics": {
      "totalCpuTimeMs": 973.000,
      "totalDurationMs": 400723.000,
      "totalRequests": 4,
      "concurrentRequests": 1,
      "maxMemoryUsageMb": 157
    }
  }
}
```

失敗範例：

```
{
  "timestamp": "2026-09-25T11:19:11.858Z",
  "level": "WARN",
  "type": "platform.invokeReport",
  "region": "us-east-1",
  "record": {
    "status": "failure",
    "errorType": "Runtime.OutOfMemory",
    "instanceId": "52754708-44f1-407a-a1fd-6d2a98175a45",
    "metrics": {
      "totalCpuTimeMs": 973.000,
      "totalDurationMs": 400723.000,
      "totalRequests": 4,
      "concurrentRequests": 1,
      "maxMemoryUsageMb": 512
    }
  }
}
```

## `platform.spinDownStart`
<a name="web-functions-logging-system-log-schema-spindownstart"></a>

環境關閉已開始。

關卡： `INFO`

`record` 物件包含以下欄位：
+ `functionName` (`String`) – 函數的名稱。
+ `revisionId` (`String`) – 環境執行的修訂。
+ `instanceId` (`String`) – 執行環境的識別符。

```
{
  "timestamp": "2026-09-25T11:19:11.858Z",
  "level": "INFO",
  "type": "platform.spinDownStart",
  "region": "us-east-1",
  "record": {
    "functionName": "my-web-app",
    "revisionId": "rev-fs0fq",
    "instanceId": "52754708-44f1-407a-a1fd-6d2a98175a45"
  }
}
```

## `platform.spinDownReport`
<a name="web-functions-logging-system-log-schema-spindownreport"></a>

關機的整體報告。

Lambda 會`SIGTERM`傳送到您的應用程式，並等待最多 1 秒讓它結束。如果應用程式仍在執行中，Lambda 會使用 將其停止，`SIGKILL`並報告錯誤類型為 的失敗`Runtime.SpinDownTimeout`。

層級：狀態成功`INFO`時、失敗`WARN`時。

`record` 物件包含以下欄位：
+ `status` ([`Status`](#web-functions-logging-system-log-schema-status)) – 關機階段的結果。
+ `errorType?` (`String`) – 當狀態失敗時出現。值，例如 `Runtime.SpinDownTimeout`和 `Runtime.ExitError`。
+ `metrics` ([`SpinDownReportMetrics`](#web-functions-logging-system-log-schema-spindownreportmetrics)) – 關機階段的指標。

成功範例：

```
{
  "timestamp": "2026-09-25T11:19:11.879Z",
  "level": "INFO",
  "type": "platform.spinDownReport",
  "region": "us-east-1",
  "record": {
    "status": "success",
    "metrics": {
      "totalDurationMs": 21.000,
      "totalCpuTimeMs": 8.000,
      "maxMemoryUsageMb": 157
    }
  }
}
```

失敗範例：

```
{
  "timestamp": "2026-09-25T11:19:12.879Z",
  "level": "WARN",
  "type": "platform.spinDownReport",
  "region": "us-east-1",
  "record": {
    "status": "failure",
    "errorType": "Runtime.SpinDownTimeout",
    "metrics": {
      "totalDurationMs": 1021.000,
      "totalCpuTimeMs": 8.000,
      "maxMemoryUsageMb": 157
    }
  }
}
```

## `platform.logsDropped`
<a name="web-functions-logging-system-log-schema-logsdropped"></a>

日誌記錄遭到捨棄，因為日誌的產生速度超過交付速度。

關卡： `WARN`

`record` 物件包含以下欄位：
+ `reason` (`String`) – 為何捨棄記錄。
+ `droppedRecords` (`Integer`) – 自上次交付記錄以來的記錄遭到捨棄。
+ `droppedBytes` (`Integer`) – 自上次交付記錄以來捨棄的位元組。

這兩個計數會累積到連續的捨棄，並在傳送記錄後重設為 0。

```
{
  "timestamp": "2026-09-25T11:20:00.000Z",
  "level": "WARN",
  "type": "platform.logsDropped",
  "region": "us-east-1",
  "record": {
    "reason": "Some logs were dropped because the downstream consumer is slower than the logs production rate",
    "droppedRecords": 120,
    "droppedBytes": 48000
  }
}
```

## 共用物件類型
<a name="web-functions-logging-system-log-schema-types"></a>

下列類型會出現在此頁面事件的欄位清單中。

### 事件信封
<a name="web-functions-logging-system-log-schema-envelope"></a>

每個系統事件都有下列信封欄位：
+ `timestamp` (`String`) – UTC 中的 RFC 3339。
+ `level` (`Level`) – 事件的層級。
+ `type` (`String`) – 事件類型 (`platform.*`)。
+ `region` (`String`) – 執行環境執行的區域。
+ `record` (`Object`) – 事件特定的欄位。

### `InitType`
<a name="web-functions-logging-system-log-schema-inittype"></a>

描述 Lambda 如何初始化環境的字串列舉。Web 函數一律使用 `native-http`。

### `Level`
<a name="web-functions-logging-system-log-schema-level"></a>

系統事件層級的字串列舉：`INFO`、 `DEBUG`或 `WARN`。系統事件絕不是 `ERROR`或 `FATAL`。當`INFO`狀態為成功且失敗`WARN`時，報告事件即為 。

### `Status`
<a name="web-functions-logging-system-log-schema-status"></a>

描述階段結果的字串列舉： `success`或 `failure`。當它是 時`failure`，記錄也包含 `errorType`。

### `InitReportMetrics`
<a name="web-functions-logging-system-log-schema-initreportmetrics"></a>
+ `totalDurationMs` (`Double`) – 初始化階段的時鐘時間。
+ `totalCpuTimeMs` (`Double`) – 初始化期間耗用的 CPU 時間。
+ `maxMemoryUsageMb` (`Integer`) – 環境的峰值記憶體，以 MiB 為單位。

### `RequestCompleteMetrics`
<a name="web-functions-logging-system-log-schema-requestcompletemetrics"></a>
+ `durationMs` (`Double`) – 請求的時鐘時間。
+ `responseBytes` (`Integer`) – 傳送的回應內文位元組。

### `InvokeSummaryMetrics`
<a name="web-functions-logging-system-log-schema-invokesummarymetrics"></a>
+ `requests` (`Integer`) – 在視窗中完成的請求。
+ `concurrentRequests` (`Integer`) – 視窗中的並行請求上限。
+ `cpuTimeMs` (`Double`) – 視窗中耗用的 CPU 時間。
+ `maxMemoryUsageMb` (`Integer`) – 環境的峰值記憶體，以 MiB 為單位。

### `InvokeReportMetrics`
<a name="web-functions-logging-system-log-schema-invokereportmetrics"></a>
+ `totalCpuTimeMs` (`Double`) – 服務期間的 CPU 時間。
+ `totalDurationMs` (`Double`) – 從 invokeStart 到環境停止提供服務的時鐘時間。
+ `totalRequests` (`Integer`) – 已服務的請求總數。
+ `concurrentRequests` (`Integer`) – 期間內並行請求上限。
+ `maxMemoryUsageMb` (`Integer`) – 環境的峰值記憶體，以 MiB 為單位。

### `SpinDownReportMetrics`
<a name="web-functions-logging-system-log-schema-spindownreportmetrics"></a>
+ `totalDurationMs` (`Double`) – 關機階段的時鐘時間。
+ `totalCpuTimeMs` (`Double`) – 關機期間耗用的 CPU 時間。
+ `maxMemoryUsageMb` (`Integer`) – 環境的峰值記憶體，以 MiB 為單位。