使用平台日志

本页面介绍如何使用 Cloud Logging 中由 AML AI 生成的平台日志。AML AI 使用 Logging API 服务名称 financialservices.googleapis.com 来记录以下活动:

  • 创建引擎配置(调整)
  • 模型创建(训练)
  • 回测操作
  • 预测操作

准备工作

如需查看和管理日志,请确保您拥有正确的 IAM 权限和角色

平台日志记录激活状态

AML AI 的平台日志始终处于活动状态(无法关闭)。

日志严重性

AML AI 日志条目使用三个严重级别:

  • NOTICE(适用于在操作开始或成功时发送的条目)
  • ERROR(适用于有关失败操作结束的条目)
  • INFO(适用于有关操作进度的条目)

查看平台日志

如需查看平台日志,请按照以下说明操作:

控制台

如需在 Google Cloud 控制台中查看平台日志,请执行以下操作:

  1. 导航到日志浏览器:

    前往日志浏览器

  2. 选择相应的 Google Cloud 项目。

  3. 查询字段中,输入以下查询命令:

    logName=("projects/PROJECT_ID/logs/financialservices.googleapis.com%2Fbacktest" OR
    "projects/PROJECT_ID/logs/financialservices.googleapis.com%2Fengine_config_creation" OR
    "projects/PROJECT_ID/logs/financialservices.googleapis.com%2Fmodel_creation" OR
    "projects/PROJECT_ID/logs/financialservices.googleapis.com%2Fprediction")
    

    其中:

    PROJECT_ID 是您要调试或监控的项目的 ID。例如 my-project

  4. 点击运行查询

如需详细了解日志浏览器,请参阅日志浏览器概览使用日志浏览器

gcloud

gcloud 命令行工具提供了用于 Cloud Logging 的命令行界面。

如需查看项目的日志,请运行以下命令:

gcloud logging read 'logName=("projects/PROJECT_ID/logs/financialservices.googleapis.com%2Fbacktest" OR
"projects/PROJECT_ID/logs/financialservices.googleapis.com%2Fengine_config_creation" OR
"projects/PROJECT_ID/logs/financialservices.googleapis.com%2Fmodel_creation" OR
"projects/PROJECT_ID/logs/financialservices.googleapis.com%2Fprediction")' --project=PROJECT_ID

其中 PROJECT_ID 是您的 Google Cloud 项目的 ID。

如需详细了解如何将 gcloud 工具与 Cloud Logging 搭配使用,请参阅 gcloud logging

了解平台日志

本部分介绍如何理解 AML AI 的特定平台日志。

START 日志

操作开始执行时,系统会生成包含 eventKind=START 的日志。

以下是启动预测运行的日志示例。

jsonPayload:
  '@type': type.googleapis.com/google.cloud.financialservices.logging.v1.PredictionLog
  engineVersion: projects/PROJECT_ID/locations/REGION_ID/instances/INSTANCE_ID/engineVersions/ENGINE_VERSION_ID
  eventKind: START
  predictionResult:
    dataset: projects/PROJECT_ID/locations/REGION_ID/instances/INSTANCE_ID/datasets/DATASET_ID
    endTime: '2023-05-31T00:00:00Z'
    model: projects/PROJECT_ID/locations/REGION_ID/instances/INSTANCE_ID/models/MODEL_ID
    outputs:
      explainabilityDestination:
        tableUri: bq://PROJECT_ID.DATASET_ID.EXPLAINABILITY_TABLE_ID
        writeDisposition: WRITE_EMPTY
      predictionDestination:
        tableUri: bq://PROJECT_ID.DATASET_ID.PREDICTION_TABLE_ID
        writeDisposition: WRITE_EMPTY
logName: projects/PROJECT_ID/logs/financialservices.googleapis.com%2Fprediction
operation:
  first: true
  id: projects/PROJECT_NUMBER/locations/REGION_ID/operations/OPERATION_ID
  producer: financialservices.googleapis.com
receiveTimestamp: '2023-06-07T12:30:48.417285528Z'
resource:
  labels:
    instance_id: INSTANCE_ID
    location: REGION_ID
    prediction_result_id: PREDICTION_ID
    resource_container: projects/PROJECT_NUMBER
  type: financialservices.googleapis.com/PredictionResult

您可以在日志浏览器查询字段中添加其他命令,以缩小显示的日志范围。

添加以下命令,以显示所选数据集上已启动的所有预测运行:

