Add AI-powered cost anomaly detection: Bedrock insights, ML forecasting, bot detection & FinOps dashboard#1
Open
sunilp303 wants to merge 2 commits into
Open
Add AI-powered cost anomaly detection: Bedrock insights, ML forecasting, bot detection & FinOps dashboard#1sunilp303 wants to merge 2 commits into
sunilp303 wants to merge 2 commits into
Conversation
…tection, and FinOps dashboard - HistoricalDataManager: persists daily per-service costs to DynamoDB (90-day TTL) for time-series ML analysis - MLForecastingEngine: pure-Python Holt double-exponential smoothing for spend forecasting + Z-score statistical anomaly detection (no external deps) - BotAttackDetector: correlates CloudWatch traffic spikes (Lambda/API GW/CloudFront) with cost anomaly services to flag potential bot/DDoS attacks - BedrockAnalyzer: calls Amazon Nova Lite via Bedrock with full anomaly context; returns severity, root-cause narrative, immediate actions, and FinOps recommendations - CloudWatchMetricsPublisher: pushes 7 custom metrics to CostMonitor namespace (actual spend, forecast, anomaly counts, bot signals, per-service scores) - Terraform: adds DynamoDB table, Bedrock/CW/Lambda IAM permissions, two CloudWatch alarms, and a 4-row FinOps dashboard (actual vs forecast, anomaly counts, KPI tiles) - All new features fail silently so existing rule-based alerts are never blocked - Lambda memory bumped 256→512 MB; threshold_percentage fixed from -50 to 15 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Documents Bedrock AI analysis, ML forecasting, Z-score detection, bot attack detection, DynamoDB cost history, CloudWatch custom metrics, and the new FinOps dashboard. Adds configuration tables for all new variables, cost estimates, troubleshooting guides for each new component, and updated architecture diagram. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
CostMonitornamespace every run (actual/forecast spend, rule-based and statistical anomaly counts, bot signals, per-service scores)Infrastructure changes (
terraform/)aws_dynamodb_table.cost_historyttlfieldaws_iam_role_policy.lambda_policybedrock:InvokeModel,cloudwatch:Put/Get,lambda:ListFunctionsaws_lambda_function.billing_monitoraws_cloudwatch_metric_alarmx2aws_cloudwatch_dashboard.billing_monitorterraform.tfvarsthreshold_percentagefrom-50?15; added AI/ML config blockNew variables
bedrock_model_idamazon.nova-lite-v1:0amazon.nova-pro-v1:0or Claude Haiku for richer analysisbedrock_regionus-east-1enable_bedrocktrueenable_bot_detectiontruecost_history_retention_days90cloudwatch_namespaceCostMonitorReviewer notes
try/except- a Bedrock outage or DynamoDB throttle never blocks the existing rule-based SNS alertstatisticsmodule) so no Lambda layer is requiredlambda:ListFunctions(limited to 20 functions) andGetMetricStatistics; disable withenable_bot_detection = falseif IAM is constrainedthreshold_percentage = -50bug interraform.tfvars(which caused alerts only on 50%+ cost decreases) is fixed to15Test plan
terraform planshows expected new resources (DynamoDB table, 2 alarms, updated dashboard, updated IAM policy)CostMonitornamespace?? Generated with Claude Code