Integrating Instana with Amazon Bedrock AgentCore
Configure Instana to receive and display trace data from applications that are built and deployed by using Amazon Bedrock AgentCore.
After you complete the following steps, you can configure Instana to receive telemetry data and visualize distributed traces for applications that are deployed in AgentCore.
Prerequisites
- The instructions in Getting Started with Generative AI Observability are completed.
- AWS CLI is configured, see AWS CLI configuration guide.
- Jupyter is installed, see Jupyter installation guide.
Create environment configuration
.env file in the root directory of your application code and add the following variables:
OTEL_EXPORTER_OTLP_ENDPOINT="<instana_endpoint>"
INSTANA_KEY="<instana_key>"
These variables define the Instana OTLP endpoint and authentication key that is used for exporting telemetry data.
Choosing the correct <instana_endpoint>
Instana supports two OTLP ingestion modes: Agent mode and Agentless mode.
Agent mode
Use this mode when the Instana agent is installed on your machine.
Default OTLP HTTP port: 4318
Example:
OTEL_EXPORTER_OTLP_ENDPOINT="http://localhost:4318"
Agentless mode (SaaS OTLP ingest)
Use this mode when you send telemetry directly to Instana Cloud.
Example:
OTEL_EXPORTER_OTLP_ENDPOINT="https://otlp-magenta-saas.instana.rocks:4318"
OTLP authentication header for Instana
.env file, and the application generates the header automatically by using the following logic:
otel_auth_header = f"x-instana-key={instana_key}"
Example of the generated header
.env file contains:
INSTANA_KEY="abcd1234xyz"
OTEL_EXPORTER_OTLP_HEADERS="x-instana-key=abcd1234xyz"
Enable telemetry export in the AgentCore application
from dotenv import load_dotenv
import os
# Load environment variables from .env file
load_dotenv()
# Fetch configuration
otel_endpoint = os.getenv("OTEL_EXPORTER_OTLP_ENDPOINT")
instana_key = os.getenv("INSTANA_KEY")
# Format Instana header
otel_auth_header = f"x-instana-key={instana_key}"
# Launch the AgentCore runtime
launch_result = agentcore_runtime.launch(
env_vars={
"BEDROCK_MODEL_ID": "amazon.nova-lite-v1:0",
"OTEL_EXPORTER_OTLP_ENDPOINT": otel_endpoint,
"OTEL_EXPORTER_OTLP_HEADERS": otel_auth_header,
"OTEL_SERVICE_NAME": "AWS-APP",
"OTEL_EXPORTER_OTLP_INSECURE": "false",
"DISABLE_ADOT_OBSERVABILITY": "true",
}
)
launch_result
This configuration enables OpenTelemetry-based tracing and exports the trace data to Instana.
Explore the sample application
You can directly use the prebuilt sample application to test the integration:
Amazon Bedrock AgentCore samples – Instana integration
Run the sample application to generate trace data and simulate traffic.
View data in Instana
After running your application, data will appear in the Instana Gen AI observability dashboard:
- Agent invocation details
- Tool calls (web search)
- Model interactions with latency and token usage
- Request and response payloads