How aws-samples/failure-analysis-assistant works
Main Components
• AWS API Gateway: Acts as the HTTP endpoint (with public URL) for Slack events (such as slash commands and interactive components). Make sure to denote that API Gateway has CloudWatch logging enabled, and note that AWS WAF is recommended if deployed in production.
• Lambda Functions: Several Lambda functions are present:
• fa2-lambda: The core function that handles the main failure analysis workflow.
• findings-report: Generates detailed reports from Security Hub or GuardDuty findings.
• metrics-insight: Handles on-demand metric-related queries via Slack.
• slack-handler: Processes incoming Slack events/commands.
• Lambda Layers: Shared modules used by the Lambda functions, for example, the nodejs layer that includes modules required to support functionality (like rendering or additional libraries).
• AWS Services for Data Acquisition:
• CloudWatch Logs: The primary store for log data that are queried based on time ranges.
• Amazon Athena (optional): Used for querying logs from S3 (e.g., ALB or CloudTrail logs).
• AWS X-Ray (optional): Provides trace information when enabled.
• Amazon Bedrock / LLM: The LLM service (e.g., Claude 3 Sonnet) is invoked to process prompt templates (in lambda/lib/prompts.ts) and generate insights or summaries for incident analysis.
• CDK Deployment: Represent this component separately as it is responsible for provisioning and managing the whole infrastructure using CloudFormation through AWS CDK stacks and constructs (files in lib/stack and lib/constructs).
Relationships & Interactions
• The Slack event triggers the Lambda function (via API Gateway) when users interact with the presented form. Once users submit their chosen time range and event details, the Lambda function (fa2-lambda) begins processing.
• The Lambda then queries various sources (CloudWatch Logs, Athena, X-Ray) and constructs a prompt using the defined templates.
• The Lambda sends this prompt to the LLM (Amazon Bedrock) and, upon receiving a response, sends the insight back to Slack.
• For optional but additional functionality, other Lambda functions (metrics-insight and findings-report) handle specific interactions triggered by Slack slash commands.
Architectural Patterns & Design Principles
• Modular Microservice-based Approach: Each Lambda function is dedicated to a clear responsibility, ensuring separation of concerns.
• Event-driven Architecture: The design is heavily event-driven (triggered by Slack events and alarms) with asynchronous processing.
• Infrastructure as Code (IaC): The CDK and associated constructs/stacks indicate an IaC approach for managing resources.
• Use of Shared Libraries: Both in the lambda/lib and lambda/layers directories for common functionalities, promoting code reuse and maintainability.