logName="projects/PROJECT_ID/logs/financialservices.googleapis.com%2Fprediction" AND
jsonPayload.predictionResult.dataset="projects/PROJECT_ID/locations/REGION_ID/instances/INSTANCE_ID/datasets/DATASET_ID" AND
jsonPayload.eventKind="START"

PROGRESS 日志

包含 eventKind=PROGRESS 的日志用于告知操作的进度。

下面是一个关于创建模型的日志示例。completedTaskCounttaskCount 可用于估算模型训练的进度。

jsonPayload:
  '@type': type.googleapis.com/google.cloud.financialservices.logging.v1.ModelCreationLog
  completedTaskCount: 11
  engineVersion: projects/PROJECT_ID/locations/REGION_ID/instances/INSTANCE_ID/engineVersions/ENGINE_VERSION_ID
  eventKind: PROGRESS
  model:
    endTime: '2023-05-31T00:00:00Z'
    engineConfig: projects/PROJECT_ID/locations/REGION_ID/instances/INSTANCE_ID/engineConfigs/ENGINE_CONFIG_ID
    engineVersion: projects/PROJECT_ID/locations/REGION_ID/instances/INSTANCE_ID/engineVersions/ENGINE_VERSION_ID
    lineOfBusiness: RETAIL
    primaryDataset: projects/PROJECT_ID/locations/REGION_ID/instances/INSTANCE_ID/datasets/DATASET_ID
    state: CREATING
  partyCount: '9246'
  taskCount: 16
logName: projects/PROJECT_ID/logs/financialservices.googleapis.com%2Fmodel_creation
operation:
  id: projects/PROJECT_NUMBER/locations/REGION_ID/operations/OPERATION_ID
  producer: financialservices.googleapis.com
receiveTimestamp: '2023-06-07T13:57:00.454668648Z'
resource:
  labels:
    instance_id: INSTANCE_ID
    location: REGION_ID
    model_id: MODEL_ID
    resource_container: projects/PROJECT_NUMBER
  type: financialservices.googleapis.com/Model
severity: INFO
timestamp: '2023-06-07T13:56:59.772973055Z'

END 日志

操作结束时,会生成具有 eventKind=END 的日志。

以下是引擎配置创建失败的日志示例。 它包含与提供的数据集中错误数据相关的错误。

jsonPayload:
  '@type': type.googleapis.com/google.cloud.financialservices.logging.v1.EngineConfigCreationLog
  completedTaskCount: 3
  engineConfig:
    engineVersion: projects/PROJECT_ID/locations/REGION_ID/instances/INSTANCE_ID/engineVersions/ENGINE_VERSION_ID
    lineOfBusiness: RETAIL
    performanceTarget:
      partyInvestigationsPerPeriodHint: '100'
    state: CREATING
    tuning:
      endTime: '2019-04-30T00:00:00Z'
      primaryDataset: projects/PROJECT_ID/locations/REGION_ID/instances/INSTANCE_ID/datasets/DATASET_ID
  eventKind: END
  operationStatus:
    code: 9
    details:
    - '@type': type.googleapis.com/google.rpc.ErrorInfo
      domain: financialservices.googleapis.com
      metadata:
        count: '15'
        data_field: party_id, validity_start_time
        data_table: party
        description: There is a duplicate primary key value in the database resulting
          in unique key violation. Note that for tables with validity_start_time,
          the primary key includes validity_start_time
        test: GROUP BY party_id, validity_start_time HAVING count(1) > 1
      reason: DUPLICATE_PRIMARY_KEY
    message: Dataset validation failed with 1 error. See error details for individual
      violations.
  partyCount: '9246'
  taskCount: 16
logName: projects/PROJECT_ID/logs/financialservices.googleapis.com%2Fengine_config_creation
operation:
  id: projects/PROJECT_NUMBER/locations/REGION_ID/operations/OPERATION_ID
  last: true
  producer: financialservices.googleapis.com
receiveTimestamp: '2023-06-07T14:26:30.214382295Z'
resource:
  labels:
    engine_config_id: ENGINE_CONFIG_ID
    instance_id: INSTANCE_ID
    location: REGION_ID
    resource_container: projects/PROJECT_NUMBER
  type: financialservices.googleapis.com/EngineConfig
severity: ERROR
timestamp: '2023-06-07T14:26:29.670913895Z'

如需查看所有“创建引擎配置”错误日志,请使用以下过滤条件:

logName="projects/PROJECT_ID/logs/financialservices.googleapis.com%2Fengine_config_creation" AND
severity>=ERROR