如何查看GoogleCloudComputeEngine日志
如何查看有关已在 Google Cloud Compute Engine 上创建的 VM 的日志?
回答
Google Operations Logging(以前称为 Stackdriver)提供了这些信息。
要查看在项目中创建的 Google Compute Engine 实例的详细信息,请根据 API 操作v1.compute.instances.insert和资源类型进行过滤resource.type=gce_instance。
注意:资源类型并不总是必需的,但最好在日志记录应该搜索的内容中声明。
使用 CLI 的示例:
gcloud logging read "resource.type=gce_instance protoPayload.methodName=v1.compute.instances.insert" --format json
使用 Google Cloud Console 的示例 - 旧版日志查看器
-
转到https://console.cloud.google.com/logs/viewer
-
验证所需的 GCP 项目是否显示在标题区域中。
-
在显示文本“按标签或文本搜索过滤”的框中,单击下拉菜单并选择“转换为高级过滤器”。
-
在显示文本“按标签或文本搜索过滤”的框中输入以下内容(作为过滤器框中的两行):
resource.type="gce_instance"
protoPayload.methodName="v1.compute.instances.insert"
-
在“最后一小时”框中选择所需的日期搜索范围
-
单击“提交过滤器”按钮