View a markdown version of this page

Amazon CloudWatch를 사용한 관찰성 - Amazon Bedrock AgentCore

Amazon CloudWatch를 사용한 관찰성

AgentCore 결제는 Amazon CloudWatch를 통한 관찰성을 지원하므로 결제 통합을 모니터링하고 문제를 해결할 수 있습니다.

  • Amazon CloudWatch는 AWS 모니터링 및 관찰성 서비스입니다. AWS 리소스에서 지표, 로그 및 추적을 수집하고 추적하여 애플리케이션 성능에 대한 가시성을 제공합니다.

  • 판매 로그는 AWS 서비스가 사용자를 대신하여 CloudWatch 로그 그룹에 직접 게시하는 로그입니다. 직접 계측하는 애플리케이션 로그와 달리 벤딩된 로그는 서비스에 의해 자동으로 생성됩니다. 전송 위치를 구성합니다.

  • 스팬은 요청 내 작업 단위를 나타냅니다(예: API 호출 및 다운스트림 작업). 스팬을 사용하여 시스템을 통한 요청 흐름을 추적하고 지연 시간 병목 현상 또는 장애를 식별합니다.

다음 설정 절차를 완료하면 모든 데이터 영역 API 호출(예: CreatePaymentInstrument)이 구성된 CloudWatch 로그 그룹에 로그 및 추적 데이터를 생성합니다.

사전 조건

  • CloudWatch 로그 그룹을 전송 대상으로 사용합니다(예: /bedrock-agentcore/payments/my-logs). 없는 경우 콘솔 또는 CLI를 사용하여 생성합니다.

  • PaymentManager의 리소스 ARN입니다.

로그 그룹 생성:

Console

CloudWatch 콘솔을 열고 로그 > 로그 그룹으로 이동한 다음 로그 그룹 생성을 선택합니다. 와 같은 이름을 /bedrock-agentcore/payments/my-logs 입력하고 원하는 보존 기간을 선택합니다.

AWS CLI
aws logs create-log-group --log-group-name /bedrock-agentcore/payments/my-logs

IAM 권한

로그를 생성하고 전송 리소스를 확장하려면 IAM 사용자 또는 역할에 다음 권한이 있어야 합니다.

{ "Version": "2012-10-17", "Statement": [ { "Sid": "CloudWatchLogsVendedDelivery", "Effect": "Allow", "Action": [ "logs:CreateDelivery", "logs:CreateLogGroup", "logs:CreateLogStream", "logs:DeleteDelivery", "logs:DeleteDeliveryDestination", "logs:DeleteDeliverySource", "logs:DeleteLogGroup", "logs:DeleteResourcePolicy", "logs:DescribeLogGroups", "logs:DescribeResourcePolicies", "logs:GetDelivery", "logs:GetDeliveryDestination", "logs:GetDeliverySource", "logs:PutDeliveryDestination", "logs:PutDeliverySource", "logs:PutLogEvents", "logs:PutResourcePolicy", "logs:PutRetentionPolicy" ], "Resource": "*" }, { "Sid": "XRayApplicationSignalsCloudTrail", "Effect": "Allow", "Action": [ "xray:GetTraceSegmentDestination", "xray:ListResourcePolicies", "xray:PutResourcePolicy", "xray:PutTelemetryRecords", "xray:PutTraceSegments", "xray:UpdateTraceSegmentDestination", "application-signals:StartDiscovery", "cloudtrail:CreateServiceLinkedChannel" ], "Resource": "*" }, { "Sid": "CreateServiceLinkedRoleForAppSignals", "Effect": "Allow", "Action": "iam:CreateServiceLinkedRole", "Resource": "arn:*:iam::*:role/aws-service-role/application-signals.cloudwatch.amazonaws.com/AWSServiceRoleForCloudWatchApplicationSignals" }, { "Sid": "BedrockAgentCoreVendedLogDelivery", "Effect": "Allow", "Action": "bedrock-agentcore:AllowVendedLogDeliveryForResource", "Resource": "*" } ] }

