查看执行步骤的历史记录

您可以以步骤条目列表的形式检索指定工作流执行的历史记录。每个步骤条目都提供的信息可帮助您分析、调试或优化工作流。例如,您可以确认实际执行了哪些步骤,并确定步骤的持续时间和成功情况。在调试大型或复杂的非线性工作流(例如包含许多并行分支的工作流)时,这特别有用。

步骤条目表示源代码中的实际步骤(例如 assigncall)或指令块(例如 for 循环或 try/retry/except 块)。如需查看步数类型的完整列表,请参阅 StepType

如何检索步骤条目

您可以通过向 Workflow Executions REST API 发送请求或通过 Google Cloud 控制台检索步骤条目:

  • Google Cloud 控制台 - 请参阅本文档中的在控制台中查看步骤条目

    除了列出步骤条目及其详细信息之外,控制台还会以图形方式显示执行步骤,以便您更轻松地查看和分析工作流执行路径。

  • Workflow Executions REST API:请参阅本文档中的检索步骤条目列出步骤条目

步骤条目信息

步骤条目包含以下信息。如需了解详情,请参阅本文档中的示例

名称 步骤条目的完整资源名称,它是采用以下格式的唯一 ID,其中 STEPENTRY_ID 是递增计数器:
projects/PROJECT_NUMBER/locations/LOCATION/workflows/WORKFLOW_ID/executions/EXECUTION_ID/stepEntries/STEPENTRY_ID
例如:
projects/123456789012/locations/us-central1/workflows/myFirstWorkflow/executions/ae8a66a1-cefa-4d16-8a2f-d50c712d8ef1/stepEntries/2
创建和更新时间 步骤条目的创建时间和最近一次更新的时间戳。如果步骤条目已完成,updateTime 会指示完成时间。
日常安排和步骤名称 步骤条目所属的例程和步骤的名称。例程名称是指在 YAML 或 JSON 源代码中定义的子工作流名称。顶级例程名称为 main
状态和进度类型 步骤条目的状态,例如,条目是成功还是失败,或者步骤条目是否正在进行以及进度类型。如需查看状态和进度类型的完整列表,请参阅 StateProgressType
导航信息 步骤条目的位置,以便您更好地了解工作流的层次结构和流程,例如,当前步骤条目前面或后面是哪些步骤条目,或者哪些是步骤条目的父级或子级。如需了解详情,请参阅 NavigationInfo
元数据 与迭代步骤条目相关的数据,包括指示子线程的 ID(例如 STEP_PARALLEL_BRANCH 中的哪个 STEP_PARALLEL_BRANCH_ENTRY)或 for 循环的迭代次数(例如 STEP_FOR 中的哪个 STEP_FOR_ITERATION)。如需了解详情,请参阅 StepEntryMetadata
例外情况 与任何异常相关的载荷,其中说明了步骤条目失败的原因。

在控制台中查看步骤条目

您可以在 Google Cloud 控制台中查看特定工作流执行的步骤条目。

  1. 在 Google Cloud 控制台中,进入 Workflows 页面:

    进入 Workflows

  2. 点击相应工作流的名称,前往其工作流详情页面。

  3. 如需详细了解特定执行,请点击其执行 ID。

    摘要标签页上会提供有关整体执行的信息,包括导致执行失败的任何异常。如需了解详情,请参阅执行错误映射

  4. 如需将工作流执行记录视为步骤条目列表进行查看,请点击步骤标签页。

    系统会列出工作流执行的所有步骤条目。

  5. 如需过滤步骤条目,请使用表格顶部的过滤条件字段选择一个属性和一个值,例如 State: Failed

  6. 如需显示任何父级子级下一步上一步步骤条目的链接,请点击相应步骤条目。

    如果您点击某个链接,其他链接会自动更新。例如,父级将链接到您点击的步骤条目的父级。

  7. 可视化面板以图形方式显示工作流中的步骤,并帮助您了解工作流路径。

    可视化面板示例

    点击图表可将其放大

    显示包含失败步骤的工作流的可视化面板

    请注意,可视化结果可能与步骤条目不同。例如,for 块在可视化中显示为单个组件;但是,根据迭代次数,可能有多个步骤条目。

    您可以在该面板中执行以下操作:

    • 放大或缩小可视化图表
    • 收起或展开父级步骤条目
    • 点击某个步骤条目,查看其前后条目
    • 确认成功和失败的步骤条目,以绿色对勾标记或红色感叹号表示
    • 点击 展开箭头关闭可视化面板;再次点击该箭头可打开该面板

检索步数条目之前

