<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>Elastic Observability Labs - Articles by Agi K Thomas</title>
        <link>https://www.elastic.co/observability-labs</link>
        <description>Trusted security news &amp; research from the team at Elastic.</description>
        <lastBuildDate>Fri, 06 Mar 2026 16:24:31 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <image>
            <title>Elastic Observability Labs - Articles by Agi K Thomas</title>
            <url>https://www.elastic.co/observability-labs/assets/observability-labs-thumbnail.png</url>
            <link>https://www.elastic.co/observability-labs</link>
        </image>
        <copyright>© 2026. Elasticsearch B.V. All Rights Reserved</copyright>
        <item>
            <title><![CDATA[Observability for Amazon MQ with Elastic: Demystifying Messaging Flows with Real-Time Insights]]></title>
            <link>https://www.elastic.co/observability-labs/blog/amazonmq-observability-rabbitmq-integration</link>
            <guid isPermaLink="false">amazonmq-observability-rabbitmq-integration</guid>
            <pubDate>Fri, 02 May 2025 00:00:00 GMT</pubDate>
            <description><![CDATA[RabbitMQ, managed by Amazon MQ, enables asynchronous communication in distributed architectures but introduces operational risks such as retries, processing delays, and queue backlogs. Elastic’s Amazon MQ integration for RabbitMQ delivers deep observability into broker health, queue performance, message flow, and resource usage through Amazon CloudWatch metrics and logs. This blog outlines key operational risks associated with RabbitMQ and explains how Elastic observability helps maintain system reliability and optimize message delivery at scale.]]></description>
            <content:encoded><![CDATA[<h1>Observability for Amazon MQ with Elastic: Demystifying Messaging Flows with Real-Time Insights</h1>
<h2>Managing the Hidden Complexity of Message-Driven Architectures</h2>
<p>Amazon MQ is a managed message broker service for <a href="http://activemq.apache.org/">Apache ActiveMQ</a> Classic and <a href="https://www.rabbitmq.com/">RabbitMQ</a> that manages the setup, operation, and maintenance of message brokers. Messaging systems like RabbitMQ, managed by <a href="https://aws.amazon.com/amazon-mq/">Amazon MQ</a>, are pivotal in modern decoupled, event-driven applications. By serving as an intermediary between services, RabbitMQ facilitates asynchronous communication through message queuing, routing, and reliable delivery, making it an ideal fit for microservices, real-time pipelines, and event-driven architectures. However, this flexibility introduces operational challenges, such as retries, processing delays, consumer failures, and queue backlogs, which can gradually impact downstream performance and system reliability.</p>
<p>With Elastic’s <a href="https://www.elastic.co/docs/reference/integrations/aws_mq">Amazon MQ integration</a>, users gain deep visibility into message flow patterns, queue performance, and consumer health. This integration allows for the proactive detection of bottlenecks, helps optimize system behaviour, and ensures reliable message delivery at scale.</p>
<p>In this blog, we'll dive into the operational challenges of RabbitMQ in modern architectures, while also examining the common gaps and strategies for overcoming them.</p>
<h2>Why Observability for RabbitMQ on Amazon MQ Matters?</h2>
<p>RabbitMQ brokers are integral to distributed systems, handling tasks ranging from order processing to payment workflows and notification delivery. Any disruption can cascade into significant downstream issues. Observability into RabbitMQ helps answer critical operational questions like:​</p>
<ul>
<li>Is CPU and memory utilization increasing over time?</li>
<li>What are the trends in the message publish rate, message confirmation rate?</li>
<li>Are consumers failing to acknowledge messages?</li>
<li>Which queues are experiencing abnormal growth?</li>
<li>Are there an increasing number of messages being dead-lettered over time?</li>
</ul>
<h2>Enhanced Observability with Amazon MQ Integration</h2>
<p>Elastic provides a dedicated <a href="https://www.elastic.co/docs/reference/integrations/aws_mq">Amazon MQ integration</a> for RabbitMQ that utilizes Amazon CloudWatch metrics and logs to deliver comprehensive observability data. This integration enables the ingestion of metrics related to connections, nodes, queues, exchanges, and system logs.</p>
<p>By deploying <a href="https://www.elastic.co/elastic-agent">Elastic Agent</a> with this integration, the users can monitor:​</p>
<ul>
<li><strong>Queue performance and Dead-letter queue (DLQ) metrics</strong> include total message count (<code>MessageCount.max</code>), messages ready for delivery (<code>MessageReadyCount.max</code>), and unacknowledged messages (<code>MessageUnacknowledgedCount.max</code>). <code>MessageCount.max</code> metric tracks the total number of messages in a queue, including those that have been dead-lettered, and monitoring this over time can help identify trends in message accumulation, which may suggest issues leading to dead-lettering.</li>
<li><strong>Consumer behaviour</strong> through metrics like consumer count (<code>ConsumerCount.max</code>) and acknowledgement rate (<code>AckRate.max</code>), which help identify underperforming consumers or potential backlogs.</li>
<li><strong>Messaging throughput</strong> by tracking publish (<code>PublishRate.max</code>), confirm (<code>ConfirmRate.max</code>), and acknowledgement rates in real time. These are crucial for understanding application messaging patterns and flow.</li>
<li><strong>Broker and node-level health,</strong> including memory usage (<code>RabbitMQMemUsed.max</code>), CPU utilization (<code>SystemCpuUtilization.max</code>), disk availability (<code>RabbitMQDiskFree.min</code>), and file descriptor usage (<code>RabbitMQFdUsed.max</code>). These indicators are essential for diagnosing resource saturation and avoiding service disruption.</li>
</ul>
<p><img src="https://www.elastic.co/observability-labs/assets/images/amazonmq-observability-rabbitmq-integration/amazonmq-rabbitmq-dashboard-overview.png" alt="" /></p>
<h2>Integrating Amazon MQ Metrics into Elastic Observability</h2>
<p>Elastic's Amazon MQ integration facilitates the ingestion of CloudWatch metrics and logs into Elastic Observability, delivering near real-time insights into RabbitMQ. The prebuilt Amazon MQ dashboard visualizes this data, providing a centralized view of broker health, messaging activity, and resource usage, helping users quickly detect and resolve issues. Elastic's <a href="https://www.elastic.co/docs/solutions/observability/incident-management/alerting">alerting</a> for Observability enables proactive notifications based on custom conditions, while its <a href="https://www.elastic.co/docs/solutions/observability/incident-management/service-level-objectives-slos">SLO</a> capabilities allow users to define and track key performance targets, strengthening system reliability and service commitments. </p>
<p>Elastic brings together logs and metrics from Amazon MQ alongside data from a wide range of other services and applications, whether running in AWS, on-premises, or across multi-cloud environments, offering unified observability from a single platform.</p>
<h3>Prerequisites</h3>
<p>To follow along, ensure you have:</p>
<ul>
<li>An account on <a href="http://cloud.elastic.co/">Elastic Cloud</a> and a deployed stack in AWS (<a href="https://www.elastic.co/guide/en/elastic-stack/current/installing-elastic-stack.html">see instructions here</a>). Ensure you are using version 8.16.5 or higher. Alternatively, you can use <a href="https://www.elastic.co/cloud/serverless">Elastic Cloud Serverless</a>, a fully managed solution that eliminates infrastructure management, automatically scales based on usage, and lets you focus entirely on extracting value from your data.</li>
<li>An AWS account with permissions to pull the necessary data from AWS. <a href="https://docs.elastic.co/en/integrations/aws#aws-permissions">See details in our documentation</a>.</li>
</ul>
<h2>Architecture</h2>
<p><img src="https://www.elastic.co/observability-labs/assets/images/amazonmq-observability-rabbitmq-integration/rabbitmq_lambda_messageflow.png" alt="" /></p>
<h2>Tracing Audit Flows from RabbitMQ to AWS Lambda</h2>
<p>Consider a financial audit trail use case, where every user action, such as a funds transfer, is published to RabbitMQ. A Python-based AWS Lambda function consumes these messages, deduplicates them using the <strong>id</strong> field, and logs structured audit events for downstream analysis.</p>
<p>Sample payload sent through RabbitMQ:</p>
<pre><code class="language-json">{
  &quot;id&quot;: &quot;txn-849302&quot;,
  &quot;type&quot;: &quot;audit&quot;,
  &quot;payload&quot;: {
    &quot;user_id&quot;: &quot;u-10245&quot;,
    &quot;event&quot;: &quot;funds.transfer&quot;,
    &quot;amount&quot;: 1200.75,
    &quot;currency&quot;: &quot;USD&quot;,
    &quot;timestamp&quot;: &quot;T14:20:15Z&quot;,
    &quot;ip&quot;: &quot;192.168.0.8&quot;,
    &quot;location&quot;: &quot;New York, USA&quot;
  }
}
</code></pre>
<p>You can now correlate message publishing activity from RabbitMQ with AWS Lambda invocation logs, track processing latency, and configure alerts for conditions like drops in consumer throughput or an unexpected surge in RabbitMQ queue depth.</p>
<h3>AWS Lambda Function: Processing RabbitMQ Messages</h3>
<p>This Python-based AWS Lambda function processes audit events received from RabbitMQ. It deduplicates messages based on the <strong>id</strong> field and logs structured event data for downstream analysis or compliance. Save the code below in a file named <strong>app.py</strong>.</p>
<pre><code class="language-python">import json
import logging
import base64
# Configure logging
logger = logging.getLogger()
logger.setLevel(logging.INFO)
# In-memory set to track processed message IDs for deduplication
processed_ids = set()
def lambda_handler(event, context):
    logger.info(&quot;Lambda triggered by RabbitMQ event&quot;)
    if 'rmqMessagesByQueue' not in event:
        logger.warning(&quot;Invalid event: missing 'rmqMessagesByQueue'&quot;)
        return {'statusCode': 400, 'body': 'Invalid RabbitMQ event'}
    for queue_name, messages in event['rmqMessagesByQueue'].items():
        logger.info(f&quot;Processing queue: {queue_name}, Messages count: {len(messages)}&quot;)
        for msg in messages:
            try:
                raw_data = msg['data']
                decoded_json = base64.b64decode(raw_data).decode('utf-8')
                message = json.loads(decoded_json)
                logger.info(f&quot;Decoded message: {json.dumps(message)}&quot;)
                message_id = message.get('id')
                if not message_id:
                    logger.warning(&quot;Message missing 'id', skipping.&quot;)
                    continue
                if message_id in processed_ids:
                    logger.warning(f&quot;Duplicate message detected: {message_id}&quot;)
                    continue
                payload = message.get('payload', {})
                logger.info(f&quot;Processing message ID: {message_id}&quot;)
                logger.info(f&quot;Event Type: {message.get('type')}&quot;)
                logger.info(f&quot;User ID: {payload.get('user_id')}&quot;)
                logger.info(f&quot;Event: {payload.get('event')}&quot;)
                logger.info(f&quot;Amount: {payload.get('amount')} {payload.get('currency')}&quot;)
                logger.info(f&quot;Timestamp: {payload.get('timestamp')}&quot;)
                logger.info(f&quot;IP Address: {payload.get('ip')}&quot;)
                logger.info(f&quot;Location: {payload.get('location')}&quot;)
                processed_ids.add(message_id)
            except Exception as e:
                logger.error(f&quot;Error processing message: {str(e)}&quot;)
    return {'statusCode': 200, 'body': 'Messages processed successfully'}

</code></pre>
<h3>Setting up AWS Secrets Manager</h3>
<p>To securely store and manage your RabbitMQ credentials, use AWS Secrets Manager.​</p>
<ol>
<li>
<p><strong>Create a New Secret:</strong></p>
<ul>
<li>Navigate to the<a href="https://console.aws.amazon.com/secretsmanager/"> AWS Secrets Manager console</a>.</li>
<li>Choose <strong>Store a new secret</strong>.</li>
<li>Select <strong>Other type of secret</strong>.</li>
<li>Enter the following key-value pairs:
<ul>
<li><code>username</code>: Your RabbitMQ username</li>
<li><code>password</code>: Your RabbitMQ password</li>
</ul>
</li>
</ul>
</li>
<li>
<p><strong>Configure the Secret:</strong></p>
<ul>
<li>Provide a meaningful name, such as <code>RabbitMQAccess</code>.</li>
<li>Optionally, add tags and set rotation if needed.​</li>
</ul>
</li>
<li>
<p><strong>Store the Secret:</strong></p>
<ul>
<li>Review the settings and store the secret. Note the ARN of the secret you have created.
<img src="https://www.elastic.co/observability-labs/assets/images/amazonmq-observability-rabbitmq-integration/aws-secret-manager-configuration.png" alt="" /></li>
</ul>
</li>
</ol>
<h3>Setting up Amazon MQ for RabbitMQ</h3>
<p>To get started with RabbitMQ on Amazon MQ, follow these steps to set up your broker.</p>
<ul>
<li>Open the <a href="https://console.aws.amazon.com/amazonmq/">Amazon MQ console</a>.</li>
<li>Create a new broker with the <strong>RabbitMQ</strong> engine.</li>
<li>Choose your preferred deployment option—<strong>single-instance</strong> or <strong>clustered</strong></li>
<li>Use the same <strong>username</strong> and <strong>password</strong> that you previously stored in <strong>AWS Secrets Manager</strong>.</li>
<li>Under <strong>Additional settings</strong>, enable <strong>CloudWatch Logs</strong> for observability.
<img src="https://www.elastic.co/observability-labs/assets/images/amazonmq-observability-rabbitmq-integration/amazonmq-cloudwatch-enable.png" alt="" /></li>
<li>Configure access and security settings, ensuring that the broker is accessible to your AWS Lambda function.</li>
</ul>
<ul>
<li>
<p>After the broker is created, note the following important details:</p>
<ul>
<li>ARN of the RabbitMQ broker.</li>
<li>RabbitMQ web console URL.
<img src="https://www.elastic.co/observability-labs/assets/images/amazonmq-observability-rabbitmq-integration/amazonmq-rabbitmq-configuration-summary.png" alt="" /></li>
</ul>
</li>
<li>
<p>You’ll need the RabbitMQ log group ARN to set up Elastic’s Amazon MQ integration for RabbitMQ. Follow these steps to locate it:</p>
<ul>
<li>Go to the <strong>General – Enabled Logs</strong> section of the broker. </li>
<li>Copy the <strong>CloudWatch log group ARN</strong>.
<img src="https://www.elastic.co/observability-labs/assets/images/amazonmq-observability-rabbitmq-integration/amazonmq-rabbitmq-loggroup-arn.png" alt="" /></li>
</ul>
</li>
</ul>
<h3>Create a RabbitMQ Queue</h3>
<p>Now that the RabbitMQ broker is configured, use the management console to create a queue where messages will be published.</p>
<ul>
<li>Access the RabbitMQ management console using the web console URL.</li>
<li>Create a new queue (example: <strong>myQueue</strong>) to receive messages.
<img src="https://www.elastic.co/observability-labs/assets/images/amazonmq-observability-rabbitmq-integration/rabbitmq-create-queue.png" alt="" /></li>
</ul>
<h3>Build and deploy the AWS Lambda function</h3>
<p>In this section, we'll set up the Lambda function using AWS SAM, add the message processing logic, and deploy it to AWS. This Lambda function will be responsible for consuming messages from RabbitMQ and logging audit events.</p>
<p>Before continuing, make sure you have completed the following prerequisites.</p>
<ul>
<li>
<p><a href="https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/prerequisites.html">AWS SAM prerequisites</a></p>
</li>
<li>
<p><a href="https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/install-sam-cli.html">Install the AWS SAM CLI</a></p>
</li>
</ul>
<p>Next, follow the steps outlined below to continue with the setup.</p>
<ol>
<li>In your command line, run the command <code>sam init</code> from a directory of your choice.</li>
<li>The AWS SAM CLI will walk you through the setup.
<ul>
<li>Select <strong>AWS Quick Start Templates</strong>.</li>
<li>Choose the <strong>Hello World Example</strong> </li>
<li>Use the <strong>Python</strong> runtime and <strong>zip</strong> package type.</li>
<li>Proceed with the default options.</li>
<li>Name your application as <strong>sample-rabbitmq-app</strong>.</li>
<li>The AWS SAM CLI downloads your starting template and creates the application project directory structure.</li>
</ul>
</li>
<li>From your command line, move to the newly created sample-rabbitmq-app directory.
<ul>
<li>Replace the content of the <strong>hello_world/app.py</strong> file with the lambda function code for rabbitmq message processing.</li>
<li>In the <strong>template.yaml</strong> file, use the values mentioned below to update the file content.
<pre><code class="language-yaml">Resources: SampleRabbitMQApp:   Type: AWS::Serverless::Function   Properties:     CodeUri: hello_world/     Description: A starter AWS Lambda function.     MemorySize: 128     Timeout: 3     Handler: app.lambda_handler     Runtime: python3.10     PackageType: Zip     Policies:       - Statement:           - Effect: Allow             Resource: '*'             Action:               - mq:DescribeBroker               - secretsmanager:GetSecretValue               - ec2:CreateNetworkInterface               - ec2:DescribeNetworkInterfaces               - ec2:DescribeVpcs               - ec2:DeleteNetworkInterface               - ec2:DescribeSubnets               - ec2:DescribeSecurityGroups     Events:       MQEvent:         Type: MQ         Properties:           Broker: &lt;ARN of the Broker&gt;           Queues:             - myQueue           SourceAccessConfigurations:             - Type: BASIC_AUTH               URI: &lt;ARN of the secret&gt;
</code></pre></li>
</ul>
</li>
<li>Run the command <code>sam deploy --guided</code> and wait for the confirmation message. This deploys all of the resources.</li>
</ol>
<h3>Sending Audit Events to RabbitMQ and Triggering Lambda</h3>
<p>To test the end-to-end setup, simulate the flow by publishing audit event data into RabbitMQ using its web UI. Once the message is sent, it triggers the Lambda function. </p>
<ol>
<li>
<p>Navigate to the <a href="https://console.aws.amazon.com/amazon-mq/home">Amazon MQ console</a> and select your newly created broker.</p>
</li>
<li>
<p>Locate and open the Rabbit web console URL<br />
<img src="https://www.elastic.co/observability-labs/assets/images/amazonmq-observability-rabbitmq-integration/amazonmq-rabbitmq-webconsole-details.png" alt="" /></p>
</li>
<li>
<p>Under the <strong>Queues and Streams</strong> tab, select the target queue (example: <strong>myQueue</strong>).</p>
</li>
<li>
<p>Enter the message payload, and click <strong>Publish message</strong> to send it to the queue.<br />
Here’s a sample payload published via RabbitMQ:</p>
<pre><code class="language-json">{
  &quot;id&quot;: &quot;txn-849302&quot;,
  &quot;type&quot;: &quot;audit&quot;,
  &quot;payload&quot;: {
    &quot;user_id&quot;: &quot;u-10245&quot;,
    &quot;event&quot;: &quot;funds.transfer&quot;,
    &quot;amount&quot;: 1200.75,
    &quot;currency&quot;: &quot;USD&quot;,
    &quot;timestamp&quot;: &quot;T14:20:15Z&quot;,
    &quot;ip&quot;: &quot;192.168.0.8&quot;,
    &quot;location&quot;: &quot;New York, USA&quot;
  }
}
</code></pre>
</li>
<li>
<p>Navigate to the AWS Lambda function created earlier.</p>
</li>
<li>
<p>Under the <strong>Monitor</strong> tab, click <strong>View CloudWatch logs</strong>.</p>
</li>
<li>
<p>Check the latest log stream to confirm that the Lambda was triggered by Amazon MQ and that the message was processed successfully.
<img src="https://www.elastic.co/observability-labs/assets/images/amazonmq-observability-rabbitmq-integration/amazonmq-lambda-logstream.png" alt="" /></p>
</li>
</ol>
<h1>Configuring Amazon MQ integration for Metrics and Logs collection</h1>
<p>Elastic’s <a href="https://www.elastic.co/docs/reference/integrations/aws_mq">Amazon MQ integration</a> simplifies the collection of logs and metrics from RabbitMQ brokers managed by Amazon MQ. Logs are ingested via <strong>Amazon CloudWatch Logs</strong>, while metrics are fetched from the specified AWS region at a defined interval.</p>
<p>Elastic provides a default configuration for metrics collection. You can accept these defaults or adjust settings such as the <strong>Collection Period</strong> to better fit your needs.</p>
<p><img src="https://www.elastic.co/observability-labs/assets/images/amazonmq-observability-rabbitmq-integration/amazonmq-metrics-configuration.png" alt="" /></p>
<p>To enable the collection of logs:</p>
<ol>
<li>Navigate to the <a href="https://console.aws.amazon.com/amazon-mq/home">Amazon MQ console</a> and select the newly created broker.</li>
<li>Click the <strong>Logs</strong> hyperlink under the <strong>General – Enabled Logs</strong> section to open the detailed log settings page.</li>
<li>From this page, copy the <strong>CloudWatch log group ARN</strong>.
<img src="https://www.elastic.co/observability-labs/assets/images/amazonmq-observability-rabbitmq-integration/amazonmq-rabbitmq-loggroup-arn.png" alt="" /></li>
<li>In <strong>Elastic</strong>, set up the <strong>Amazon MQ integration</strong> and paste the CloudWatch log group ARN.
<img src="https://www.elastic.co/observability-labs/assets/images/amazonmq-observability-rabbitmq-integration/amazonmq-logs-configuration.png" alt="" /></li>
<li><strong>Accept Defaults or Customize Settings</strong> – Elastic provides a <strong>default configuration</strong> for logs collection. You can accept these defaults or adjust settings such as <strong>collection intervals</strong> to better fit your needs.</li>
</ol>
<h3>Visualizing RabbitMQ Workloads with the Pre-Built Amazon MQ Dashboard</h3>
<p>You can access the RabbitMQ dashboard by:</p>
<ol>
<li>
<p>Navigate to the Dashboard Menu – Select the Dashboard menu option in Elastic and search for <strong>[Amazon MQ] RabbitMQ Overview</strong> to open the dashboard.</p>
</li>
<li>
<p>Navigate to the Integrations Menu – Open the <strong>Integrations</strong> menu in Elastic, select <strong>Amazon MQ</strong>, go to the <strong>Assets</strong> tab, and choose <strong>[Amazon MQ] RabbitMQ Overview</strong> from the dashboard assets</p>
</li>
</ol>
<p>The Amazon MQ RabbitMQ dashboard in the Elastic integration delivers a comprehensive overview of broker health and messaging activity. It provides real-time insights into broker resource utilization, queue and topic performance, connection trends, and messaging throughput. The dashboard helps users track system behaviour, detect performance bottlenecks, and ensure reliable message delivery across distributed applications.</p>
<h4>Broker Metrics</h4>
<p>This section provides a centralised view of the overall health and performance of the RabbitMQ broker on Amazon MQ. The visualizations highlights the number of configured exchanges and queues, active broker connections, producers, consumers, and total messages in flight. System-level metrics such as CPU utilization, memory consumption, and free disk space help assess whether the broker has sufficient resources to handle current workloads.</p>
<p>Message flow metrics such as publish rate, confirmation rate, and acknowledgement rate are displayed to provide visibility into how messages are processed through the broker. Monitoring trends in these values helps detect message delivery issues, throughput degradation, or potential saturation of the broker under load.</p>
<h4>Node Metrics</h4>
<p>Node-level visibility helps identify resource imbalances across nodes in clustered RabbitMQ setups. This section includes per-node CPU usage, memory consumption, and available disk space, offering insight into the underlying infrastructure's ability to support broker operations.</p>
<h4>Queue Metrics</h4>
<p>Queue-specific insights are critical for understanding message delivery patterns and backlog conditions. This section details total messages, ready messages, and unacknowledged messages, segmented by broker, virtual host, and queue.</p>
<p>By observing how these counts change over time, users can identify slow consumers, message build-ups, or delivery issues that may affect application performance or lead to dropped messages under pressure.</p>
<h4>Logs</h4>
<p>This section displays log level, process ID, and raw message content. These logs provide immediate visibility into events such as connection failures, resource thresholds being hit, or unexpected queue behaviors.</p>
<p><img src="https://www.elastic.co/observability-labs/assets/images/amazonmq-observability-rabbitmq-integration/amazonmq-rabbitmq-dashboard.png" alt="" /></p>
<h3>Detecting Queue Backlogs with Alerting Rules</h3>
<p>Elastic’s <a href="https://www.elastic.co/docs/solutions/observability/incident-management/alerting">alert</a> framework allows you to define rules that monitor critical RabbitMQ metrics and automatically trigger actions when specific thresholds are breached. </p>
<h4>Alert: Queue Backlog (Message Ready or Unacknowledged Messages)</h4>
<p>This alert helps detect queue backlog in Amazon MQ by evaluating two metrics</p>
<ul>
<li><code>MessageUnacknowledgedCount.max</code> and</li>
<li><code>MessageReadyCount.max</code>. </li>
</ul>
<p>The alert is triggered if either condition persists for more than <strong>10 minutes</strong>:</p>
<ul>
<li><code>MessageUnacknowledgedCount.max</code> exceeds <strong>5,000</strong></li>
<li><code>MessageReadyCount.max</code> exceeds <strong>7,000</strong></li>
</ul>
<p>These thresholds should be adjusted based on typical message volume and consumer throughput. Sustained high values can indicate that consumers are not keeping up or message delivery pipelines are congested, potentially causing delays or dropped messages. Sustained high values may result in processing delays or dropped messages if not addressed.</p>
<p><img src="https://www.elastic.co/observability-labs/assets/images/amazonmq-observability-rabbitmq-integration/amazonmq-alert-configuration.png" alt="" /></p>
<h3>Tracking Resource Utilization to Maintain RabbitMQ Performance</h3>
<p>Elastic’s <a href="https://www.elastic.co/docs/solutions/observability/incident-management/service-level-objectives-slos">Service-level objectives (SLOs)</a> capabilities allow you to define and monitor performance targets using key indicators like latency, availability, and error rates. Once configured, Elastic continuously evaluates these SLOs in real time, offering intuitive dashboards, alerts for threshold violations, and insights into error budget consumption. This enables teams to stay ahead of issues, ensuring service reliability and consistent performance.</p>
<h4>SLO: Node Resource Health (CPU, Memory, Disk)</h4>
<p>This SLO focuses on ensuring RabbitMQ brokers and nodes have sufficient resources to process messages without performance degradation. It tracks CPU, memory, and disk usage across RabbitMQ brokers and nodes to prevent resource exhaustion that could lead to service interruptions.</p>
<p><strong>Target thresholds:</strong></p>
<ul>
<li><code>SystemCpuUtilization.max</code> remains below <strong>85%</strong> for <strong>99%</strong> of the time.</li>
<li><code>RabbitMQMemUsed.max</code> remains below <strong>80%</strong> of <code>RabbitMQMemLimit.max</code> for <strong>99%</strong> of the time.</li>
<li><code>RabbitMQDiskFree.min</code> remains above <strong>25%</strong> of <code>RabbitMQDiskFreeLimit.max</code> for <strong>99%</strong> of the time.</li>
</ul>
<p>Sustained high values in CPU or memory usage can signal resource contention, which may result in slower message processing or downtime. Low disk availability may cause the broker to stop accepting messages, risking message loss. These thresholds are designed to catch early signs of resource saturation and ensure smooth, uninterrupted message flow across RabbitMQ deployments.</p>
<p><img src="https://www.elastic.co/observability-labs/assets/images/amazonmq-observability-rabbitmq-integration/amazonmq-slo-configuration.png" alt="" /></p>
<h2>Conclusion</h2>
<p>As RabbitMQ-based messaging architectures scale and become more complex, the need for in-depth visibility into system performance and potential issues deepens. Elastic’s <a href="https://www.elastic.co/docs/reference/integrations/aws_mq">Amazon MQ integration</a> brings that visibility front and center—helping you go beyond basic health checks to understand real-time messaging throughput, queue backlog trends, and resource saturation across your brokers and consumers.</p>
<p>By leveraging the prebuilt dashboards, configuring alerts and SLOs, you can proactively detect anomalies, fine-tune consumer performance, and ensure reliable delivery across your event-driven applications.</p>
]]></content:encoded>
            <category>observability-labs</category>
            <enclosure url="https://www.elastic.co/observability-labs/assets/images/amazonmq-observability-rabbitmq-integration/AmazonMQ-observability-RabbitMQ.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[Troubleshooting your Agents and Amazon Bedrock AgentCore with Elastic Observability]]></title>
            <link>https://www.elastic.co/observability-labs/blog/llm-agentic-ai-observability-amazon-bedrock-agentcore</link>
            <guid isPermaLink="false">llm-agentic-ai-observability-amazon-bedrock-agentcore</guid>
            <pubDate>Mon, 01 Dec 2025 00:00:00 GMT</pubDate>
            <description><![CDATA[Discover how to achieve end-to-end observability for Amazon Bedrock AgentCore: from tracking service health and token costs to debugging complex reasoning loops with distributed tracing.]]></description>
            <content:encoded><![CDATA[<h2>Troubleshooting your Agents and Amazon Bedrock AgentCore with Elastic Observability</h2>
<h3>Introduction</h3>
<p>We're excited to introduce Elastic Observability’s Amazon Bedrock AgentCore integration, which allows users to observe <a href="https://aws.amazon.com/bedrock/agentcore/">Amazon Bedrock AgentCore</a> and the agents' LLM interactions end-to-end. Agentic AI represents a fundamental shift in how we build applications. </p>
<p>Unlike standard LLM chatbots that simply generate text, agents can reason, plan, and execute multi-step workflows to complete complex tasks autonomously. Many times these agents are running on a platform such as Amazon Bedrock AgentCore, which helps developers build, deploy and scale agents. Amazon Bedrock AgentCore is Amazon Bedrock's platform providing the secure, scalable, and modular infrastructure services (like agent runtime, memory, and identity) necessary for developers to deploy and operate highly capable AI agents built with any framework or model.</p>
<p>Using a platform, such as Amazon Bedrock Agentcore, is easy, but troubleshooting an agent is far more complex than debugging a standard microservice. Key challenges include:</p>
<ul>
<li>
<p><strong>Non-Deterministic Behavior:</strong> Agents may choose different tools or reasoning paths for the same prompt, making it difficult to reproduce bugs.</p>
</li>
<li>
<p><strong>&quot;Black Box&quot; Execution:</strong> When an agent fails or provides a hallucinated answer, it is often unclear if the issue lies in the LLM's reasoning, the context provided, or a failed tool execution.</p>
</li>
<li>
<p><strong>Cost &amp; Latency Blind Spots:</strong> A single user query can trigger recursive loops or expensive multi-step tool calls, leading to unexpected spikes in token usage and latency.</p>
</li>
</ul>
<p>To effectively observe these systems, you need to correlate signals from two distinct layers:</p>
<ol>
<li>
<p><strong>The Platform Layer (Amazon Bedrock AgentCore):</strong> You need to understand the overall health of the managed service. This includes high-level metrics like invocation counts, latency, throttling, and platform-level errors that affect all agents running in AgentCore.</p>
</li>
<li>
<p><strong>The Application Layer (Your Agentic Logic):</strong> You want to understand the granular &quot;why&quot; behind the behavior. This includes distributed traces, usually with OpenTelemetry, that visualize the full request lifecycle (e.g. waterfall view), identifying exactly which step in the reasoning chain failed or took too long.</p>
</li>
</ol>
<p><strong>Agentic AI Observability in Elastic</strong> provides a unified, end-to-end view of your agentic deployment by combining platform-level insights from Amazon Bedrock AgentCore, through the new <a href="https://www.elastic.co/docs/reference/integrations/aws_bedrock_agentcore">Amazon Bedrock AgentCore integration</a>, with deep application-level visibility from OpenTelemetry (OTel) traces, logs and metrics form the agent. This unified view in Elastic allows you to observe, troubleshoot, and optimize your agentic applications from end to end without switching tools. Additionally, Elastic provides Agent Builder which allows you to create agents to analyze any of the data from Amazon Bedrock AgentCore and the agents running on it.</p>
<p><img src="https://www.elastic.co/observability-labs/assets/images/llm-agentic-ai-observability-amazon-bedrock-agentcore/amazon-bedrock-agentcore-dashboard-runtime-gateway-traces.jpg" alt="Amazon Bedrock AgentCore Dashboards for Runtime and Gateway and APM Tracing" /></p>
<h2>Agentic AI Observability in Elastic</h2>
<p>As mentioned above there are two main parts to end-to-end Agentic AI Observability in Elastic.</p>
<ul>
<li>
<p><strong>Amazon Bedrock AgentCore Platform Observability -</strong> using platform logs and metrics,  Elastic provides comprehensive visibility into the high-level health of the AgentCore service by ingesting AWS vended logs and metrics across four critical components:</p>
<ul>
<li>
<p><strong>Runtime:</strong> Monitor core performance indicators such as agent errors, overall latency, throttle counts, and invocation rates, for each endpoint. </p>
</li>
<li>
<p><strong>Gateway:</strong> specific insights into gateway and tool call performance, including invocations, error rates, and latency.</p>
</li>
<li>
<p><strong>Memory:</strong> Track short-term and long-term memory operations, including event creation, retrieval, and listing, alongside performance analysis, errors, and latency metrics.</p>
</li>
<li>
<p><strong>Identity:</strong> Audit security and access health with logs on successful and failed access attempts.</p>
</li>
</ul>
</li>
</ul>
<ul>
<li><strong>Agent Observability with APM, logs and metrics -</strong> To understand <em>how</em> your agent is behaving, Elastic ingests OTel-native traces, metrics and logs from your application running within AgentCore. This allows you to visualize the full execution path, including LLM reasoning steps and tool calls, in a detailed waterfall diagram. </li>
</ul>
<ul>
<li><strong>Agentic AI Analysis</strong> - All of the data from Amazon Bedrock AgentCore and the agent running on it, can be analyzed with <strong>Elastic’s AI driven capabilities</strong>. These include:</li>
</ul>
<ul>
<li>
<p><strong>Elastic AgentCore SRE Agent built on Elastic Agent Builder</strong> - We don't just monitor agents; we provide you with one to assist your team. The <strong>AgentCore SRE Agent</strong> is a specialized assistant built using <strong>Elastic Agent Builder</strong>. It possesses specialized knowledge of AgentCore applications observed in Elastic.</p>
<ul>
<li>
<p><strong>How it helps:</strong> You can ask specific questions regarding your AgentCore environment, such as how to interpret a complex error log or why a specific trace shows latency.</p>
</li>
<li>
<p><strong>Get the Agent:</strong> You can deploy this agent yourself from our <a href="https://github.com/elastic/observability-examples/tree/main/aws/amazon-bedrock-agentcore/elastic_agentcore_sre_agent">GitHub repository</a>.</p>
</li>
</ul>
</li>
<li>
<p><strong>Elastic Observability AI Assistant</strong> - Use natural language anywhere in Elastic’s UI to help you pinpoint issues, analyze something specific, or just learn what the problem is through LLM knowledge base. Additionally, SREs can interpret log messages, errors, metrics patterns, optimize code, write reports, and even identify and execute a runbook, or find a related github issue.</p>
</li>
<li>
<p><strong>Streams -</strong> AI-Driven Log Analysis - When you send AgentCore logs from your instrumented application into Elastic, you can parse and analyze them. Additionally, Streams finds <strong>Significant Events</strong> within your log stream allowing you to focus immediately on what matters most.</p>
</li>
<li>
<p><strong>Dashboards and ES|QL</strong> Data is only useful if you can act on it. Elastic provides out-of-the-box (OOTB) assets to accelerate your mean time to resolution (MTTR). And Elastic provides ES|QL to help you perform ad-hoc analysis on any signal</p>
<ul>
<li>
<p><strong>OOTB Dashboards:</strong> Pre-built visualizations based on AgentCore service signals. These dashboards provide an immediate, high-level overview of the usage, health, and performance of your AgentCore runtime, gateway, memory, and identity components.</p>
</li>
<li>
<p><strong>OOTB Alert Templates:</strong> Pre-configured alerts for common agentic issues (e.g., high error rates, latency spikes, or unusual token consumption), allowing you to move from reactive to proactive troubleshooting immediately.</p>
</li>
</ul>
</li>
</ul>
<h2>Onboarding Amazon Bedrock AgentCore signals into Elastic</h2>
<h3> Amazon Bedrock AgentCore Integration</h3>
<p>To get started with platform-level visibility, you need to enable the <strong>Amazon Bedrock AgentCore</strong> integration in Elastic. This integration automatically collects metrics and logs from your AgentCore runtime, gateway, memory, and identity components via Amazon CloudWatch.</p>
<p><strong>Setup Steps:</strong></p>
<ol>
<li>
<p><strong>Prepare AWS Environment:</strong> Ensure your AgentCore agents are deployed and running and that you have enabled logging on your AgentCore resources in the AWS console.</p>
</li>
<li>
<p><strong>Add the Integration:</strong></p>
<ul>
<li>
<p>In Elastic (Kibana), navigate to <strong>Integrations</strong>.</p>
</li>
<li>
<p>Search for <strong>&quot;Amazon Bedrock AgentCore&quot;</strong>. Select <strong>Add Amazon Bedrock AgentCore</strong>.</p>
</li>
</ul>
</li>
<li>
<p><strong>Configure &amp; Deploy:</strong></p>
<p>Configure Elastic's Amazon Bedrock AgentCore integration to collect CloudWatch metrics from your chosen AWS region at the specified collection interval. Logs will be added soon after the publication of this blog.</p>
</li>
</ol>
<h3>Onboard the Agent with OTel Instrumentation</h3>
<p>The next step is observing the application logic itself. The beauty of Amazon Bedrock AgentCore is that the application runtime often comes pre-instrumented. You simply need to tell it where to send the telemetry data.</p>
<p>For this example, we will use the <a href="https://github.com/elastic/observability-examples/tree/main/aws/amazon-bedrock-agentcore/travel_assistant"><strong>Travel Assistant</strong></a> from the Elastic Observability examples.</p>
<p>To instrument this agent, you do not need to modify the source code. Instead, when you invoke the agent using the <code>agentcore</code> CLI, you simply pass your Elastic connection details as environment variables. This redirects the OTel signals (traces, metrics, and logs) directly to the Elastic EDOT collector.</p>
<p><strong>Example Invoke Command:</strong> Run the following command to launch the agent and start streaming telemetry to Elastic:</p>
<pre><code class="language-bash">    agentcore launch \
    --env BEDROCK_MODEL_ID=&quot;us.anthropic.claude-3-5-sonnet-20240620-v1:0&quot; \
    --env OTEL_EXPORTER_OTLP_ENDPOINT=&quot;https://&lt;REPLACE_WITH_ELASTIC_ENDPOINT&gt;.region.cloud.elastic.co:443&quot; \
    --env OTEL_EXPORTER_OTLP_HEADERS=&quot;Authorization=ApiKey &lt;REPLACE_WITH_YOUR_API_KEY&gt;&quot; \
    --env OTEL_EXPORTER_OTLP_PROTOCOL=&quot;http/protobuf&quot; \
    --env OTEL_METRICS_EXPORTER=&quot;otlp&quot; \
    --env OTEL_TRACES_EXPORTER=&quot;otlp&quot; \
    --env OTEL_LOGS_EXPORTER=&quot;otlp&quot; \
    --env OTEL_RESOURCE_ATTRIBUTES=&quot;service.name=travel_assistant,service.version=1.0.0&quot; \
    --env AGENT_OBSERVABILITY_ENABLED=&quot;true&quot; \
    --env DISABLE_ADOT_OBSERVABILITY=&quot;true&quot; \
    --env TAVILY_API_KEY=&quot;&lt;REPLACE_WITH_YOUR_TAVILY_KEY&gt;&quot;
</code></pre>
<p><strong>Key Configuration Parameters:</strong></p>
<ul>
<li>
<p><code>OTEL_EXPORTER_OTLP_ENDPOINT</code>: Your Elastic OTLP endpoint (ensure port 443 is specified).</p>
</li>
<li>
<p><code>OTEL_EXPORTER_OTLP_HEADERS</code>: The Authorization header containing your Elastic API Key.</p>
</li>
<li>
<p><code>DISABLE_ADOT_OBSERVABILITY=true</code>: This ensures the native AgentCore signals are routed exclusively to your defined endpoint (Elastic) rather than default AWS paths.</p>
</li>
</ul>
<h2>Analyzing Agentic Data in Elastic Observability</h2>
<p>As we walk through the analysis features below, we will use the Travel Assistant agent which we instrumented earlier as well as any other apps you may be running on AgentCore. For the purposes of this example, as a second agent, we will use <a href="https://github.com/awslabs/amazon-bedrock-agentcore-samples/tree/main/02-use-cases/customer-support-assistant"><strong>Customer Support Assistant</strong></a> from the AWS Labs AgentCore samples </p>
<h3>Out-of-the-Box (OOTB) Dashboards</h3>
<p>Elastic populates a set of comprehensive dashboards based on Amazon Bedrock AgentCore service logs and metrics. These appear as a unified view with tabs, providing a &quot;single pane of glass&quot; into the operational health of your platform.</p>
<p><img src="https://www.elastic.co/observability-labs/assets/images/llm-agentic-ai-observability-amazon-bedrock-agentcore/amazon-bedrock-agentcore-integration-dashboards-runtime-gateway-memory-identity.gif" alt="Amazon Bedrock AgentCore out-of-the-box Dashboards for Runtime, Gateway, Memory and Identity" /></p>
<p>This view is divided into four key zones, each addressing specific components of AgentCore - Runtime, Gateway, Memory, Identity. Note that note all agentic applications use all 4 components. In our example only the Customer Assistant uses all four components, whereas the Travel agent uses only Runtime. </p>
<p><strong>Runtime Health</strong></p>
<hr />
<p>Visualize agent invocations, session metrics, error trends (system vs. user), and performance stats like latency and throttling, split per endpoint. This dashboard helps you answer questions like</p>
<ul>
<li>&quot;How are my Travel Assistant agent and Customer Support agent performing in terms of overall traffic and latency, and are there any spikes in errors or throttling?&quot;</li>
</ul>
<p><img src="https://www.elastic.co/observability-labs/assets/images/llm-agentic-ai-observability-amazon-bedrock-agentcore/amazon-bedrock-agentcore-runtime-dashboard.jpg" alt="Amazon Bedrock AgentCore out-of-the-box Dashboard for AgentCore Runtime" /></p>
<p><strong>Gateway Performance</strong></p>
<hr />
<p>Analyze invocations across Lambda and MCP (Model Context Protocol), with detailed breakdowns for tool vs. non-tool calls. The dashboard highlights throttling detection, target execution times, and separates system errors from user errors.</p>
<ul>
<li><em>Question answered:</em> &quot;Are my external integrations (Lambda, MCP) performing efficiently, or are specific tool calls experiencing high latency, throttling, or system-level errors?&quot;</li>
</ul>
<p><strong>Memory Operations</strong></p>
<hr />
<p>Track core operations like event creation, retrieval, and listing, alongside deep dives into long-term memory processing. This includes extraction and consolidation metrics broken down by strategy type, as well as specific monitoring for throttling and system vs. user errors.</p>
<ul>
<li><em>Question answered:</em> &quot;Are failures in memory consolidation strategies or high retrieval latency preventing the agent from effectively recalling user context?&quot;</li>
</ul>
<p><strong>Identity &amp; Access</strong></p>
<hr />
<p>Monitor identity token fetch operations (workload, OAuth, API keys) and real-time authentication success/failure rates. The dashboard breaks down activity by provider and highlights throttling or capacity bottlenecks.</p>
<ul>
<li><em>Question answered:</em> &quot;Are authentication failures or token fetch bottlenecks from specific providers preventing agents from accessing required resources?&quot;</li>
</ul>
<h3>Out-of-the-Box (OOTB) Alert Templates</h3>
<p>Observability isn't just about looking at dashboards; it's about knowing when to act. To move from reactive checking to proactive monitoring, Elastic provides <strong>OOTB Alert Rule Templates</strong> (starting with Elastic version 9.2.1).</p>
<p>These templates eliminate guesswork by pre-selecting the optimal metrics to monitor and applying sensible thresholds. This configuration focuses on high-fidelity alerts for genuine anomalies, helping you catch critical issues early while minimizing alert fatigue.</p>
<p><img src="https://www.elastic.co/observability-labs/assets/images/llm-agentic-ai-observability-amazon-bedrock-agentcore/elastic-alert-rule-templates-for-amazon-bedrock-agentcore.jpg" alt="Amazon Bedrock AgentCore out-of-the-box Alert rule templates for AgentCore" /></p>
<p><strong>Suggested OOTB Alerts:</strong></p>
<ul>
<li>
<p><strong>Agent Runtime System Errors:</strong> Detects server-side errors (500 Internal Server Error) during agent runtime invocations, indicating infrastructure or service issues with AWS Bedrock AgentCore.</p>
</li>
<li>
<p><strong>Agent Runtime User Errors:</strong> Flags client-side errors (4xx) during agent runtime invocations, including validation failures (400), resource not found (404), access denied (403), and resource conflicts (409). This helps catch misconfigured permissions, invalid input, or missing resources early.</p>
</li>
<li>
<p><strong>Agent Runtime High Latency:</strong> Triggers when the average latency for agent runtime invocations exceeds 10 seconds (10,000ms). Latency measures the time elapsed between receiving a request and sending the final response token.</p>
</li>
</ul>
<h3> APM Tracing</h3>
<p>While logs and metrics tell you <em>that</em> an issue exists, <strong>APM Tracing</strong> tells you exactly <em>where</em> and <em>why</em> it is happening. By ingesting the OpenTelemetry signals from your instrumented agent, Elastic generates a detailed distributed trace (e.g. waterfall view) for every interaction. To get further details on LLM information such as prompts, responses, token usage, etc, you can explore the APM logs.  </p>
<p><img src="https://www.elastic.co/observability-labs/assets/images/llm-agentic-ai-observability-amazon-bedrock-agentcore/otel-native-strands-agent-traces-in-elastic-apm.jpg" alt="Amazon Bedrock AgentCore OTel-nativedistributed tracing waterfall diagram in Elastic APM" /></p>
<p>This allows you to peer inside the &quot;black box&quot; of the agent's execution flow:</p>
<ul>
<li>
<p><strong>Visualize the Chain of Thought:</strong> See the full sequence of events, from the user's initial prompt to the final response, including all intermediate reasoning steps.</p>
</li>
<li>
<p><strong>Pinpoint Tool Failures:</strong> Identify exactly which external tool (e.g., a Lambda function for flight booking or a knowledge base query) failed or timed out.</p>
</li>
<li>
<p><strong>Analyze Latency Contributors:</strong> Distinguish between latency caused by the LLM's generation time versus latency caused by slow downstream API calls.</p>
</li>
<li>
<p><strong>Debug with Context:</strong> Drill down into individual spans to see specific error messages, attributes, and metadata that explain why a particular step failed.</p>
</li>
</ul>
<h3>Conclusion</h3>
<p>As organizations move from experimental chatbots to complex, autonomous agents in production, the need for robust observability has never been greater. Agentic applications introduce new layers of complexity—non-deterministic behaviors, multi-step reasoning loops, and cost implications—that standard monitoring tools simply cannot see.</p>
<p>Elastic Agentic AI Observability for Amazon Bedrock AgentCore bridges this gap. By unifying platform-level health metrics from AgentCore with deep, transaction-level distributed tracing from OpenTelemetry, Elastic gives SREs and developers the complete picture. Whether you are debugging a failed tool call, optimizing latency, or controlling token costs, you have the visibility needed to run agentic AI with confidence.</p>
<p><strong>Complete Visibility: AgentCore + Amazon Bedrock:</strong> For the most comprehensive view, we recommend onboarding Elastic’s <a href="https://www.elastic.co/docs/reference/integrations/aws_bedrock"><strong>Amazon Bedrock</strong> integration</a> alongside AgentCore. While the AgentCore integration focuses on the orchestration layer—monitoring agent errors, tool latency, and invocations—the Bedrock integration provides deep visibility into the underlying foundation models themselves. This includes tracking model-specific latency, token usage, full prompts and responses, and even <strong>Guardrails</strong> usage and effectiveness. By combining both, you ensure complete coverage from the high-level agent workflow down to the raw model inference.</p>
<ul>
<li>
<p><strong>Read more:</strong><a href="https://www.elastic.co/observability-labs/blog/llm-observability-aws-bedrock"> Monitor Amazon Bedrock with Elastic</a></p>
</li>
<li>
<p><strong>Read more:</strong><a href="https://www.elastic.co/observability-labs/blog/llm-observability-amazon-bedrock-guardrails"> Amazon Bedrock Guardrails Observability</a></p>
</li>
</ul>
<p><strong>Get Started Today</strong> Ready to see your agents in action?</p>
<ul>
<li>
<p><strong>Try it out:</strong> Log in to <a href="https://cloud.elastic.co/login">Elastic Cloud</a> and add the Amazon Bedrock AgentCore integration. Or use <a href="https://aws.amazon.com/marketplace/seller-profile?id=d8f59038-c24c-4a9d-a66d-6711d35d7305">Elastic from Amazon Marketplace</a></p>
</li>
<li>
<p><strong>Explore the Code:</strong> Check out our GitHub repository for the <a href="https://github.com/elastic/observability-examples/tree/main/aws/amazon-bedrock-agentcore/travel_assistant">Travel assistant</a> which you saw in this blog, as well as the <a href="https://github.com/elastic/observability-examples/tree/main/aws/amazon-bedrock-agentcore/elastic_agentcore_sre_agent">AgentCore SRE Agent</a>.</p>
</li>
<li>
<p><strong>Learn More:</strong> Read the <a href="https://www.elastic.co/docs/reference/integrations/aws_bedrock_agentcore">full documentation</a> on setting up integration for Agentic AI Observability for Amazon Bedrock AgentCore.</p>
</li>
</ul>
]]></content:encoded>
            <category>observability-labs</category>
            <enclosure url="https://www.elastic.co/observability-labs/assets/images/llm-agentic-ai-observability-amazon-bedrock-agentcore/agentcore-blog.jpg" length="0" type="image/jpg"/>
        </item>
        <item>
            <title><![CDATA[LLM observability with Elastic: Taming the LLM with Guardrails for Amazon Bedrock]]></title>
            <link>https://www.elastic.co/observability-labs/blog/llm-observability-amazon-bedrock-guardrails</link>
            <guid isPermaLink="false">llm-observability-amazon-bedrock-guardrails</guid>
            <pubDate>Sun, 02 Mar 2025 00:00:00 GMT</pubDate>
            <description><![CDATA[Elastic’s enhanced Amazon Bedrock integration for Observability now includes Guardrails monitoring, offering real-time visibility into AI safety mechanisms. Track guardrail performance, usage, and policy interventions with pre-built dashboards. Learn how to set up observability for Guardrails and monitor key signals to strengthen safeguards against hallucinations, harmful content, and policy violations.]]></description>
            <content:encoded><![CDATA[<p>In a previous <a href="https://www.elastic.co/observability-labs/blog/llm-observability-aws-bedrock">blog</a> we showed you how to set up observability for your models hosted on Amazon Bedrock using Elastic’s integration. You can now effortlessly enable observability for your Amazon Bedrock guardrails using the enhanced <a href="https://www.elastic.co/guide/en/integrations/current/aws_bedrock.html">Elastic Amazon Bedrock integration</a>. If you previously onboarded the Amazon Bedrock integration, just upgrade it and you will automatically get all guardrails-related updates. The enhanced integration provides a single pane of glass dashboard with two panels - one focusing on overall Bedrock visualizations as well as a separate panel dedicated to Guardrails. You can now ingest and visualize metrics and logs specific to Guardrails, such as guardrail invocation count, invocation latency, text unit utilization, guardrail policy types associated with interventions and many more.</p>
<p>In this blog we will show you how to set up observability for Amazon Bedrock Guardrails, how you can make use of the enhanced dashboards and what key signals to alert on for an effective observability coverage of your Bedrock guardrails.</p>
<h2>Prerequisites</h2>
<p>To follow along with this blog, please make sure you have:</p>
<ul>
<li>An account on <a href="http://cloud.elastic.co/">Elastic Cloud</a> and a deployed stack in AWS (<a href="https://www.elastic.co/guide/en/elastic-stack/current/installing-elastic-stack.html">see instructions here</a>). Ensure you are using version 8.16.2 or higher. Alternatively, you can use <a href="https://www.elastic.co/cloud/serverless">Elastic Cloud Serverless</a>, a fully managed solution that eliminates infrastructure management, automatically scales based on usage, and lets you focus entirely on extracting value from your data.</li>
<li>An AWS account with permissions to pull the necessary data from AWS. See <a href="https://docs.elastic.co/en/integrations/aws#aws-permissions">details in our documentation</a>.</li>
</ul>
<h2>Steps to create a guardrail for Amazon Bedrock</h2>
<p>Before you set up observability for the guardrails, ensure that you have configured guardrails for your model. Follow the steps below to create an Amazon Bedrock Guardrail</p>
<ol>
<li><strong>Access the Amazon Bedrock Console</strong>
<ul>
<li>Sign in to the AWS Management Console with appropriate permissions and navigate to the Amazon Bedrock console.</li>
</ul>
</li>
<li><strong>Navigate to Guardrails</strong>
<ul>
<li>From the left-hand menu, select <strong>Guardrails</strong>.</li>
</ul>
</li>
<li><strong>Create a New Guardrail</strong>
<ul>
<li>Select <strong>Create guardrail</strong>.</li>
<li>Provide a descriptive name, an optional brief description, and specify a message to display when the guardrail blocks the user prompt.
<ul>
<li>Example: <em>Sorry, I am not configured to answer such questions. Kindly ask a different question.</em></li>
</ul>
</li>
</ul>
</li>
<li><strong>Configure Guardrail Policies</strong>
<ul>
<li><strong>Content Filters</strong>: Adjust settings to block harmful content and prompt attacks.</li>
<li><strong>Denied Topics</strong>: Specify topics to block.</li>
<li><strong>Word Filters</strong>: Define specific words or phrases to block.</li>
<li><strong>Sensitive Information Filters</strong>: Set up filters to detect and remove sensitive information.</li>
<li><strong>Contextual Grounding</strong>:
<ul>
<li>Configure the <strong>Grounding Threshold</strong> to set the minimum confidence level for factual accuracy.</li>
<li>Set the <strong>Relevance Threshold</strong> to ensure responses align with user queries.</li>
</ul>
</li>
</ul>
</li>
<li><strong>Review and Create</strong>
<ul>
<li>Review your settings and select <strong>Create</strong> to finalize the guardrail.</li>
</ul>
</li>
<li><strong>Create a Guardrail Version</strong>
<ul>
<li>In the <strong>Version</strong> section, select <strong>Create</strong>.</li>
<li>Optionally add a description, then select <strong>Create Version</strong>.</li>
</ul>
</li>
</ol>
<p><img src="https://www.elastic.co/observability-labs/assets/images/llm-observability-amazon-bedrock-guardrails/guardrails-policy-configuration.png" alt="Amazon Bedrock Guardrails Policy Configurations" /></p>
<p>After creating a version of your guardrail, it's important to note down the <strong>Guardrail ID</strong> and the <strong>Guardrail Version Name</strong>. These identifiers are essential when integrating the guardrail into your application, as you'll need to specify them during guardrail invocation.</p>
<p><img src="https://www.elastic.co/observability-labs/assets/images/llm-observability-amazon-bedrock-guardrails/guardrails-creation-confirmations.png" alt="Amazon Bedrock Guardrails Policy Version" /></p>
<h2>Example code to integrate with Amazon Bedrock guardrails</h2>
<p>Integrating Amazon Bedrock's ChatBedrock into your Python application enables advanced language model interactions with customisable safety measures. By configuring guardrails, you can ensure that the model adheres to predefined policies, preventing it from generating inappropriate or sensitive content.</p>
<p>The following code demonstrates how to integrate Amazon Bedrock with guardrails to enforce contextual grounding in AI-generated responses. It sets up a Bedrock client using AWS credentials, defines a reference grounding statement, and uses the ChatBedrock API to process user queries with contextual constraints. The <strong>converse_with_guardrails</strong> function sends a user query alongside a predefined grounding reference, ensuring that responses align with the provided knowledge source.</p>
<h3>Setting Up Environment Variables</h3>
<p>Before running the script, configure the required <strong>AWS credentials</strong> and <strong>guardrail settings</strong> as environment variables. These variables allow the script to authenticate with Amazon Bedrock and apply the necessary guardrails for safe and controlled AI interactions.</p>
<p>Create a <strong>.env</strong> file in the same directory as your script and add:</p>
<pre><code class="language-bash">AWS_ACCESS_KEY=&quot;your-access-key&quot; 
AWS_SECRET_KEY=&quot;your-secret-key&quot; 
AWS_REGION=&quot;your-aws-region&quot; 
GUARDRAIL_ID=&quot;your-guardrail-id&quot; 
GUARDRAIL_VERSION=&quot;your-guardrail-version&quot;
</code></pre>
<h3>Create a Python script and run</h3>
<p>Create a Python script using the code below and execute it to interact with the Amazon Bedrock Guardrails you set up.</p>
<pre><code class="language-python">import os
import boto3
from dotenv import load_dotenv
from langchain_aws import ChatBedrock
import json
from botocore.exceptions import ClientError

# Load environment variables
load_dotenv()

# Function to check for hallucinations using contextual grounding
def check_hallucination(response):
   output_assessments = response.get(&quot;trace&quot;, {}).get(&quot;guardrail&quot;, {}).get(&quot;outputAssessments&quot;, {})

   # Iterate over all assessments
   for key, assessments in output_assessments.items():
       for assessment in assessments:
           contextual_policy = assessment.get(&quot;contextualGroundingPolicy&quot;, {})
          
           if &quot;filters&quot; in contextual_policy:
               grounding = relevance = None
               grounding_threshold = relevance_threshold = None

               for filter_result in contextual_policy[&quot;filters&quot;]:
                   filter_type = filter_result.get(&quot;type&quot;)
                   if filter_type == &quot;RELEVANCE&quot;:
                       relevance = filter_result.get(&quot;score&quot;, 0)
                       relevance_threshold = filter_result.get(&quot;threshold&quot;, 0)
                   elif filter_type == &quot;GROUNDING&quot;:
                       grounding = filter_result.get(&quot;score&quot;, 0)
                       grounding_threshold = filter_result.get(&quot;threshold&quot;, 0)
          
           if relevance &lt; relevance_threshold or grounding &lt; grounding_threshold:
               return True, relevance, grounding, relevance_threshold, grounding_threshold  # Hallucination detected
  
   return False, relevance, grounding, relevance_threshold, grounding_threshold  # No hallucination detected

def converse_with_guardrails(bedrock_client, messages, grounding_reference):
   message = [
       {
           &quot;role&quot;: &quot;user&quot;,
           &quot;content&quot;: [
               {
                   &quot;guardContent&quot;: {
                       &quot;text&quot;: {
                           &quot;text&quot;: grounding_reference,
                           &quot;qualifiers&quot;: [&quot;grounding_source&quot;],
                       }
                   }
               },
               {
                   &quot;guardContent&quot;: {
                       &quot;text&quot;: {
                           &quot;text&quot;: messages,
                           &quot;qualifiers&quot;: [&quot;query&quot;],
                       }
                   }
               },
           ],
       }
   ]
   converse_config = {
       &quot;modelId&quot;: os.getenv('CHAT_MODEL'),
       &quot;messages&quot;: message,
       &quot;guardrailConfig&quot;: {
           &quot;guardrailIdentifier&quot;: os.getenv(&quot;GUARDRAIL_ID&quot;),
           &quot;guardrailVersion&quot;: os.getenv(&quot;GUARDRAIL_VERSION&quot;),
           &quot;trace&quot;: &quot;enabled&quot;
       },
       &quot;inferenceConfig&quot;: {
           &quot;temperature&quot;: 0.5       
       },
   }
   try:
       response = bedrock_client.converse(**converse_config)
       return response
   except ClientError as e:
       error_message = e.response['Error']['Message']
       print(f&quot;An error occurred: {error_message}&quot;)
       print(&quot;Converse config:&quot;)
       print(json.dumps(converse_config, indent=2))
       return None
  
def pretty_print_response(response, is_hallucination, relevance, relevance_threshold, grounding, grounding_threshold):
   print(&quot;\n&quot; + &quot;=&quot;*60)
   print(&quot; Guardrail Assessment&quot;)
   print(&quot;=&quot;*60)
   # Extract response message safely
   response_text = response.get(&quot;output&quot;, {}).get(&quot;message&quot;, {}).get(&quot;content&quot;, [{}])[0].get(&quot;text&quot;, &quot;N/A&quot;)
   print(&quot;\n **Model Response:**&quot;)
   print(f&quot;   {response_text}&quot;)
   print(&quot;\n **Guardrail Assessment:**&quot;)
   print(f&quot;   Is Hallucination : {is_hallucination}&quot;)
   print(&quot;\n **Contextual Grounding Policy Scores:**&quot;)
   print(f&quot;   - Relevance Score : {relevance:.2f} (Threshold: {relevance_threshold:.2f})&quot;)
   print(f&quot;   - Grounding Score : {grounding:.2f} (Threshold: {grounding_threshold:.2f})&quot;)
   print(&quot;\n&quot; + &quot;=&quot;*60 + &quot;\n&quot;)
  
def main():
   bs = boto3.Session(
       aws_access_key_id=os.getenv('AWS_ACCESS_KEY'),
       aws_secret_access_key=os.getenv('AWS_SECRET_KEY'),
       region_name=os.getenv('AWS_REGION')
   )

   # Initialize Bedrock client
   bedrock_client = bs.client(&quot;bedrock-runtime&quot;)

   # Grounding reference
   grounding_reference = &quot;The Wright brothers made the first powered aircraft flight on December 17, 1903.&quot;

   # User query
   user_query = &quot;Who were the first to fly an airplane?&quot;
  
   # Get model response
   response = converse_with_guardrails(bedrock_client, user_query, grounding_reference)

   # Check for hallucinations
   is_hallucination, relevance, grounding, relevance_threshold, grounding_threshold = check_hallucination(response)

   # Print the results
   pretty_print_response(response, is_hallucination, relevance, relevance_threshold, grounding, grounding_threshold)


if __name__ == &quot;__main__&quot;:
   main()
</code></pre>
<h3>Identifying Hallucinations with Contextual Grounding</h3>
<p>The contextual grounding feature proved effective in identifying potential hallucinations by comparing model responses against reference information. Relevance and grounding scores provided quantitative measures to assess the accuracy of model outputs.</p>
<p>The python script run output below demonstrates how the <strong>Grounding Score</strong> helps detect hallucinations:</p>
<pre><code>============================================================
 Guardrail Assessment
============================================================

 **Model Response:**
   Sorry, I am not configured to answer such questions. Kindly ask a different question.

 **Guardrail Assessment:**
   Is Hallucination : True

 **Contextual Grounding Policy Scores:**
   - Relevance Score : 1.00 (Threshold: 0.99)
   - Grounding Score : 0.03 (Threshold: 0.99)

============================================================
</code></pre>
<p>Here, the <strong>Grounding Score</strong> of <strong>0.03</strong> is significantly lower than the configured threshold of <strong>0.99</strong>, indicating that the response lacks factual accuracy. Since the score falls below the threshold, the system flags the response as a hallucination, highlighting the need to monitor guardrail outputs to ensure AI safety.</p>
<h2>Configuring Amazon Bedrock Guardrails Metrics &amp; Logs Collection</h2>
<p>Elastic makes it easy to collect both logs and metrics from Amazon Bedrock Guardrails using the Amazon Bedrock integration. By default, Elastic provides a curated set of logs and metrics, but you can customize the configuration based on your needs. The integration supports Amazon S3 and Amazon CloudWatch Logs for log collection, along with metrics collection from your chosen AWS region at a specified interval.</p>
<p>Follow these steps to enable the collection of metrics and logs:</p>
<ol>
<li>
<p><strong>Navigate to Amazon Bedrock Settings</strong> - In the AWS Console, go to <strong>Amazon Bedrock</strong> and open the <strong>Settings</strong> section.</p>
</li>
<li>
<p><strong>Choose Logging Destination</strong> - Select whether to send logs to <strong>Amazon S3</strong> or <strong>Amazon CloudWatch Logs</strong>.</p>
</li>
<li>
<p><strong>Provide Required Details</strong></p>
<ul>
<li><strong>If using Amazon S3</strong>, logs can be collected from objects referenced in <strong>S3 notification events</strong> (read from an SQS queue) or by <strong>direct polling</strong> from an S3 bucket.</li>
<li><strong>If using CloudWatch Logs</strong>: you need to create a <strong>CloudWatch log group</strong> and note its <strong>ARN</strong>, as this will be required for configuring both <strong>Amazon Bedrock</strong> and <strong>Elastic Amazon Bedrock integration</strong>.</li>
</ul>
</li>
</ol>
<p><img src="https://www.elastic.co/observability-labs/assets/images/llm-observability-amazon-bedrock-guardrails/amazon-bedrock-settings-configuraiton.png" alt="Amazon Bedrock settings" /></p>
<ol start="4">
<li><strong>Configure Elastic's Amazon Bedrock integration</strong> - In <strong>Elastic</strong>, set up the <strong>Amazon Bedrock integration</strong>, ensuring the logging destination matches the one configured in <strong>Amazon Bedrock</strong>. Logs from your selected source and metrics from your AWS region will be collected automatically.</li>
</ol>
<p><img src="https://www.elastic.co/observability-labs/assets/images/llm-observability-amazon-bedrock-guardrails/amazon-bedrock-integrations-logs-config.png" alt="Amazon Bedrock integration logs configuration" /></p>
<ol start="5">
<li><strong>Accept Defaults or Customize Settings</strong> - Elastic provides a default configuration for logs and metrics collection. You can accept these defaults or adjust settings such as collection intervals to better fit your needs.</li>
</ol>
<p><img src="https://www.elastic.co/observability-labs/assets/images/llm-observability-amazon-bedrock-guardrails/amazon-bedrock-integrations-metrics-config.png" alt="Amazon Bedrock integration guardrails metrics configuration" /></p>
<h2>Understanding the pre-configured dashboard for Amazon Bedrock Guardrails</h2>
<p>You can access the Amazon Bedrock Guardrails dashboard using either of the following methods:</p>
<ol>
<li>
<p><strong>Navigate to the Dashboard Menu</strong>  - Select the <strong>Dashboard</strong> menu option in <strong>Elastic</strong> and search for <strong>[Amazon Bedrock] Guardrails</strong> to open the dashboard.</p>
</li>
<li>
<p><strong>Navigate to the Integrations Menu</strong>  - Open the <strong>Integrations</strong> menu in <strong>Elastic</strong>, select <strong>Amazon Bedrock</strong>, go to the <strong>Assets</strong> tab, and choose <strong>[Amazon Bedrock] Guardrails</strong> from the dashboard assets.</p>
</li>
</ol>
<p><img src="https://www.elastic.co/observability-labs/assets/images/llm-observability-amazon-bedrock-guardrails/amazon-bedrock-guardrails-overview-dashboard.png" alt="Amazon Bedrock settings" /></p>
<p>The Amazon Bedrock Guardrails dashboard in the Elastic integration provides insights into guardrail performance, tracking total invocations, API latency, text unit usage, and intervention rates. It analyzes policy-based interventions, highlighting trends, text consumption, and frequently triggered policies. The dashboard also showcases instances where guardrails modified or blocked responses and offers a detailed breakdown of invocations by policy and content source.</p>
<h3>Guardrail invocation overview</h3>
<p>This dashboard section provides a comprehensive summary of key metrics related to guardrail performance and usage:</p>
<ul>
<li><strong>Total guardrails API invocations</strong>: Displays the overall count of times guardrails were invoked.</li>
<li><strong>Average Guardrails API invocation latency</strong>: Shows the average response time for guardrail API calls, offering insights into system performance.</li>
<li><strong>Total text unit utilization</strong>: Indicates the volume of text processed during guardrail invocations. For pricing of text units refer to Amazon Bedrock pricing page.</li>
<li><strong>Invocations - with and without guardrail interventions</strong>: A pie chart representation showing the distribution of LLM invocations based on guardrail activity. It displays the count of invocations where no guardrail interventions occurred, those where guardrails intervened and detected policy violations, and those where guardrails intervened but found no violations.</li>
</ul>
<p>These metrics help users evaluate guardrail effectiveness, track intervention patterns, and optimize configurations to ensure policy enforcement while maintaining system performance.</p>
<h3>Guardrail policy types for interventions</h3>
<p>This section provides a comprehensive view of guardrail policy interventions and their impact:</p>
<ul>
<li><strong>Interventions by Policy Type</strong>: Bar charts display the number of interventions applied to user inputs and model outputs, categorized by policy type (e.g., Contextual Grounding Policy, Word Policy, Content Policy, Sensitive Information Policy, Topic Policy).</li>
<li><strong>Text Unit Utilization by Policy Type</strong>: Panels highlight the text units consumed by various policy interventions, separately for user inputs and model outputs.</li>
<li><strong>Policy Usage Trends</strong>: A word cloud visualisation reveals the most frequently applied policy types, offering insights into intervention patterns.</li>
</ul>
<p>By analyzing intervention counts, text unit usage, and policy trends, users can identify frequently triggered policies, optimize guardrail settings, and ensure LLM interactions align with compliance and safety requirements.</p>
<p><img src="https://www.elastic.co/observability-labs/assets/images/llm-observability-amazon-bedrock-guardrails/amazon-bedrock-guardrails-overview.png" alt="Amazon Bedrock Guardrails dashboard overview and policy types sections" /></p>
<h3>Prompt and response where guardrails intervened</h3>
<p>This dashboard section displays the original LLM prompt, inputs from various sources (API calls, applications, or chat interfaces), and the corresponding guardrail response. The text panel presents the prompt alongside the model's response after applying guardrail interventions. These interventions occur when input evaluation or model responses violate configured policies, leading to blocked or masked outputs.</p>
<p>The section also includes additional details to enhance visibility into how guardrails operate. It indicates whether a violation was detected, along with the violation type (e.g., <strong>GROUNDING</strong>, <strong>RELEVANCE</strong>) and the action taken (<strong>BLOCKED</strong>, <strong>NONE</strong>). For contextual grounding, the dashboard also shows the filter threshold, which defines the minimum confidence level required for a response to be considered valid, and the <strong>confidence score</strong>, which reflects how well the response aligns with the expected criteria.</p>
<p>By analyzing violations, actions taken, and confidence scores, users can adjust guardrail thresholds to balance blocking unsafe responses and allowing valid ones, ensuring optimal accuracy and compliance. This process is particularly crucial for detecting and mitigating hallucinations—instances where models generate information not grounded in source data. Implementing contextual grounding checks enables the identification of such ungrounded or irrelevant content, enhancing the reliability of applications like retrieval-augmented generation (RAG).</p>
<p><img src="https://www.elastic.co/observability-labs/assets/images/llm-observability-amazon-bedrock-guardrails/guardrails-intervened-logs.png" alt="Amazon Bedrock Guardrails logs where guardrails intervened" /></p>
<h3>Guardrail invocation by guardrail policy</h3>
<p>This section offers insights into the number of Guardrails API invocations, the overall latency, the total text units categorised by various guardrail policies (identified by guardrail ARN) and the policy versions.</p>
<h3>Guardrail invocation by content source (Input &amp; Output)</h3>
<p>This section provides a detailed overview of critical metrics related to guardrail performance and usage. It includes the total number of guardrail invocations, the count of intervention invocations where policies were applied, the volume of text units consumed during these interventions for both user inputs and model outputs and the average guardrail API invocation latency.</p>
<p><img src="https://www.elastic.co/observability-labs/assets/images/llm-observability-amazon-bedrock-guardrails/guardrails-invocationby-policy-contentsource.png" alt="Amazon Bedrock Guardrails invocation by policy and content source" /></p>
<p>These insights help users understand how guardrails operate across different policies and content sources. By analyzing invocation counts, latency, and text unit consumption, users can assess policy effectiveness, track intervention patterns, and optimize configurations. Evaluating how guardrails interact with user inputs and model outputs ensures consistent enforcement, helping refine thresholds and improve compliance strategies.</p>
<h2>Configure SLOs and Alerts</h2>
<p>To create an SLO for monitoring <strong>contextual grounding accuracy</strong>, define a custom query SLI where <strong>good events</strong> are model responses that meet contextual grounding criteria, ensuring factual accuracy and alignment with the provided reference.</p>
<p>A suitable query for tracking good events is:</p>
<pre><code>gen_ai.prompt : &quot;*qualifiers[\\\&quot;grounding_source\\\&quot;]*&quot; and 
(gen_ai.compliance.violation_detected : false or 
not gen_ai.compliance.violation_detected : *)
</code></pre>
<p>The total query considers all relevant interactions having contextual grounding check is:</p>
<pre><code>gen_ai.prompt : &quot;*qualifiers[\\\&quot;grounding_source\\\&quot;]*&quot;
</code></pre>
<p>Set an <strong>SLO target of 99.5%</strong>, ensuring that the vast majority of responses remain factually grounded. This helps detect hallucinations and misaligned outputs in real-time. By continuously monitoring contextual grounding accuracy, you can proactively address inconsistencies, retrain models, or refine RAG pipelines before inaccuracies impact end users.</p>
<p><img src="https://www.elastic.co/observability-labs/assets/images/llm-observability-amazon-bedrock-guardrails/slo-configurations.png" alt="SLO settings for Guardails metrics" /></p>
<p>Elastic's alerting capabilities enable proactive monitoring of key performance metrics. For instance, by setting up an alert on the <strong>average aws_bedrock.guardrails.invocation_latency</strong> with a <strong>500ms</strong> threshold, you can promptly identify and address performance bottlenecks, ensuring that policy enforcement remains efficient without causing unexpected delays.</p>
<p><img src="https://www.elastic.co/observability-labs/assets/images/llm-observability-amazon-bedrock-guardrails/alert-configurations.png" alt="Alert settings for Guardails metrics" /></p>
<h2>Conclusion</h2>
<p>The Elastic Amazon Bedrock integration makes it easy for you to collect a curated set of metrics and logs for your LLM-powered applications using Amazon Bedrock including Guardrails. It comes with an out-of-the-box dashboard which you can further customize for your specific needs.</p>
<p>If you haven’t already done so, read our previous <a href="https://www.elastic.co/observability-labs/blog/llm-observability-aws-bedrock">blog</a> on what you can do with the Amazon Bedrock integration, set up guardrails for your Bedrock models, and enable the <a href="https://www.elastic.co/guide/en/integrations/current/aws_bedrock.html">Bedrock integration</a> to start observing your Bedrock models and guardrails today!</p>]]></content:encoded>
            <category>observability-labs</category>
            <enclosure url="https://www.elastic.co/observability-labs/assets/images/llm-observability-amazon-bedrock-guardrails/llm-observability-aws-bedrock-illustration.png" length="0" type="image/png"/>
        </item>
        <item>
            <title><![CDATA[LLM Observability with the new Amazon Bedrock Integration in Elastic Observability]]></title>
            <link>https://www.elastic.co/observability-labs/blog/llm-observability-aws-bedrock</link>
            <guid isPermaLink="false">llm-observability-aws-bedrock</guid>
            <pubDate>Mon, 25 Nov 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[Elastic's new Amazon Bedrock integration for Observability provides comprehensive insights into Amazon Bedrock LLM performance and usage. Learn about how LLM based metric and log collection in real-time with pre-built dashboards can effectively monitor and resolve LLM invocation errors and performance challenges.]]></description>
            <content:encoded><![CDATA[<p>As organizations increasingly adopt LLMs for AI-powered applications such as content creation, Retrieval-Augmented Generation (RAG), and data analysis, SREs and developers face new challenges. Tasks like monitoring workflows, analyzing input and output, managing query latency, and controlling costs become critical. LLM observability helps address these issues by providing clear insights into how these models perform, allowing teams to quickly identify bottlenecks, optimize configurations, and improve reliability. With better observability, SREs can confidently scale LLM applications, especially on platforms like <a href="https://aws.amazon.com/bedrock/">Amazon Bedrock</a>, while minimizing downtime and keeping costs in check.</p>
<p>Elastic is expanding support for LLM Observability with Elastic Observability's new <a href="https://www.elastic.co/docs/current/integrations/aws_bedrock">Amazon Bedrock integration</a>. This new observability integration provides you with comprehensive visibility into the performance and usage of foundational models from leading AI companies and from Amazon available through Amazon Bedrock. The new Amazon Bedrock Observability integration offers an out-of-the-box experience by simplifying the collection of Amazon Bedrock metrics and logs, making it easier to gain actionable insights and effectively manage your models. The integration is simple to set up and comes with pre-built, out-of-the-box dashboards. With real-time insights, SREs can now monitor, optimize and troubleshoot LLM applications that are using Amazon Bedrock.</p>
<p>This blog will walk through the features available to SREs, such as monitoring invocations, errors, and latency information across various models, along with the usage and performance of LLM requests. Additionally, the blog will show how easy it is to set up and what insights you can gain from Elastic for LLM Observability.</p>
<h2>Prerequisites</h2>
<p>To follow along with this blog, please make sure you have:</p>
<ul>
<li>An account on <a href="http://cloud.elastic.co">Elastic Cloud</a> and a deployed stack in AWS (<a href="https://www.elastic.co/guide/en/elastic-stack/current/installing-elastic-stack.html">see instructions here</a>). Ensure you are using version 8.13 or higher.</li>
<li>An AWS account with permissions to pull the necessary data from AWS. <a href="https://docs.elastic.co/en/integrations/aws#aws-permissions">See details in our documentation</a>.</li>
</ul>
<h2>Configuring Amazon Bedrock Logs Collection</h2>
<p>To collect Amazon Bedrock logs, you can choose from the following options:</p>
<ol>
<li>Amazon Simple Storage Service (Amazon S3)  bucket</li>
<li>Amazon CloudWatch logs</li>
</ol>
<p><strong>S3 Bucket Logs Collection</strong>: When collecting logs from the Amazon S3 bucket, you can retrieve logs from Amazon S3 objects pointed to by Amazon S3 notification events, which are read from an SQS queue, or by directly polling a list of Amazon S3 objects in an Amazon S3 bucket. Refer to Elastic’s <a href="https://www.elastic.co/docs/current/integrations/aws_logs">Custom AWS Logs</a> integration for more details.</p>
<p><strong>CloudWatch Logs Collection</strong>: In this option, you will need to create a <a href="https://console.aws.amazon.com/cloudwatch/">CloudWatch log group</a>. After creating the log group, be sure to note down the ARN of the newly created log group, as you will need it for the Amazon Bedrock settings configuration and Amazon Bedrock integration configuration for logs.</p>
<p>Configure the Amazon Bedrock CloudWatch logs with the Log group ARN to start collecting CloudWatch logs.</p>
<p><img src="https://www.elastic.co/observability-labs/assets/images/llm-observability-aws-bedrock/cloudwatch-logs-configuration.png" alt="" /></p>
<p>Please visit the <a href="https://aws.amazon.com/console/">AWS Console</a> and navigate to the &quot;Settings&quot; section under <a href="https://aws.amazon.com/bedrock/">Amazon Bedrock</a> and select your preferred method of collecting logs. Based on the value you select from the Logging Destination in the Amazon Bedrock settings, you will need to enter either the Amazon S3 location or the CloudWatch log group ARN.</p>
<p><img src="https://www.elastic.co/observability-labs/assets/images/llm-observability-aws-bedrock/aws-bedrock-logs-configuration.png" alt="" /></p>
<h2>Configuring Amazon Bedrock Metrics Collection</h2>
<p>Configure Elastic's Amazon Bedrock integration to collect Amazon Bedrock metrics from your chosen AWS region at the specified collection interval.</p>
<p><img src="https://www.elastic.co/observability-labs/assets/images/llm-observability-aws-bedrock/cloudwatch-metrics-configuration.png" alt="" /></p>
<h2>Maximize Visibility with Out-of-the-Box Dashboards</h2>
<p>Amazon Bedrock integration offers rich out-of-the-box visibility into the performance and usage information of models in Amazon Bedrock, including text and image models. The <strong>Amazon Bedrock Overview</strong> dashboard provides a summarized view of the invocations, errors and latency information across various models.</p>
<p><img src="https://www.elastic.co/observability-labs/assets/images/llm-observability-aws-bedrock/aws-bedrock-dashboard-metric-summary.png" alt="" /></p>
<p>The <strong>Text / Chat metrics</strong> section in the <strong>Amazon Bedrock Overview</strong> dashboard provides insights into token usage for Text models in Amazon Bedrock. This includes use cases such as text content generation, summarization, translation, code generation, question answering, and sentiment analysis.</p>
<p><img src="https://www.elastic.co/observability-labs/assets/images/llm-observability-aws-bedrock/aws-bedrock-dashboard-text-metrics.png" alt="" /></p>
<p>The <strong>Image metrics</strong> section in the <strong>Amazon Bedrock Overview</strong> dashboard offers valuable insights into the usage of Image models in Amazon Bedrock.</p>
<p><img src="https://www.elastic.co/observability-labs/assets/images/llm-observability-aws-bedrock/aws-bedrock-dashboard-image-metrics.png" alt="" /></p>
<p>The <strong>Logs</strong> section of the <strong>Amazon Bedrock Overview</strong> dashboard in Elastic provides detailed insights into the usage and performance of LLM requests. It enables you to monitor key details such as model name, version, LLM prompt and response, usage tokens, request size, completion tokens, response size, and any error codes tied to specific LLM requests.</p>
<p>The detailed logs provide full visibility into raw model interactions, capturing both the inputs (prompts) and the outputs (responses) generated by the models. This transparency enables you to analyze and optimize how your LLM handles different requests, allowing for more precise fine-tuning of both the prompt structure and the resulting model responses. By closely monitoring these interactions, you can refine prompt strategies and enhance the quality and reliability of model outputs.</p>
<p><img src="https://www.elastic.co/observability-labs/assets/images/llm-observability-aws-bedrock/aws-bedrock-dashboard-logs-details.png" alt="" /></p>
<p><strong>Amazon Bedrock Overview</strong> dashboard provides a comprehensive view of the initial and final response times. It includes a percentage comparison graph that highlights the performance differences between these response stages, enabling you to quickly identify efficiency improvements or potential bottlenecks in your LLM interactions.</p>
<p><img src="https://www.elastic.co/observability-labs/assets/images/llm-observability-aws-bedrock/aws-bedrock-dashboard-performance.png" alt="" /></p>
<h2>Creating Alerts and SLOs to Monitor Amazon Bedrock</h2>
<p>As with any Elastic integration, Amazon Bedrock <a href="https://www.elastic.co/docs/current/integrations/aws_bedrock#collecting-bedrock-model-invocation-logs-from-s3-bucket">logs</a> and <a href="https://www.elastic.co/docs/current/integrations/aws_bedrock#metrics">metrics</a> are fully integrated into Elastic Observability, allowing you to leverage features like SLOs, alerting, custom dashboards, and detailed logs exploration.</p>
<p>To create an alert, for example to monitor LLM invocation latency in Amazon Bedrock, you can apply a Custom Threshold rule on the Amazon Bedrock datastream. Set the rule to trigger an alert when the LLM invocation latency exceeds a defined threshold. This ensures proactive monitoring of model performance, allowing you to detect and address latency issues before they impact the user experience.</p>
<p><img src="https://www.elastic.co/observability-labs/assets/images/llm-observability-aws-bedrock/aws-bedrock-alert-invocation-latency.png" alt="" /></p>
<p>When a violation occurs, the Alert Details view linked in the notification provides detailed context, including when the issue began, its current status, and any history of similar violations. This rich information enables rapid triaging, investigation, and root cause analysis to resolve issues efficiently.</p>
<p>Similarly, to create an SLO for monitoring Amazon Bedrock invocation performance for instance, you can define a custom query SLI where good events are those Amazon Bedrock invocations that do not result in client errors or server errors and have latency less than 10 seconds. Set an appropriate SLO target, such as 99%. This will help you identify errors and latency issues in applications using LLMs, allowing you to take timely corrective actions before they affect the overall user experience.</p>
<p><img src="https://www.elastic.co/observability-labs/assets/images/llm-observability-aws-bedrock/aws-bedrock-slo-configuration.png" alt="" /></p>
<p>The image below highlights the SLOs, SLIs, and the remaining error budget for Amazon Bedrock models. The observed violations are a result of deliberately crafted long text generation prompts, which led to extended response times. This example demonstrates how the system tracks performance against defined targets, helping you quickly identify latency issues and performance bottlenecks. By monitoring these metrics, you gain valuable insights for proactive issue triaging, allowing for timely corrective actions and improved user experience of applications using LLM.</p>
<p><img src="https://www.elastic.co/observability-labs/assets/images/llm-observability-aws-bedrock/aws-bedrock-slo-rundata.png" alt="" /></p>
<h2>Try it out today</h2>
<p>The Amazon Bedrock playgrounds provide a console environment to experiment with running inference on different models and configurations before deciding to use them in an application. Start your own 7-day free trial by signing up via AWS Marketplace and quickly spin up a deployment in minutes on any of the Elastic Cloud regions on AWS around the world.</p>
<p>Deploy a cluster on our <a href="https://www.elastic.co/cloud/elasticsearch-service">Elasticsearch Service</a>, <a href="https://www.elastic.co/downloads/">download</a> the Elasticsearch stack, or run <a href="https://aws.amazon.com/marketplace/seller-profile?id=d8f59038-c24c-4a9d-a66d-6711d35d7305">Elastic from AWS Marketplace</a> then spin up the new technical preview of Amazon Bedrock integration, open the curated dashboards in Kibana and start monitoring your Amazon Bedrock service!</p>
]]></content:encoded>
            <category>observability-labs</category>
            <enclosure url="https://www.elastic.co/observability-labs/assets/images/llm-observability-aws-bedrock/LLM-observability-AWS-Bedrock.jpg" length="0" type="image/jpg"/>
        </item>
    </channel>
</rss>