벤딩 로그

벤딩된 로그는 구성된 로그 그룹에 애플리케이션 로그로 표시됩니다. 이는 모든 데이터 영역 API 호출에 대해 AgentCore 결제 서비스에서 자동으로 생성됩니다.

벤딩 스팬

판매 스팬은 개별 요청에 대한 추적 레코드입니다. 이를 사용하여 AWS X-Ray에서 요청 흐름을 시각화합니다. 각 스팬은 작업 단위(예: API 호출 및 다운스트림 작업)를 나타내므로 지연 시간 병목 현상 또는 장애를 식별할 수 있습니다.

범위 이름

AgentCore 결제는 데이터 영역 API 호출당 하나의 스팬을 내보냅니다. 범위 이름은 패턴을 따릅니다Bedrock.AgentCore.Payments.<Operation>.

범위 이름 설명

Bedrock.AgentCore.Payments.ProcessPayment

결제 트랜잭션 처리

Bedrock.AgentCore.Payments.CreatePaymentInstrument

결제 수단 생성

Bedrock.AgentCore.Payments.GetPaymentInstrument

결제 수단 검색

Bedrock.AgentCore.Payments.ListPaymentInstruments

결제 수단 나열

Bedrock.AgentCore.Payments.DeletePaymentInstrument

결제 수단 삭제

Bedrock.AgentCore.Payments.GetPaymentInstrumentBalance

계측 밸런스 가져오기

Bedrock.AgentCore.Payments.CreatePaymentSession

결제 세션 생성

Bedrock.AgentCore.Payments.GetPaymentSession

결제 세션 검색

Bedrock.AgentCore.Payments.ListPaymentSessions

결제 세션 나열

Bedrock.AgentCore.Payments.DeletePaymentSession

결제 세션 삭제

범위 속성

각 스팬에는 AWS X-Ray에서 필터링 및 분석을 위한 다음 속성이 포함됩니다.

속성 설명

aws.payments.payment_manager_id

이 요청에 대한 Payment Manager ID

aws.payments.payment_connector_id

Payment Connector ID(해당하는 경우)

aws.payments.payment_instrument_id

결제 수단 ID(해당하는 경우)

aws.payments.payment_session_id

결제 세션 ID(해당하는 경우)

aws.payments.spend_amount

결제 금액(ProcessPayment만 해당)

aws.payments.spend_currency

결제 통화(ProcessPayment만 해당)

aws.payments.session_remaining_budget

결제 후 남은 세션 예산(ProcessPayment만 해당)

aws.payments.total_budget_amount

총 세션 예산(ProcessPayment만 해당)

aws.payments.merchant

트랜잭션의 판매자 주소(payTo)(ProcessPayment만 해당)

aws.payments.payment_agent_name

X-Amzn-Bedrock-AgentCore-Payments-Agent-Name 헤더를 통해 제공된 경우 에이전트 이름

aws.payments.token_fetch_latency_ms

AgentCore 자격 증명에서 자격 증명 토큰 검색 지연 시간(ProcessPayment만 해당)

표준 AWS 속성은 모든 스팬에도 포함됩니다.

  • aws.region - AWS 리전

  • aws.account.id - 호출자의 계정 ID

  • aws.resource.arn - PaymentManager ARN

  • aws.request_id - 요청 ID

  • http.response.status_code - HTTP 응답 상태 코드

판매 지표

AgentCore 결제는 Amazon CloudWatch 네임스페이스에 다음 지표를 게시합니다. 이를 사용하여 대시보드를 구축하고, 경보를 설정하고, 결제 상태를 모니터링할 수 있습니다.

지표 단위 설명

OperationSuccess

개수

성공한 API 호출 수

OperationFailure

개수

실패한 API 호출 수

OperationLatency

밀리초

API 호출당 End-to-end 지연 시간