如需获得检索步骤条目所需的权限,请让您的管理员为您授予项目的 Workflows Admin (workflows.stepEntries.get) IAM 角色。 如需详细了解如何授予角色,请参阅管理对项目、文件夹和组织的访问权限

您也可以通过自定义角色或其他预定义角色来获取所需的权限。

检索步骤条目

如需检索给定工作流执行的步骤条目,请使用 projects.locations.workflows.executions.stepEntries.get 方法。

在使用任何请求数据之前,请先进行以下替换:

  • PROJECT_NUMBERIAM 和管理设置页面中列出的 Google Cloud 项目编号。
  • LOCATION:在其中部署此工作流的区域,例如 us-central1
  • WORKFLOW_ID:工作流的用户定义名称,例如 myFirstWorkflow
  • EXECUTION_ID:工作流执行的唯一 ID,在工作流执行后返回。
  • STEPENTRY_ID:步骤条目的唯一 ID,例如 1

如需发送您的请求,请展开以下选项之一:

您应该收到类似以下内容的 JSON 响应:

{
  "name": "projects/PROJECT_NUMBER/locations/LOCATION/workflows/WORKFLOW_ID/executions/EXECUTION_ID/stepEntries/STEPENTRY_ID",
  "createTime": "2023-10-19T13:49:56.522717646Z",
  "updateTime": "2023-10-19T13:49:56.525439354Z",
  "routine": "main",
  "step": "checkSearchTermInInput",
  "stepType": "STEP_CONDITION",
  "state": "STATE_SUCCEEDED",
  "entryId": "2",
  "navigationInfo": {
    "children": [
      "3"
    ],
    "parent": "1",
    "next": "3",
    "previous": "1"
  }
}

列出步骤条目之前

如需获得列出步骤条目所需的权限,请让您的管理员为您授予项目的 Workflows Admin (workflows.stepEntries.list) IAM 角色。 如需详细了解如何授予角色,请参阅管理对项目、文件夹和组织的访问权限

您也可以通过自定义角色或其他预定义角色来获取所需的权限。

列出步骤条目

如需列出给定工作流执行的步骤条目,请使用 projects.locations.workflows.executions.stepEntries.list 方法。默认情况下,系统会按步骤条目的 createTime 升序返回结果。

在使用任何请求数据之前,请先进行以下替换:

  • PROJECT_NUMBERIAM 和管理设置页面中列出的 Google Cloud 项目编号。
  • LOCATION:在其中部署此工作流的区域,例如 us-central1
  • WORKFLOW_ID:工作流的用户定义名称,例如 myFirstWorkflow
  • EXECUTION_ID:工作流执行的唯一 ID,在工作流执行后返回。

如需发送您的请求,请展开以下选项之一:

您应该收到类似以下内容的 JSON 响应:

{
  "stepEntries": [
    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION/workflows/WORKFLOW_ID/executions/EXECUTION_ID/stepEntries/1",
      "createTime": "2023-10-19T13:49:56.522705770Z",
      "updateTime": "2023-10-19T13:49:56.525439429Z",
      "routine": "main",
      "step": "checkSearchTermInInput",
      "stepType": "STEP_SWITCH",
      "state": "STATE_SUCCEEDED",
      "entryId": "1",
      "navigationInfo": {
        "children": [
          "2"
        ],
        "next": "2"
      }
    },
    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION/workflows/WORKFLOW_ID/executions/EXECUTION_ID/stepEntries/2",
      "createTime": "2023-10-19T13:49:56.522717646Z",
      "updateTime": "2023-10-19T13:49:56.525439354Z",
      "routine": "main",
      "step": "checkSearchTermInInput",
      "stepType": "STEP_CONDITION",
      "state": "STATE_SUCCEEDED",
      "entryId": "2",
      "navigationInfo": {
        "children": [
          "3"
        ],
        "parent": "1",
        "next": "3",
        "previous": "1"
      }
    },
    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION/workflows/WORKFLOW_ID/executions/EXECUTION_ID/stepEntries/3",
      "createTime": "2023-10-19T13:49:56.525379814Z",
      "updateTime": "2023-10-19T13:49:56.525439285Z",
      "routine": "main",
      "step": "checkSearchTermInInput.condition1",
      "stepType": "STEP_ASSIGN",
      "state": "STATE_SUCCEEDED",
      "entryId": "3",
      "navigationInfo": {
        "parent": "2",
        "next": "4",
        "previous": "2"
      }
    },
    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION/workflows/WORKFLOW_ID/executions/EXECUTION_ID/stepEntries/4",
      "createTime": "2023-10-19T13:49:56.525440360Z",
      "updateTime": "2023-10-19T13:49:56.716973793Z",
      "routine": "main",
      "step": "readWikipedia",
      "stepType": "STEP_CALL",
      "state": "STATE_SUCCEEDED",
      "entryId": "4",
      "navigationInfo": {
        "next": "5",
        "previous": "3"
      }
    },
    {
      "name": "projects/PROJECT_NUMBER/locations/LOCATION/workflows/WORKFLOW_ID/executions/EXECUTION_ID/stepEntries/5",
      "createTime": "2023-10-19T13:49:56.717263008Z",
      "updateTime": "2023-10-19T13:49:56.717353199Z",
      "routine": "main",
      "step": "returnOutput",
      "stepType": "STEP_RETURN",
      "state": "STATE_SUCCEEDED",
      "entryId": "5",
      "navigationInfo": {
        "previous": "4"
      }
    }
  ],
  "totalSize": 5
}

