OpenObserve Docs

Amazon Bedrock → OpenObserve

Automatically capture token usage, latency, and model metadata for every Amazon Bedrock converse call in your Python application.

Prerequisites

  • Python 3.8+
  • An OpenObserve account (cloud or self-hosted)
  • Your OpenObserve organisation ID and Base64-encoded auth token
  • AWS credentials with AmazonBedrockFullAccess permissions

Installation

pip install openobserve-telemetry-sdk openinference-instrumentation-bedrock boto3 python-dotenv

Configuration

Create a .env file in your project root:

OPENOBSERVE_URL=https://api.openobserve.ai/
OPENOBSERVE_ORG=your_org_id
OPENOBSERVE_AUTH_TOKEN=Basic <your_base64_token>

AWS_ACCESS_KEY_ID=your-access-key-id
AWS_SECRET_ACCESS_KEY=your-secret-access-key
AWS_DEFAULT_REGION=your-aws-region

Instrumentation

Call BedrockInstrumentor().instrument() before creating any boto3 client.

from dotenv import load_dotenv
load_dotenv()

from openinference.instrumentation.bedrock import BedrockInstrumentor
from openobserve import openobserve_init

BedrockInstrumentor().instrument()
openobserve_init(resource_attributes={"service.name": "amazon-bedrock"})

import os
import boto3

bedrock = boto3.client(
    "bedrock-runtime",
    region_name=os.environ.get("AWS_DEFAULT_REGION", "us-east-1"),
)

response = bedrock.converse(
    modelId="amazon.nova-lite-v1:0",
    messages=[{"role": "user", "content": [{"text": "Explain observability in one sentence."}]}],
)
print(response["output"]["message"]["content"][0]["text"])

What Gets Captured

AttributeDescription
operation_nameAlways bedrock.converse
llm_model_nameModel ID used (e.g. amazon.nova-lite-v1:0)
llm_token_count_promptInput tokens consumed
llm_token_count_completionOutput tokens generated
llm_token_count_totalTotal tokens for the request
llm_input_messages_0_message_roleRole of the input message (user)
llm_input_messages_0_message_contents_0_message_content_textInput message text
llm_output_messages_0_message_roleRole of the output message (assistant)
llm_output_messages_0_message_contentFull response text
input_valueRaw prompt text
output_valueRaw response text
openinference_span_kindAlways LLM
span_statusUNSET on success, ERROR on failure
durationEnd-to-end request latency

Viewing Traces

  1. Log in to OpenObserve and navigate to Traces in the left sidebar
  2. Click any bedrock.converse span to inspect token counts, latency, and full request/response content

Amazon Bedrock trace span in OpenObserve

Next Steps

Every model call is recorded in OpenObserve. Build dashboards to track token usage over time, set alerts on latency spikes, and correlate Bedrock spans with the rest of your application traces.

Read More

Was this page helpful?

Last updated on

On this page