Add IBM Instana observability integration for AgentCore (#603)
* Added IBM Instana observability integration sample for AgentCore --------- Signed-off-by: Sandesh R <115570766+2getsandesh@users.noreply.github.com>
This commit is contained in:
+8
@@ -0,0 +1,8 @@
|
||||
uv
|
||||
ddgs
|
||||
boto3
|
||||
bedrock-agentcore
|
||||
bedrock-agentcore-starter-toolkit
|
||||
dotenv
|
||||
strands-agents[otel]
|
||||
strands-agents-tools
|
||||
+589
@@ -0,0 +1,589 @@
|
||||
{
|
||||
"cells": [
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "5c0122e65c053f38",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"# Strands Agent with Instana Observability on Amazon Bedrock AgentCore Runtime\n",
|
||||
"\n",
|
||||
"## Overview\n",
|
||||
"\n",
|
||||
"This notebook demonstrates deploying a Strands agent to Amazon Bedrock AgentCore Runtime with Instana observability integration. The implementation uses Amazon Bedrock models and sends telemetry data to Instana through OpenTelemetry (OTEL).\n",
|
||||
"\n",
|
||||
"## Key Components\n",
|
||||
"\n",
|
||||
"- **Strands Agents**: Python framework for building LLM-powered agents with built-in telemetry support\n",
|
||||
"- **Amazon Bedrock AgentCore Runtime**: Managed runtime service for hosting and scaling agents on AWS\n",
|
||||
"- **Instana**: Real-time observability and performance monitoring for applications that receives traces via OTEL\n",
|
||||
"- **OpenTelemetry**: Industry-standard protocol for collecting and exporting telemetry data\n",
|
||||
"\n",
|
||||
"## Architecture\n",
|
||||
"\n",
|
||||
"The agent is containerized and deployed to AgentCore Runtime, which provides HTTP endpoints for invocation. Telemetry data flows from the Strands agent through OTEL exporters to Instana for monitoring and debugging. The implementation disables AgentCore's default observability to use Instana instead.\n",
|
||||
"\n",
|
||||
"## Prerequisites\n",
|
||||
"\n",
|
||||
"- Python 3.10+\n",
|
||||
"- [Get started with Amazon Bedrock AgentCore](https://docs.aws.amazon.com/bedrock-agentcore/latest/devguide/agentcore-get-started-toolkit.html#agentcore-get-started-prerequisites)\n",
|
||||
"- AWS credentials configured with Bedrock and [AgentCore permissions](https://docs.aws.amazon.com/aws-managed-policy/latest/reference/BedrockAgentCoreFullAccess.html)\n",
|
||||
"- [Instana](https://www.ibm.com/products/instana) account\n",
|
||||
"- Docker installed locally\n",
|
||||
"- Access to Amazon Bedrock models"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "d66556df",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Finding the Correct Instana Endpoint\n",
|
||||
"\n",
|
||||
"To find the correct OTLP endpoint for your Instana instance:\n",
|
||||
"\n",
|
||||
"1. Open the **sidebar** in Instana.\n",
|
||||
"2. Scroll to the bottom and select **About Instana**.\n",
|
||||
"3. Note the **Instance Region** displayed there.\n",
|
||||
"4. Based on this region, choose the appropriate **HTTP OTLP endpoint (4318)** using the endpoint [documentation](https://www.ibm.com/docs/en/instana-observability/1.0.309?topic=instana-backend)\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"### Retrieving Your Instana Key\n",
|
||||
"\n",
|
||||
"To obtain your Instana key:\n",
|
||||
"\n",
|
||||
"1. From the sidebar, click **Agents & Collectors**.\n",
|
||||
"2. Select **Linux – Automatic Installation (One-liner)**.\n",
|
||||
"3. Copy the key that appears after the `-a` flag — this is your **Agent Key**, which is used as the **Instana Key**.\n",
|
||||
"\n",
|
||||
"Refer to the image below for guidance.\n",
|
||||
"\n",
|
||||
"<div style=\"text-align:left\">\n",
|
||||
" <img src=\"../images/instana_agent_key.png\" width=\"99%\"/>\n",
|
||||
"</div>"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "74e3d709",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Create a new file named `.env` in the root directory of your project and add the following environment variables:\n",
|
||||
"\n",
|
||||
"Run the cell below to automatically generate a .env file in the root of your project. After the file is created, update the placeholder values with your actual Instana OTLP endpoint and API key.\n",
|
||||
"\n",
|
||||
"The `.env` file is used to securely store your configuration details (like API keys and endpoints) so they can be easily loaded into your application without hardcoding them.\n",
|
||||
"\n",
|
||||
"**Note**: Never commit the `.env` file to GitHub or share your Instana key publicly. Add `.env` to your `.gitignore` file to keep credentials secure.\n",
|
||||
"\n",
|
||||
"### Example .env file content:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "511419c0",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%%writefile .env\n",
|
||||
"\n",
|
||||
"# Instana OTLP endpoint (e.g., https://otlp-blue-saas.instana.io:4318)\n",
|
||||
"OTEL_EXPORTER_OTLP_ENDPOINT=\"<instana_endpoint>\"\n",
|
||||
"\n",
|
||||
"# Note: This example uses StrandsTelemetry() for exporting, which supports only the HTTP OTLP endpoint.\n",
|
||||
"# Make sure to use the HTTP endpoint when working with Strands Telemetry.\n",
|
||||
"\n",
|
||||
"# Instana key\n",
|
||||
"INSTANA_KEY=\"<agent_key>\""
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "aa47b45e",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Install the dependencies by running the cell below:"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "initial_id",
|
||||
"metadata": {
|
||||
"jupyter": {
|
||||
"is_executing": true
|
||||
}
|
||||
},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"!pip install --force-reinstall -U -r requirements.txt --quiet"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "def21rvknub",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Configure AWS Credentials"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "4dc2776a",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Configure your AWS credentials by following the links provided in the `Prerequisites` section before running the notebook."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "932110e6-fca6-47b6-b7c5-c4714a866a80",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Agent Implementation\n",
|
||||
"\n",
|
||||
"The agent file (`strands_nova.py`) implements a travel agent with web search capabilities. Key configuration includes:\n",
|
||||
"- Initializing Strands telemetry"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "3b845b32-a03e-45c2-a2f0-2afba8069f47",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"%%writefile strands_nova.py\n",
|
||||
"import os\n",
|
||||
"import logging\n",
|
||||
"from bedrock_agentcore.runtime import BedrockAgentCoreApp\n",
|
||||
"from strands import Agent, tool\n",
|
||||
"from strands.models import BedrockModel\n",
|
||||
"from strands.telemetry import StrandsTelemetry\n",
|
||||
"from ddgs import DDGS\n",
|
||||
"\n",
|
||||
"logging.basicConfig(level=logging.ERROR, format=\"[%(levelname)s] %(message)s\")\n",
|
||||
"logger = logging.getLogger(__name__)\n",
|
||||
"logger.setLevel(os.getenv(\"AGENT_RUNTIME_LOG_LEVEL\", \"INFO\").upper())\n",
|
||||
"\n",
|
||||
"\n",
|
||||
"@tool\n",
|
||||
"def web_search(query: str) -> str:\n",
|
||||
" \"\"\"\n",
|
||||
" Search the web for information using DuckDuckGo.\n",
|
||||
"\n",
|
||||
" Args:\n",
|
||||
" query: The search query\n",
|
||||
"\n",
|
||||
" Returns:\n",
|
||||
" A string containing the search results\n",
|
||||
" \"\"\"\n",
|
||||
" try:\n",
|
||||
" ddgs = DDGS()\n",
|
||||
" results = ddgs.text(query, max_results=5)\n",
|
||||
"\n",
|
||||
" formatted_results = []\n",
|
||||
" for i, result in enumerate(results, 1):\n",
|
||||
" formatted_results.append(\n",
|
||||
" f\"{i}. {result.get('title', 'No title')}\\n\"\n",
|
||||
" f\" {result.get('body', 'No summary')}\\n\"\n",
|
||||
" f\" Source: {result.get('href', 'No URL')}\\n\"\n",
|
||||
" )\n",
|
||||
"\n",
|
||||
" return \"\\n\".join(formatted_results) if formatted_results else \"No results found.\"\n",
|
||||
"\n",
|
||||
" except Exception as e:\n",
|
||||
" return f\"Error searching the web: {str(e)}\"\n",
|
||||
"\n",
|
||||
"# Function to initialize Bedrock model\n",
|
||||
"def get_bedrock_model():\n",
|
||||
" region = os.getenv(\"AWS_DEFAULT_REGION\", \"us-east-1\")\n",
|
||||
" model_id = os.getenv(\"BEDROCK_MODEL_ID\", \"amazon.nova-lite-v1:0\")\n",
|
||||
"\n",
|
||||
" bedrock_model = BedrockModel(\n",
|
||||
" model_id=model_id,\n",
|
||||
" region_name=region,\n",
|
||||
" temperature=0.0,\n",
|
||||
" max_tokens=1024\n",
|
||||
" )\n",
|
||||
" return bedrock_model\n",
|
||||
"\n",
|
||||
"# Initialize the Bedrock model\n",
|
||||
"bedrock_model = get_bedrock_model()\n",
|
||||
"\n",
|
||||
"# Define the agent's system prompt\n",
|
||||
"system_prompt = \"\"\"You are an experienced travel agent specializing in personalized travel recommendations \n",
|
||||
"with access to real-time web information. Your role is to find dream destinations matching user preferences \n",
|
||||
"using web search for current information. You should provide comprehensive recommendations with current \n",
|
||||
"information, brief descriptions, and practical travel details.\"\"\"\n",
|
||||
"\n",
|
||||
"app = BedrockAgentCoreApp()\n",
|
||||
"\n",
|
||||
"def initialize_agent():\n",
|
||||
" \"\"\"Initialize the agent with proper telemetry configuration.\"\"\"\n",
|
||||
"\n",
|
||||
" # Initialize Strands telemetry with 3P configuration\n",
|
||||
" strands_telemetry = StrandsTelemetry()\n",
|
||||
" strands_telemetry.setup_otlp_exporter()\n",
|
||||
" \n",
|
||||
" # Create and cache the agent\n",
|
||||
" agent = Agent(\n",
|
||||
" model=bedrock_model,\n",
|
||||
" system_prompt=system_prompt,\n",
|
||||
" tools=[web_search]\n",
|
||||
" )\n",
|
||||
" \n",
|
||||
" return agent\n",
|
||||
"\n",
|
||||
"@app.entrypoint\n",
|
||||
"def strands_agent_bedrock(payload, context=None):\n",
|
||||
" \"\"\"\n",
|
||||
" Invoke the agent with a payload\n",
|
||||
" \"\"\"\n",
|
||||
" user_input = payload.get(\"prompt\")\n",
|
||||
" logger.info(\"[%s] User input: %s\", context.session_id, user_input)\n",
|
||||
" \n",
|
||||
" # Initialize agent with proper configuration\n",
|
||||
" agent = initialize_agent()\n",
|
||||
" \n",
|
||||
" response = agent(user_input)\n",
|
||||
" return response.message['content'][0]['text']\n",
|
||||
"\n",
|
||||
"if __name__ == \"__main__\":\n",
|
||||
" app.run()"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "680f3c05",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Configure AgentCore Runtime deployment\n",
|
||||
"\n",
|
||||
"Next, we’ll use the starter toolkit to configure the AgentCore Runtime deployment.\n",
|
||||
"During this step, you’ll set up the entrypoint, the execution role you created earlier, and the requirements file.\n",
|
||||
"You’ll also configure the starter kit to automatically create the Amazon ECR repository when it launches.\n",
|
||||
"\n",
|
||||
"When you run the configuration command, a Dockerfile will be automatically generated based on your application code.\n",
|
||||
"\n",
|
||||
"**Note:**\n",
|
||||
"The bedrock_agentcore_starter_toolkit enables AgentCore Observability by default.\n",
|
||||
"If you plan to use Instana for observability, you’ll need to remove the default AgentCore Observability configuration, as described in the next section.\n",
|
||||
"\n",
|
||||
"<div style=\"text-align:left\">\n",
|
||||
" <img src=\"../images/configure.png\" width=\"40%\"/>\n",
|
||||
"</div>"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "2e79eba2-ca59-463f-9ebf-56e362d7ae66",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from bedrock_agentcore_starter_toolkit import Runtime\n",
|
||||
"from boto3.session import Session\n",
|
||||
"boto_session = Session()\n",
|
||||
"region = boto_session.region_name\n",
|
||||
"\n",
|
||||
"agentcore_runtime = Runtime()\n",
|
||||
"agent_name = \"strands_instana_observability\"\n",
|
||||
"response = agentcore_runtime.configure(\n",
|
||||
" entrypoint=\"strands_nova.py\",\n",
|
||||
" auto_create_execution_role=True,\n",
|
||||
" auto_create_ecr=True,\n",
|
||||
" requirements_file=\"requirements.txt\",\n",
|
||||
" region=region,\n",
|
||||
" agent_name=agent_name,\n",
|
||||
" disable_otel=True,\n",
|
||||
")\n",
|
||||
"response"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "aede8bb4",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Alternative Configuration (Using a Pre-Created IAM Role)\n",
|
||||
"\n",
|
||||
"If your AWS account **does not allow automatic role creation** or if you want **more control over permissions**, you can use a **pre-created IAM role** instead of letting the toolkit create one automatically.\n",
|
||||
"\n",
|
||||
"In this case:\n",
|
||||
"- Set `auto_create_execution_role=False`\n",
|
||||
"- Provide your existing IAM role ARN via the `execution_role` parameter.\n",
|
||||
"\n",
|
||||
"This approach is useful when:\n",
|
||||
"- Your organization enforces **least-privilege IAM policies**.\n",
|
||||
"- You want to **reuse a common execution role** across multiple AgentCore deployments.\n",
|
||||
"- You are working in a **restricted environment** (for example, enterprise or shared AWS accounts) where creating new roles is not permitted.\n",
|
||||
"\n",
|
||||
"Refer to the sample below to see how to configure the runtime with a manually managed IAM role."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "5889839a",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# Alternative Configuration (Optional)\n",
|
||||
"\n",
|
||||
"from bedrock_agentcore_starter_toolkit import Runtime\n",
|
||||
"from boto3.session import Session\n",
|
||||
"\n",
|
||||
"ROLE_ARN = \"your_IAM_role\"\n",
|
||||
"\n",
|
||||
"boto_session = Session()\n",
|
||||
"region = boto_session.region_name\n",
|
||||
"\n",
|
||||
"agentcore_runtime = Runtime()\n",
|
||||
"agent_name = \"strands_instana_observability\"\n",
|
||||
"response = agentcore_runtime.configure(\n",
|
||||
" entrypoint=\"strands_nova.py\",\n",
|
||||
" auto_create_execution_role=False, # This disables the auto-create role\n",
|
||||
" execution_role=ROLE_ARN,\n",
|
||||
" auto_create_ecr=True,\n",
|
||||
" requirements_file=\"requirements.txt\",\n",
|
||||
" region=region,\n",
|
||||
" agent_name=\"strands_instana_observability\",\n",
|
||||
" disable_otel=True,\n",
|
||||
")\n",
|
||||
"response"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "c4vnazx93s",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Deploy to AgentCore Runtime\n",
|
||||
"\n",
|
||||
"Now that your Dockerfile has been generated, it’s time to launch your agent to the AgentCore Runtime.\n",
|
||||
"\n",
|
||||
"This step will automatically:\n",
|
||||
"- Create the Amazon ECR repository (if it doesn’t already exist)\n",
|
||||
"- Deploy your containerized agent to the AgentCore Runtime environment\n",
|
||||
"- Load your environment variables (like the Instana endpoint and API key) from the `.env` file you created earlier\n",
|
||||
"\n",
|
||||
"**NOTE:** Make sure your `.env` file is correctly configured before running this cell — otherwise, the telemetry data will not be exported to Instana.\n",
|
||||
"\n",
|
||||
"<div style=\"text-align:left\">\n",
|
||||
" <img src=\"../images/launch.png\" width=\"75%\"/>\n",
|
||||
"</div>"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "17a32ab8-7701-4900-8055-e24364bdf35c",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from dotenv import load_dotenv\n",
|
||||
"import os\n",
|
||||
"\n",
|
||||
"# Load environment variables from .env file\n",
|
||||
"load_dotenv()\n",
|
||||
"\n",
|
||||
"# Fetch configuration\n",
|
||||
"otel_endpoint = os.getenv(\"OTEL_EXPORTER_OTLP_ENDPOINT\")\n",
|
||||
"instana_key = os.getenv(\"INSTANA_KEY\")\n",
|
||||
"\n",
|
||||
"# Format Instana header\n",
|
||||
"otel_auth_header = f\"x-instana-key={instana_key}\"\n",
|
||||
"\n",
|
||||
"# Launch the AgentCore runtime\n",
|
||||
"launch_result = agentcore_runtime.launch(\n",
|
||||
" env_vars={\n",
|
||||
" \"BEDROCK_MODEL_ID\": \"amazon.nova-lite-v1:0\",\n",
|
||||
" \"OTEL_EXPORTER_OTLP_ENDPOINT\": otel_endpoint,\n",
|
||||
" \"OTEL_EXPORTER_OTLP_HEADERS\": otel_auth_header,\n",
|
||||
" \"OTEL_SERVICE_NAME\": \"AWS-APP\",\n",
|
||||
" \"OTEL_EXPORTER_OTLP_INSECURE\": \"false\",\n",
|
||||
" \"DISABLE_ADOT_OBSERVABILITY\": \"true\",\n",
|
||||
" }\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"launch_result"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "a0ae9c09-09db-4a76-871a-92eacd96b9c3",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Check Deployment Status\n",
|
||||
"\n",
|
||||
"Once the deployment is launched, it may take a few minutes for the AgentCore Runtime to finish setting up.\n",
|
||||
"You can use the following code to monitor the deployment status in real time.\n",
|
||||
"\n",
|
||||
"This snippet continuously checks the status of your AgentCore endpoint every few seconds until it reaches a final state — such as:\n",
|
||||
"- READY → Deployment completed successfully\n",
|
||||
"- CREATE_FAILED, UPDATE_FAILED, or DELETE_FAILED → Deployment encountered an error"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "afa6ac09-9adb-4846-9fc1-4d12aeb74853",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import time\n",
|
||||
"status_response = agentcore_runtime.status()\n",
|
||||
"status = status_response.endpoint['status']\n",
|
||||
"end_status = ['READY', 'CREATE_FAILED', 'DELETE_FAILED', 'UPDATE_FAILED']\n",
|
||||
"while status not in end_status:\n",
|
||||
" time.sleep(10)\n",
|
||||
" status_response = agentcore_runtime.status()\n",
|
||||
" status = status_response.endpoint['status']\n",
|
||||
" print(status)\n",
|
||||
"status"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "b7f89c56-918a-4cab-beaa-c7ac43a2ba29",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"### Invoking AgentCore Runtime\n",
|
||||
"\n",
|
||||
"Finally, we can invoke the deployed agent with a sample prompt to test its response and verify that it’s working as expected.\n",
|
||||
"\n",
|
||||
"<div style=\"text-align:left\">\n",
|
||||
" <img src=\"../images/invoke.png\" width=75%\"/>\n",
|
||||
"</div>"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "3d909e42-e1a0-407f-84c2-3d16cc889cd3",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"invoke_response = agentcore_runtime.invoke({\"prompt\": \"I'm planning a weekend trip to london. What are the must-visit places and local food I should try?\"})"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "705afd42",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"Use the code below to neatly display the agent’s output."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "dc34c4f3",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"from IPython.display import Markdown, display\n",
|
||||
"display(Markdown(\"\".join(invoke_response['response'])))"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "05efe60e",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## View Traces in Instana\n",
|
||||
"\n",
|
||||
"To view the traces:\n",
|
||||
"1. Go to your Instana dashboard\n",
|
||||
"2. Click on `Analytics` from the sidebar.\n",
|
||||
"3. Check the box labeled `Show internal calls` under the `Hidden calls` tab.\n",
|
||||
"4. Click on `Add Filter` and select `Service Name`\n",
|
||||
"5. Search for \"strands-agents\" in the search bar.\n",
|
||||
"6. Click to view and analyze the list of associated calls. Each call represents a user interaction.\n",
|
||||
"7. Click on any call to see the full trace data.\n",
|
||||
"\n",
|
||||
"The traces will include:\n",
|
||||
"- Agent invocation details\n",
|
||||
"- Tool calls (web search)\n",
|
||||
"- Model interactions with latency and token usage\n",
|
||||
"- Request/response payloads"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "7d3fdfe404469632",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Cleanup (Optional)\n",
|
||||
"\n",
|
||||
"Once you’ve finished testing, use the code below to delete the AgentCore Runtime and the associated Amazon ECR repository to avoid unnecessary resource usage and costs."
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "code",
|
||||
"execution_count": null,
|
||||
"id": "76a6cf1416830a54",
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"import boto3\n",
|
||||
"\n",
|
||||
"agentcore_control_client = boto3.client(\n",
|
||||
" 'bedrock-agentcore-control',\n",
|
||||
" region_name=region\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"ecr_client = boto3.client(\n",
|
||||
" 'ecr',\n",
|
||||
" region_name=region\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"runtime_delete_response = agentcore_control_client.delete_agent_runtime(\n",
|
||||
" agentRuntimeId=launch_result.agent_id,\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"response = ecr_client.delete_repository(\n",
|
||||
" repositoryName=launch_result.ecr_uri.split('/')[1],\n",
|
||||
" force=True\n",
|
||||
")"
|
||||
]
|
||||
},
|
||||
{
|
||||
"cell_type": "markdown",
|
||||
"id": "b118ad38-feeb-4d1d-9d57-e5c845becc56",
|
||||
"metadata": {},
|
||||
"source": [
|
||||
"## Summary\n",
|
||||
"\n",
|
||||
"You have successfully deployed a Strands agent to Amazon Bedrock AgentCore Runtime with Instana observability. The implementation demonstrates:\n",
|
||||
"- Integration of Strands agents with AgentCore Runtime\n",
|
||||
"- Configuration of OpenTelemetry to send traces to Instana\n",
|
||||
"- Proper initialization order to ensure telemetry configuration\n",
|
||||
"\n",
|
||||
"The agent is now running in a managed, scalable environment with full observability through Instana."
|
||||
]
|
||||
}
|
||||
],
|
||||
"metadata": {
|
||||
"kernelspec": {
|
||||
"display_name": "agentcore-instana-kernel",
|
||||
"language": "python",
|
||||
"name": ".agentcore_instana_env"
|
||||
},
|
||||
"language_info": {
|
||||
"codemirror_mode": {
|
||||
"name": "ipython",
|
||||
"version": 3
|
||||
},
|
||||
"file_extension": ".py",
|
||||
"mimetype": "text/x-python",
|
||||
"name": "python",
|
||||
"nbconvert_exporter": "python",
|
||||
"pygments_lexer": "ipython3",
|
||||
"version": "3.11.6"
|
||||
}
|
||||
},
|
||||
"nbformat": 4,
|
||||
"nbformat_minor": 5
|
||||
}
|
||||
+6
-1
@@ -42,6 +42,10 @@ Each platform requires specific configuration:
|
||||
- API key from Braintrust dashboard
|
||||
- Project configuration
|
||||
|
||||
### Instana
|
||||
- Instana key
|
||||
- Project configuration
|
||||
|
||||
### Langfuse
|
||||
- Public and secret keys
|
||||
- Project configuration
|
||||
@@ -58,10 +62,11 @@ After completing examples:
|
||||
|
||||
- [Arize Documentation](https://arize.com/docs/ax)
|
||||
- [Braintrust Documentation](https://www.braintrust.dev/docs)
|
||||
- [Instana Documentation](https://www.ibm.com/docs/en/instana-observability/1.0.308?topic=overview)
|
||||
- [Langfuse Documentation](https://langfuse.com/docs)
|
||||
- [AgentCore Runtime Guide](https://docs.aws.amazon.com/bedrock-agentcore/latest/userguide/runtime.html)
|
||||
|
||||
# Third-Party Observability for Amazon Bedrock AgentCore Agents
|
||||
|
||||
This repository contains examples of using agents hosted on Amazon Bedrock AgentCore Runtime with third-party observability tools like Arize, Braintrust, Langfuse, and others. These examples demonstrate OpenTelemetry integration for monitoring agent performance, tracing LLM interactions, and debugging workflows.
|
||||
This repository contains examples of using agents hosted on Amazon Bedrock AgentCore Runtime with third-party observability tools like Arize, Braintrust, Instana, Langfuse, and others. These examples demonstrate OpenTelemetry integration for monitoring agent performance, tracing LLM interactions, and debugging workflows.
|
||||
|
||||
|
||||
BIN
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
@@ -53,6 +53,9 @@ For more details on AgentCore Observability, please refer to [this](https://aws.
|
||||
│ ├── Braintrust/
|
||||
│ │ ├── requirements.txt
|
||||
│ │ └── runtime_with_strands_and_braintrust.ipynb
|
||||
│ ├── Instana/
|
||||
│ │ ├── requirements.txt
|
||||
│ │ └── runtime_with_strands_and_instana.ipynb
|
||||
│ ├── Langfuse/
|
||||
│ │ ├── requirements.txt
|
||||
│ │ └── runtime_with_strands_and_langfuse.ipynb
|
||||
@@ -102,6 +105,7 @@ Examples of using agents hosted on Amazon Bedrock AgentCore Runtime with third-p
|
||||
|
||||
- **Arize**: AI and Agent engineering platform
|
||||
- **Braintrust**: AI evaluation and monitoring platform
|
||||
- **Instana**: Real-Time APM and Observability Platform
|
||||
- **Langfuse**: LLM observability and analytics
|
||||
|
||||
### 5. Lambda AgentCore Invocation (05-Lambda-AgentCore-invocation)
|
||||
|
||||
@@ -57,3 +57,4 @@
|
||||
- spencer-zepelin
|
||||
- Chaitra Mathur (mchaitra007)
|
||||
- govindhi
|
||||
- Sandesh R
|
||||
|
||||
Reference in New Issue
Block a user