示例

包含 for 代码块的工作流

工作流

YAML

- assignStep:
    assign:
      - sum: 0
- forStep:
    for:
      range: [1, 2]
      value: v
      steps:
        - sumStep:
            assign:
              - sum: ${sum + v}
- returnStep:
    return: ${sum}

JSON

[
  {
    "assignStep": {
      "assign": [
        {
          "sum": 0
        }
      ]
    }
  },
  {
    "forStep": {
      "for": {
        "range": [
          1,
          2
        ],
        "value": "v",
        "steps": [
          {
            "sumStep": {
              "assign": [
                {
                  "sum": "${sum + v}"
                }
              ]
            }
          }
        ]
      }
    }
  },
  {
    "returnStep": {
      "return": "${sum}"
    }
  }
]

图示

使用 for 块的工作流

步骤条目

  {
  "stepEntries": [
    {
      "name": "projects/200478149810/locations/us-central1/workflows/ck-for-block/executions/74785b43-5b9f-4adf-bde7-a9880d0e100a/stepEntries/1",
      "createTime": "2023-10-20T17:19:37.889232683Z",
      "updateTime": "2023-10-20T17:19:37.889275457Z",
      "routine": "main",
      "step": "assignStep",
      "stepType": "STEP_ASSIGN",
      "state": "STATE_SUCCEEDED",
      "entryId": "1",
      "navigationInfo": {
        "next": "2"
      }
    },
    {
      "name": "projects/200478149810/locations/us-central1/workflows/ck-for-block/executions/74785b43-5b9f-4adf-bde7-a9880d0e100a/stepEntries/2",
      "createTime": "2023-10-20T17:19:37.889276124Z",
      "updateTime": "2023-10-20T17:19:37.889474759Z",
      "routine": "main",
      "step": "forStep",
      "stepType": "STEP_FOR",
      "state": "STATE_SUCCEEDED",
      "entryId": "2",
      "navigationInfo": {
        "children": [
          "3",
          "5"
        ],
        "next": "3",
        "previous": "1"
      }
    },
    {
      "name": "projects/200478149810/locations/us-central1/workflows/ck-for-block/executions/74785b43-5b9f-4adf-bde7-a9880d0e100a/stepEntries/3",
      "createTime": "2023-10-20T17:19:37.889313107Z",
      "updateTime": "2023-10-20T17:19:37.889382353Z",
      "routine": "main",
      "step": "forStep",
      "stepType": "STEP_FOR_ITERATION",
      "state": "STATE_SUCCEEDED",
      "entryId": "3",
      "navigationInfo": {
        "children": [
          "4"
        ],
        "parent": "2",
        "next": "4",
        "previous": "2"
      },
      "stepEntryMetadata": {
        "progressType": "PROGRESS_TYPE_FOR",
        "progressNumber": "1"
      }
    },
    {
      "name": "projects/200478149810/locations/us-central1/workflows/ck-for-block/executions/74785b43-5b9f-4adf-bde7-a9880d0e100a/stepEntries/4",
      "createTime": "2023-10-20T17:19:37.889317653Z",
      "updateTime": "2023-10-20T17:19:37.889382265Z",
      "routine": "main",
      "step": "sumStep",
      "stepType": "STEP_ASSIGN",
      "state": "STATE_SUCCEEDED",
      "entryId": "4",
      "navigationInfo": {
        "parent": "3",
        "next": "5",
        "previous": "3"
      },
      "stepEntryMetadata": {
        "progressType": "PROGRESS_TYPE_FOR",
        "progressNumber": "1"
      }
    },
    {
      "name": "projects/200478149810/locations/us-central1/workflows/ck-for-block/executions/74785b43-5b9f-4adf-bde7-a9880d0e100a/stepEntries/5",
      "createTime": "2023-10-20T17:19:37.889383134Z",
      "updateTime": "2023-10-20T17:19:37.889474707Z",
      "routine": "main",
      "step": "forStep",
      "stepType": "STEP_FOR_ITERATION",
      "state": "STATE_SUCCEEDED",
      "entryId": "5",
      "navigationInfo": {
        "children": [
          "6"
        ],
        "parent": "2",
        "next": "6",
        "previous": "4"
      },
      "stepEntryMetadata": {
        "progressType": "PROGRESS_TYPE_FOR",
        "progressNumber": "2"
      }
    },
    {
      "name": "projects/200478149810/locations/us-central1/workflows/ck-for-block/executions/74785b43-5b9f-4adf-bde7-a9880d0e100a/stepEntries/6",
      "createTime": "2023-10-20T17:19:37.889384893Z",
      "updateTime": "2023-10-20T17:19:37.889474649Z",
      "routine": "main",
      "step": "sumStep",
      "stepType": "STEP_ASSIGN",
      "state": "STATE_SUCCEEDED",
      "entryId": "6",
      "navigationInfo": {
        "parent": "5",
        "next": "7",
        "previous": "5"
      },
      "stepEntryMetadata": {
        "progressType": "PROGRESS_TYPE_FOR",
        "progressNumber": "2"
      }
    },
    {
      "name": "projects/200478149810/locations/us-central1/workflows/ck-for-block/executions/74785b43-5b9f-4adf-bde7-a9880d0e100a/stepEntries/7",
      "createTime": "2023-10-20T17:19:37.889475882Z",
      "updateTime": "2023-10-20T17:19:37.889483477Z",
      "routine": "main",
      "step": "returnStep",
      "stepType": "STEP_RETURN",
      "state": "STATE_SUCCEEDED",
      "entryId": "7",
      "navigationInfo": {
        "previous": "6"
      }
    }
  ],
  "totalSize": 7
}