SpendAmount

없음

처리된 결제 금액(ProcessPayment만 해당)

Throttles

개수

제한된 요청 수

UserErrors

개수

클라이언트 측 검증 오류 수

ActiveSessions

개수

활성 결제 세션 수

PaymentRequestCount

개수

총 결제 요청 수

PaymentSuccessCount

개수

결제 트랜잭션 성공

PaymentFailureCount

개수

실패한 결제 트랜잭션

PaymentLatency

밀리초

결제 처리 지연 시간

지표 차원

지표는 필터링을 위해 다음 차원과 함께 게시됩니다.

  • 작업 - API 작업 이름(항상 존재)

  • PaymentManagerId - Payment Manager ID(사용 가능한 경우)

  • PaymentConnectorId - Payment Connector ID(사용 가능한 경우)

  • AgentName - 에이전트 이름(헤더를 통해 제공된 경우)

  • 통화 - 결제 통화( SpendAmount 지표용)

관찰성 활성화

Console

Amazon Bedrock AgentCore 콘솔의 Payment Manager 세부 정보 페이지에서:

  1. 로그 전송 및 추적 섹션으로 이동합니다.

  2. CloudWatch 로그 그룹에 대한 로그 전송을 구성합니다.

  3. 추적을 활성화하여 AWS X-Ray에서 스팬을 봅니다.

Payment Manager 세부 정보 페이지의 관찰성 섹션에서는 세션 수, API 호출, 트랜잭션 성공률 및 오류율을 포함한 실시간 지표를 제공합니다.

AWS CLI
# Step 1: Allow vended log delivery for your Payment Manager aws bedrock-agentcore allow-vended-log-delivery-for-resource \ --resource-arn "arn:aws:bedrock-agentcore:us-west-2:123456789012:payment-manager/my-manager" # Step 2: Create a delivery source aws logs put-delivery-source \ --name "payments-logs" \ --resource-arn "arn:aws:bedrock-agentcore:us-west-2:123456789012:payment-manager/my-manager" \ --log-type "APPLICATION_LOGS" # Step 3: Create a delivery destination aws logs put-delivery-destination \ --name "payments-log-destination" \ --delivery-destination-configuration '{"destinationResourceArn": "arn:aws:logs:us-west-2:123456789012:log-group:/bedrock-agentcore/payments/my-logs"}' # Step 4: Create the delivery aws logs create-delivery \ --delivery-source-name "payments-logs" \ --delivery-destination-arn "arn:aws:logs:us-west-2:123456789012:delivery-destination:payments-log-destination"
AWS SDK
import boto3 # Allow vended log delivery for your Payment Manager agentcore_client = boto3.client("bedrock-agentcore-control", region_name="us-west-2") agentcore_client.allow_vended_log_delivery_for_resource( resourceArn="arn:aws:bedrock-agentcore:us-west-2:123456789012:payment-manager/my-manager" ) # Configure CloudWatch Logs delivery logs_client = boto3.client("logs", region_name="us-west-2") # Create delivery source logs_client.put_delivery_source( name="payments-logs", resourceArn="arn:aws:bedrock-agentcore:us-west-2:123456789012:payment-manager/my-manager", logType="APPLICATION_LOGS" ) # Create delivery destination logs_client.put_delivery_destination( name="payments-log-destination", deliveryDestinationConfiguration={ "destinationResourceArn": "arn:aws:logs:us-west-2:123456789012:log-group:/bedrock-agentcore/payments/my-logs" } ) # Create the delivery logs_client.create_delivery( deliverySourceName="payments-logs", deliveryDestinationArn="arn:aws:logs:us-west-2:123456789012:delivery-destination:payments-log-destination" )

AgentCore 관찰성에 대한 자세한 내용은 AgentCore 관찰성을 참조하세요. 게이트웨이별 지표 및 범위는 AgentCore에서 생성한 게이트웨이 관찰성 데이터를 참조하세요.