You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过BW Agent的REST API获取应用执行及节点追踪日志?

Absolutely! You can definitely pull both application execution trace logs and node-specific trace logs via the BW Agent REST API. Here's a straightforward breakdown of how to implement both:

1. Retrieve Application Execution Trace Logs

First, make sure your BW Agent is up and running, and you have the necessary API access permissions (usually a valid auth token).

API Endpoint & Method

Use a GET request against the following endpoint:

/api/v1/traces/applications/{appId}

Replace {appId} with the unique ID of your target application.

Key Query Parameters

  • startTime: Timestamp (ISO 8601 format, e.g., 2024-05-20T00:00:00Z) to define the start of your log range.
  • endTime: Timestamp marking the end of your log range.
  • executionId (optional): Filter logs to a specific application execution instance if you only care about one run.
  • logLevel (optional): Narrow results to a specific level like DEBUG, INFO, ERROR, or WARN.

Example Request (curl)

curl -X GET "http://<bw-agent-host>:<port>/api/v1/traces/applications/my-app-123?startTime=2024-05-20T00:00:00Z&endTime=2024-05-20T12:00:00Z&logLevel=DEBUG" \
-H "Authorization: Bearer your-auth-token-here"

Response Overview

The response will return a JSON array of trace entries, each containing:

  • traceId: Unique identifier for the entire execution trace
  • spans: List of individual execution steps (each with their own start/end times, logs, and metadata)
  • applicationId: The target app ID
  • timestamp: When the log entry was generated
2. Retrieve Application Node Trace Logs

To get logs specific to a particular node within your application, you can use a node-targeted endpoint, which lets you isolate logs from a single instance or component.

API Endpoint & Method

Use a GET request against:

/api/v1/traces/applications/{appId}/nodes/{nodeId}

Replace {appId} with your app's ID and {nodeId} with the unique ID of the target node (you can get node IDs via the BW Agent's application metadata API if needed).

Key Query Parameters

Same core parameters as above (startTime, endTime, logLevel), plus:

  • serviceName (optional): Filter logs to a specific service running on the node.

Example Request (curl)

curl -X GET "http://<bw-agent-host>:<port>/api/v1/traces/applications/my-app-123/nodes/node-456?startTime=2024-05-20T00:00:00Z&endTime=2024-05-20T12:00:00Z&logLevel=ERROR" \
-H "Authorization: Bearer your-auth-token-here"

Response Overview

The response will be similar to the application-level trace, but filtered exclusively to logs generated by the specified node. You'll get details like node-specific span IDs, resource usage logs, and component-specific execution steps.

Quick Tips

  • If you don't know your appId or nodeId, you can fetch a list of applications and their nodes using the GET /api/v1/applications endpoint.
  • For large result sets, use the pageSize and pageNumber parameters to paginate results and avoid timeouts.

内容的提问来源于stack exchange,提问作者Anouar BAKRI

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 08:51:15