包含子工作流调用的协作流

工作流

YAML

main:
  steps:
    - callStep:
        call: square
        args:
          x: 10
        result: t
    - retStep:
        return: ${t}
square:
  params: [x]
  steps:
    - assignStep:
        assign:
          - y: ${x*x}
    - retStep:
        return: ${y}

JSON

{
  "main": {
    "steps": [
      {
        "callStep": {
          "call": "square",
          "args": {
            "x": 10
          },
          "result": "t"
        }
      },
      {
        "retStep": {
          "return": "${t}"
        }
      }
    ]
  },
  "square": {
    "params": [
      "x"
    ],
    "steps": [
      {
        "assignStep": {
          "assign": [
            {
              "y": "${x*x}"
            }
          ]
        }
      },
      {
        "retStep": {
          "return": "${y}"
        }
      }
    ]
  }
}

图示

包含子工作流调用的协作流

步骤条目

{
  "stepEntries": [
    {
      "name": "projects/200478149810/locations/us-central1/workflows/ck-for-block/executions/69da2159-1039-4f88-8d8a-12baf398f372/stepEntries/1",
      "createTime": "2023-10-21T15:25:55.406007695Z",
      "updateTime": "2023-10-21T15:25:55.412984492Z",
      "routine": "main",
      "step": "callStep",
      "stepType": "STEP_CALL",
      "state": "STATE_SUCCEEDED",
      "entryId": "1",
      "navigationInfo": {
        "children": [
          "2",
          "3"
        ],
        "next": "2"
      }
    },
    {
      "name": "projects/200478149810/locations/us-central1/workflows/ck-for-block/executions/69da2159-1039-4f88-8d8a-12baf398f372/stepEntries/2",
      "createTime": "2023-10-21T15:25:55.412921902Z",
      "updateTime": "2023-10-21T15:25:55.412967631Z",
      "routine": "square",
      "step": "assignStep",
      "stepType": "STEP_ASSIGN",
      "state": "STATE_SUCCEEDED",
      "entryId": "2",
      "navigationInfo": {
        "parent": "1",
        "next": "3",
        "previous": "1"
      }
    },
    {
      "name": "projects/200478149810/locations/us-central1/workflows/ck-for-block/executions/69da2159-1039-4f88-8d8a-12baf398f372/stepEntries/3",
      "createTime": "2023-10-21T15:25:55.412968712Z",
      "updateTime": "2023-10-21T15:25:55.412978913Z",
      "routine": "square",
      "step": "retStep",
      "stepType": "STEP_RETURN",
      "state": "STATE_SUCCEEDED",
      "entryId": "3",
      "navigationInfo": {
        "parent": "1",
        "next": "4",
        "previous": "2"
      }
    },
    {
      "name": "projects/200478149810/locations/us-central1/workflows/ck-for-block/executions/69da2159-1039-4f88-8d8a-12baf398f372/stepEntries/4",
      "createTime": "2023-10-21T15:25:55.412992302Z",
      "updateTime": "2023-10-21T15:25:55.412998396Z",
      "routine": "main",
      "step": "retStep",
      "stepType": "STEP_RETURN",
      "state": "STATE_SUCCEEDED",
      "entryId": "4",
      "navigationInfo": {
        "previous": "3"
      }
    }
  ],
  "totalSize": 4
}

