View a markdown version of this page

Example queries - AWS Context

Example queries

You can use CloudWatch Logs Insights to query the aws/spans log group. The following are some common queries.

  • Count failed calls by operation and error type.

    filter attributes.aws.resource.type = "AWS::Context::AgentContext" and ispresent(attributes.error.type) | stats count(*) as failures by name, attributes.error.type | sort failures desc
  • List the slowest AgenticRetrieveStream calls.

    filter name = "AgenticRetrieveStream" | fields @timestamp, attributes.aws.request.id, attributes.latency_ms, attributes.http.response.status_code | sort attributes.latency_ms desc | limit 20
  • Find the span for a request ID.

    filter attributes.aws.request.id = "a1b2c3d4-5678-90ab-cdef-EXAMPLE11111" | fields @timestamp, name, traceId, spanId, parentSpanId, status.code, attributes.error.type