0

Project Name: Bedrock-ICYM (I See You Monitoring)

This module sets up a pipeline to collect and analyze observability and metadata data for Amazon Bedrock applications, including Knowledge Bases, Agents, Invoke Model, Function Calling, and Guardrails. The pipeline ingests JSON data into Amazon Kinesis Firehose, processes the data by flattening nest

Example · مثالaws

Content

Project Name: Bedrock-ICYM (I See You Monitoring)

Observability and Evaluation Custom Solution for Amazon Bedrock Applications

This module sets up a pipeline to collect and analyze observability and metadata data for Amazon Bedrock applications, including Knowledge Bases, Agents, Invoke Model, Function Calling, and Guardrails. The pipeline ingests JSON data into Amazon Kinesis Firehose, processes the data by flattening nested JSON structures using a Lambda function, and stores the processed data in an S3 bucket. A Glue Crawler then creates a table in a Glue database, allowing the data to be queried using Athena for observability and tracking purposes and building a business intelligence dashboard using Amazon QuickSight.

Prerequisites

Before you can use this solution, you need to set up the required AWS resources. This can be done using the provided CloudFormation template (observability-template.yaml).

Deploying the CloudFormation Template

  1. Clone this repository to your local machine.
  2. Navigate to the project directory.
  3. Navigate to AWS Console, search and open CloudFormation. Click on create stack, and now you can upload the pre-requisite.yaml CloudFormation template using AWS Console.
  4. [Optionally] You can skip step 3 and run the yaml_file_deployment.ipynb jupyter notebook to deploy the CloudFormation template. Make sure that the pre-requisite.yaml file is available in the same directory.

Overview

Tracking observability and metadata is crucial for understanding application performance, user behavior, and identifying areas for improvement, which can ultimately lead to better user experiences and informed business decisions.

This pipeline helps track various aspects of Amazon Bedrock Generative AI applications, including:

  • User input: The user's query or input to the application.
  • LLM response: The response generated by the Large Language Model (LLM) for the user's input.
  • Response duration: The time taken by the LLM to generate the response.
  • Application metadata: Additional metadata related to the application, such as the application name, user ID of the user interacting with the application, and much more.
  • Knowledge Base evaluation: Metrics and insights related to the performance and effectiveness of the Knowledge Bases used in the application.
  • Agent evaluation: Metrics and insights related to the performance and behavior of the Agents used in the application.
  • Response evaluation: Metrics and insights related to the quality and relevance of the responses generated by the application.

By capturing and storing this data, we can gain insights into the application's performance, user behavior, and potential areas for improvement. Additionally, the collected data can be used to build business intelligence dashboards using Amazon QuickSight, enabling data-driven decision-making and optimizing the application's performance.

Components

The CloudFormation template creates resources for observability and tracking metadata for Amazon Bedrock applications, including Knowledge Bases, Agents, Invoke Model, Function Calling, and Guardrails.

  1. S3 Bucket: An Amazon S3 bucket is created to store the observability and metadata data for the Amazon Bedrock applications.
  1. IAM Roles and Policies: The template defines IAM roles and policies to grant necessary permissions for different components of the pipeline.
  1. Lambda Function: A Lambda function is created to flatten nested JSON data from the Kinesis Firehose records. The function is written in Python 3.9 and has a memory allocation of 256 MB and a timeout of 120 seconds.
  1. CloudWatch Log Group: A CloudWatch Log Group is created to store logs for the Lambda function, with logs retained for 7 days.
  1. Kinesis Firehose Delivery Stream: A Kinesis Firehose Delivery Stream is created to ingest data directly into the S3 bucket. It includes buffering and compression settings, and a processing configuration that invokes the Lambda function to flatten the incoming JSON data.
  1. AWS Glue Database: An AWS Glue database is created to store the metadata for the observability and metadata data stored in the S3 bucket.
  1. AWS Glue Crawler: An AWS Glue Crawler is created to crawl the data stored in the S3 bucket and create a table in the Glue database, allowing the data to be queried using Athena.
  1. Outputs: The template outputs the names and ARNs of the created resources for reference after the stack is created.

Contributing

If you'd like to contribute to this project, please follow the standard GitHub workflow:

  1. Fork the repository
  2. Create a new branch for your feature or bug fix
  3. Make your changes and commit them with descriptive commit messages
  4. Push your changes to your forked repository
  5. Create a pull request against the main repository

Please ensure that your code follows the project's coding standards and includes appropriate tests.

License

This project is licensed under the [MIT License](LICENSE).

Source and license

Source
Amazon Bedrock Samples
Original
aws-samples/amazon-bedrock-samples/evaluation-observe/Custom-Observability-Solution/1. Pre-Requisite
License
MIT