包含失败步骤条目的工作流

工作流

YAML

- tryStep:
    try:
      return: ${1 / 0}
    except:
      return: 0

JSON

[
  {
    "tryStep": {
      "try": {
        "return": "${1 / 0}"
      },
      "except": {
        "return": 0
      }
    }
  }
]

图示

包含失败步骤条目的工作流

步骤条目

{
  "stepEntries": [
    {
      "name": "projects/200478149810/locations/us-central1/workflows/ck-for-block/executions/8ec49dae-ab0c-4b55-b1c4-b809244be913/stepEntries/1",
      "createTime": "2023-10-20T18:06:50.395938752Z",
      "updateTime": "2023-10-20T18:06:50.396525946Z",
      "routine": "main",
      "step": "tryStep",
      "stepType": "STEP_TRY_RETRY_EXCEPT",
      "state": "STATE_SUCCEEDED",
      "entryId": "1",
      "navigationInfo": {
        "children": [
          "2",
          "4"
        ],
        "next": "2"
      }
    },
    {
      "name": "projects/200478149810/locations/us-central1/workflows/ck-for-block/executions/8ec49dae-ab0c-4b55-b1c4-b809244be913/stepEntries/2",
      "createTime": "2023-10-20T18:06:50.395942598Z",
      "updateTime": "2023-10-20T18:06:50.396497992Z",
      "routine": "main",
      "step": "tryStep",
      "stepType": "STEP_TRY",
      "state": "STATE_FAILED",
      "entryId": "2",
      "navigationInfo": {
        "children": [
          "3"
        ],
        "parent": "1",
        "next": "3",
        "previous": "1"
      }
    },
    {
      "name": "projects/200478149810/locations/us-central1/workflows/ck-for-block/executions/8ec49dae-ab0c-4b55-b1c4-b809244be913/stepEntries/3",
      "createTime": "2023-10-20T18:06:50.395944871Z",
      "updateTime": "2023-10-20T18:06:50.396497499Z",
      "routine": "main",
      "step": "tryStep.try",
      "stepType": "STEP_RETURN",
      "state": "STATE_FAILED",
      "exception": {
        "payload": "{\"message\":\"ZeroDivisionError: division by zero\",\"tags\":[\"ZeroDivisionError\",\"ArithmeticError\"]}"
      },
      "entryId": "3",
      "navigationInfo": {
        "parent": "2",
        "next": "4",
        "previous": "2"
      }
    },
    {
      "name": "projects/200478149810/locations/us-central1/workflows/ck-for-block/executions/8ec49dae-ab0c-4b55-b1c4-b809244be913/stepEntries/4",
      "createTime": "2023-10-20T18:06:50.396506860Z",
      "updateTime": "2023-10-20T18:06:50.396525900Z",
      "routine": "main",
      "step": "tryStep",
      "stepType": "STEP_EXCEPT",
      "state": "STATE_SUCCEEDED",
      "entryId": "4",
      "navigationInfo": {
        "children": [
          "5"
        ],
        "parent": "1",
        "next": "5",
        "previous": "3"
      }
    },
    {
      "name": "projects/200478149810/locations/us-central1/workflows/ck-for-block/executions/8ec49dae-ab0c-4b55-b1c4-b809244be913/stepEntries/5",
      "createTime": "2023-10-20T18:06:50.396516994Z",
      "updateTime": "2023-10-20T18:06:50.396525818Z",
      "routine": "main",
      "step": "tryStep.except",
      "stepType": "STEP_RETURN",
      "state": "STATE_SUCCEEDED",
      "entryId": "5",
      "navigationInfo": {
        "parent": "4",
        "previous": "4"
      }
    }
  ],
  "totalSize": 5
}

后续步骤