如何查看 Google 云计算引擎日志

How to see Google Cloud Compute Engine Logs

如何查看有关在 Google Cloud Compute Engine 上创建的 VM 的日志?

Google 操作日志记录(以前称为 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 云控制台的示例 - 旧版日志查看器

  • 转到https://console.cloud.google.com/logs/viewer

  • 验证所需的 Google Cloud 项目是否显示在标题区域。

  • 在显示文本“按标签或文本搜索过滤”的框中,单击下拉菜单和select“转换为高级过滤器”。

  • 在显示文本“按标签过滤或文本搜索”的框中输入以下内容(作为过滤框中的两行):

    resource.type="gce_instance"

    protoPayload.methodName="v1.compute.instances.insert"

  • Select“最后一小时”框中所需的日期搜索范围

  • 单击“提交过滤器”按钮