

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# 检索 PCUI 和 AWS ParallelCluster 运行时日志
<a name="troubleshooting-v3-get-runtime-logs"></a>

了解如何检索 PCUI 和 AWS ParallelCluster 运行时日志以进行故障排除。首先，找到相关的 PCUI 和 AWS ParallelCluster 堆栈名称。使用堆栈名称找到安装日志组。最后，导出日志。这些日志特定于 AWS ParallelCluster 运行时系统。有关集群日志，请参阅[检索和保留日志](troubleshooting-v3-get-logs.md)。

**先决条件**
+  AWS CLI 已安装。
+ 您拥有在 PCUI 开启 AWS 账户 的上运行 AWS CLI 命令的凭据。
+ 您可以在 PCUI 处于开启状态 AWS 账户 的上访问亚马逊 CloudWatch 控制台。

## 步骤 1：找到相关堆栈的堆栈名称
<a name="pcui-install-logs-v3-step-1"></a>

在以下示例中，将红色突出显示的文本替换为实际值。

使用安装 PCUI 的 AWS 区域 位置列出堆栈：

```
$ aws cloudformation list-stacks --region aws-region-id
```

请注意以下堆栈的堆栈名称：
+ 在您的账户中部署 PCUI 的堆栈的名称。您在安装 PCUI 时输入了该名称；例如 `pcluster-ui`。
+ 以您输入的 AWS ParallelCluster 堆栈名称为前缀的堆栈；例如，`pcluster-ui-ParallelClusterApi-ABCD1234EFGH`。

## 步骤 2：找到日志组
<a name="pcui-install-logs-v3-step-2"></a>

列出 PCUI 堆栈的日志组，如以下示例所示：

```
$ aws cloudformation describe-stack-resources \
   --region aws-region-id \
   --stack-name pcluster-ui \
   --query "StackResources[?ResourceType == 'AWS::Logs::LogGroup' && (LogicalResourceId == 'ApiGatewayAccessLog' || LogicalResourceId == 'ParallelClusterUILambdaLogGroup')].PhysicalResourceId" \
   --output text
```

列出 AWS ParallelCluster API 堆栈的日志组，如以下示例所示：

```
$ aws cloudformation describe-stack-resources \
   --region aws-region-id \
   --stack-name pcluster-ui-ParallelCluster-Api-ABCD1234EFGH \
   --query "StackResources[?ResourceType == 'AWS::Logs::LogGroup' && LogicalResourceId == 'ParallelClusterFunctionLogGroup'].PhysicalResourceId" \
   --output text
```

记下日志组列表，以便在下一个步骤中使用。

## 步骤 3：导出日志
<a name="pcui-install-logs-v3-step-3"></a>

使用以下步骤收集并导出日志：

1. 登录 AWS 管理控制台，然后在 PCUI 已开启的上导航到 [Amazon CloudWatch](https://console.aws.amazon.com/cloudwatch/) 控制台。 AWS 账户 

1. 在导航窗格上，依次选择**日志**和 **日志见解**。

1. 选择上一步中列出的所有日志组。

1. 选择时间范围，例如 12 小时。

1. 运行以下查询：

   ```
   $ fields @timestamp, @message
   | sort @timestamp desc
   | limit 10000
   ```

1. 选择**导出结果**、**下载表 (JSON)**。