Guide · Amazon DevOps Guru · MCP Server Anomaly Detection
Amazon DevOps Guru for MCP Servers — ML-Powered Anomaly Detection for ECS, Lambda, and SQS
Amazon DevOps Guru uses machine learning to automatically detect operational anomalies across the AWS resources that power your MCP server — ECS Fargate tasks, Lambda functions, SQS tool queues, DynamoDB session stores — and surfaces actionable recommendations without requiring you to write a single CloudWatch alarm rule. This guide covers the core concepts (ReactiveInsight vs ProactiveInsight, CAUSAL vs CONTEXTUAL anomalies), how DevOps Guru activates by configuring a resource collection, the @aws-sdk/client-devops-guru SDK calls for listing and retrieving insights, the IAM permissions required, and the per-resource pricing model. For resource collection setup and tag-based coverage, see DevOps Guru Resource Collection. For querying insights and anomaly details, see Working with DevOps Guru Insights. For SNS and EventBridge notification channels, see DevOps Guru Notifications.
TL;DR
DevOps Guru activates when you call UpdateResourceCollection to tell it which AWS resources to baseline — it creates a service-linked role automatically, begins ingesting CloudWatch metrics for those resources, and within 24–48 hours starts generating insights when it detects anomalous patterns. A ReactiveInsight is generated after an anomaly is confirmed (something is already wrong); a ProactiveInsight is generated before the anomaly peaks (ML predicts a problem is about to happen). The IAM action namespace is devops-guru:*; you also need cloudwatch:GetMetricData for the service to function. The first 90 days are free for accounts with fewer than 100 resources; after that, pricing is approximately $0.0028 per resource-hour (~$2 per resource per month).
Why MCP server operators need automated anomaly detection
The standard monitoring stack for a production MCP server — CloudWatch dashboards, manually written alarms on CPU and memory, structured log queries — has a fundamental scaling problem: it only catches the anomalies you anticipated when you wrote the alarm rules. MCP servers fail in ways that are genuinely hard to predict. An LLM tool call that normally completes in 300ms begins returning in 8,000ms because a third-party API added latency. A session store DynamoDB table develops hot partitions as a popular MCP tool writes deterministically keyed items. A Lambda-based MCP server starts throttling because an upstream event source mapper accumulates a backlog. These failure modes do not fit neatly into static thresholds on obvious metrics.
DevOps Guru addresses this by learning what "normal" looks like for each resource in your deployment — not from a configuration file, but from several weeks of actual CloudWatch metric history. When a metric deviates from its learned baseline in a statistically significant way, DevOps Guru generates an insight. Critically, it also groups correlated anomalies across related resources into a single insight, so an incident that simultaneously affects your ECS service CPU, its SQS queue depth, and its DynamoDB read latency appears as one insight with a root cause analysis rather than three independent alarms that you have to correlate manually.
For indie MCP server authors in particular — who typically lack a dedicated SRE team and cannot justify the cost of building a custom ML anomaly detection pipeline — DevOps Guru provides enterprise-grade proactive monitoring at a cost (roughly $2/resource/month) that scales to small deployments.
Key concepts: Insight, Anomaly, and Recommendation
Three concepts dominate the DevOps Guru data model:
Insight
An insight is the top-level finding. It has a type (Reactive or Proactive), a severity (HIGH, MEDIUM, LOW), and a status (ONGOING, CLOSED). An insight groups one or more anomalies detected across related AWS resources, plus a set of recommendations for remediation.
- ReactiveInsight: Generated when DevOps Guru detects that an anomaly has already occurred or is currently happening. The insight status is ONGOING while the anomaly is active and transitions to CLOSED when metrics return to baseline. For MCP servers, a reactive insight might fire when your ECS service CPU spikes above its learned baseline following a surge in concurrent tool calls.
- ProactiveInsight: Generated when ML models predict that a resource is trending toward an anomalous state before the threshold is crossed. A proactive insight gives you a warning window — often 15–60 minutes before impact — to take preventive action. ProactiveInsights require at least two weeks of baseline data before the ML model has enough history to generate reliable predictions.
Anomaly
An anomaly is an individual metric deviation associated with an insight. Each anomaly has a type:
- CAUSAL: The anomaly believed to be the root cause of the insight. For example, an SQS queue's
ApproximateNumberOfMessagesNotVisible(in-flight messages) metric staying elevated for an extended period — indicating stuck message processing in a tool handler. - CONTEXTUAL: An anomaly on a correlated resource that deviated at the same time as the CAUSAL anomaly, suggesting it is a downstream symptom rather than the root cause. For example, a Lambda function's throttle count rising at the same time as the queue depth — confirming that the Lambda handler is the bottleneck, not the queue producer.
Recommendation
Recommendations are actionable remediation steps attached to an insight. Each recommendation has a description, a documentation link, and a reason explaining why DevOps Guru generated it. For MCP servers, common recommendations include scaling out ECS task count, increasing Lambda reserved concurrency, adjusting SQS visibility timeout, or reviewing DynamoDB partition key design.
How DevOps Guru activates: resource collection
Unlike GuardDuty (which you enable once per account) or CloudTrail (which you enable per region), DevOps Guru activates by configuring a resource collection — the set of AWS resources it will baseline and monitor. Until you call UpdateResourceCollection, DevOps Guru does nothing and costs nothing.
There are three collection modes:
- CloudFormation stacks: DevOps Guru monitors all resources within specified CloudFormation stacks. This is the recommended mode for teams that manage MCP server infrastructure with CloudFormation or CDK — it ties coverage directly to your deployment unit.
- Tag-based: DevOps Guru monitors resources tagged with a specific key-value pair. The tag key is
devops-guru-resource-collection; the value can be any string. This mode works for teams that do not use CloudFormation or need to cover resources across multiple stacks with a single DevOps Guru scope. - ALL_RESOURCES: DevOps Guru monitors every supported resource in the account and region. Use this only in small accounts — costs grow linearly with resource count.
Calling UpdateResourceCollection for the first time triggers the creation of the AWSServiceRoleForDevOpsGuru service-linked role automatically, so your IAM principal needs iam:CreateServiceLinkedRole for the initial setup call.
import {
DevOpsGuruClient,
UpdateResourceCollectionCommand,
GetResourceCollectionCommand,
DescribeAccountHealthCommand,
type UpdateResourceCollectionCommandInput,
} from "@aws-sdk/client-devops-guru";
const devopsGuru = new DevOpsGuruClient({ region: "us-east-1" });
// Add a CloudFormation stack to DevOps Guru's resource collection.
// DevOps Guru will begin monitoring all supported resources in the stack.
// The service-linked role is created automatically on first call.
async function addStackToCollection(stackName: string): Promise<void> {
const input: UpdateResourceCollectionCommandInput = {
Action: "ADD",
ResourceCollection: {
CloudFormation: {
StackNames: [stackName],
},
},
};
await devopsGuru.send(new UpdateResourceCollectionCommand(input));
console.log(`Stack ${stackName} added to DevOps Guru resource collection.`);
}
// Verify current resource collection configuration.
async function getCloudFormationCollection(): Promise<string[]> {
const { ResourceCollection } = await devopsGuru.send(
new GetResourceCollectionCommand({
ResourceCollectionType: "AWS_CLOUD_FORMATION",
})
);
return ResourceCollection?.CloudFormation?.StackNames ?? [];
}
// Check account-level health: open reactive insights, open proactive insights,
// and total resource count under DevOps Guru monitoring.
async function checkAccountHealth(): Promise<void> {
const health = await devopsGuru.send(new DescribeAccountHealthCommand({}));
console.log("DevOps Guru account health:");
console.log(
" Open reactive insights:", health.OpenReactiveInsights
);
console.log(
" Open proactive insights:", health.OpenProactiveInsights
);
console.log(
" Analyzed resources:", health.ResourceHours
);
}
Gotcha — 24-48 hour baseline window: After you call UpdateResourceCollection to add resources, DevOps Guru ingests existing CloudWatch metric history (up to two weeks lookback) to establish a baseline. During this initial baselining period, no insights are generated. For proactive insights specifically, DevOps Guru requires at least two weeks of data to train its prediction models. Plan your DevOps Guru rollout well before a production launch — adding it on the day of an incident will not help.
Supported resource types for MCP servers
DevOps Guru supports a specific set of AWS resource types. The ones most relevant to MCP server deployments are:
| Resource type | Monitored metrics (examples) | Common MCP server insight |
|---|---|---|
| ECS Service (Fargate) | CPUUtilization, MemoryUtilization, RunningTaskCount | Sudden CPU spike during batch tool calls; task count dropping below desired |
| Lambda Function | Errors, Throttles, Duration, ConcurrentExecutions | Throttle spikes during peak MCP traffic; duration creep from cold start increases |
| SQS Queue | ApproximateNumberOfMessagesVisible, NumberOfMessagesSent, ApproximateAgeOfOldestMessage | Queue depth buildup when MCP tool handler Lambda is throttled or slow |
| DynamoDB Table | ConsumedReadCapacityUnits, ConsumedWriteCapacityUnits, ThrottledRequests | Read throttles on MCP session store; hot partition from deterministic key design |
| RDS (Aurora/MySQL/Postgres) | DatabaseConnections, CPUUtilization, FreeableMemory | Connection pool exhaustion when MCP server restarts under load |
| API Gateway (REST/HTTP) | 5XXError, Latency, IntegrationLatency, Count | Elevated 5XX rate when backend MCP server is overloaded |
| ElastiCache (Redis) | CurrConnections, Evictions, ReplicationLag | Cache evictions from memory pressure on MCP session store; replication lag on failover |
Gotcha — ECS services must be in the same CloudFormation stack as the DevOps Guru resource collection: If your ECS service is not managed by CloudFormation (you created it via the console or Terraform), you cannot use stack-based collection for it — use tag-based collection instead.
Listing and retrieving insights
Once DevOps Guru has baselined your resources and detected anomalies, you use ListInsights and GetInsight to query the results programmatically. The most common use case is building an operational health check that queries ongoing reactive insights on a schedule and pages your on-call rotation when new HIGH-severity insights appear.
import {
ListInsightsCommand,
GetInsightCommand,
type ListInsightsCommandInput,
type ReactiveInsight,
type ProactiveInsight,
} from "@aws-sdk/client-devops-guru";
// List all ongoing reactive insights (active anomalies right now).
async function listOngoingReactiveInsights(): Promise<ReactiveInsight[]> {
const insights: ReactiveInsight[] = [];
let nextToken: string | undefined;
do {
const input: ListInsightsCommandInput = {
StatusFilter: {
// "Ongoing" filter returns insights that are currently active.
// For historical queries, use "Any" with a StartTimeRange instead.
Ongoing: {
Type: "REACTIVE",
},
},
MaxResults: 100,
NextToken: nextToken,
};
const { ReactiveInsights, NextToken } = await devopsGuru.send(
new ListInsightsCommand(input)
);
insights.push(...(ReactiveInsights ?? []));
nextToken = NextToken;
} while (nextToken);
return insights;
}
// List proactive insights (predicted future anomalies).
async function listOngoingProactiveInsights(): Promise<ProactiveInsight[]> {
const insights: ProactiveInsight[] = [];
let nextToken: string | undefined;
do {
const { ProactiveInsights, NextToken } = await devopsGuru.send(
new ListInsightsCommand({
StatusFilter: {
Ongoing: { Type: "PROACTIVE" },
},
MaxResults: 100,
NextToken: nextToken,
})
);
insights.push(...(ProactiveInsights ?? []));
nextToken = NextToken;
} while (nextToken);
return insights;
}
// Get full insight detail including associated resource ARNs.
// Use this after ListInsights returns an insight ID to get the
// recommendations and anomaly details.
async function getInsightDetail(insightId: string) {
const { ReactiveInsight, ProactiveInsight } = await devopsGuru.send(
new GetInsightCommand({ Id: insightId })
);
const insight = ReactiveInsight ?? ProactiveInsight;
if (!insight) throw new Error(`Insight ${insightId} not found`);
return {
id: insight.Id,
name: insight.Name,
severity: insight.Severity, // HIGH | MEDIUM | LOW
status: insight.Status, // ONGOING | CLOSED
// For reactive: InsightTimeRange.StartTime / EndTime
// For proactive: PredictionTimeRange.StartTime / EndTime
resourceCollection: insight.ResourceCollection,
associatedResourceArns: insight.AssociatedResourceArns,
};
}
Gotcha — ListInsights time range filter: When using the Any or Closed status filter variants (for historical queries), you must provide a time range via StartTimeRange or EndTimeRange using JavaScript Date objects, not epoch seconds. The SDK automatically serializes Date objects to the correct format; passing raw epoch millisecond integers will cause a serialization error.
IAM permissions for DevOps Guru
DevOps Guru requires two categories of IAM permissions: permissions for your application code or operations tooling to call the DevOps Guru API, and permissions for DevOps Guru itself (via its service-linked role) to read CloudWatch metrics.
Application/operator permissions
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "DevOpsGuruManage",
"Effect": "Allow",
"Action": [
"devops-guru:UpdateResourceCollection",
"devops-guru:GetResourceCollection",
"devops-guru:ListInsights",
"devops-guru:GetInsight",
"devops-guru:ListAnomaliesForInsight",
"devops-guru:GetRecommendations",
"devops-guru:PutFeedback",
"devops-guru:DescribeAccountHealth",
"devops-guru:DescribeAccountOverview",
"devops-guru:AddNotificationChannel",
"devops-guru:ListNotificationChannels",
"devops-guru:RemoveNotificationChannel",
"devops-guru:UpdateServiceIntegration",
"devops-guru:DescribeServiceIntegration"
],
"Resource": "*"
},
{
"Sid": "DevOpsGuruServiceLinkedRole",
"Effect": "Allow",
"Action": "iam:CreateServiceLinkedRole",
"Resource": "arn:aws:iam::*:role/aws-service-role/devops-guru.amazonaws.com/AWSServiceRoleForDevOpsGuru",
"Condition": {
"StringLike": {
"iam:AWSServiceName": "devops-guru.amazonaws.com"
}
}
}
]
}
Gotcha — initial setup requires iam:CreateServiceLinkedRole: The first call to UpdateResourceCollection creates the AWSServiceRoleForDevOpsGuru service-linked role if it does not already exist. If your calling principal lacks iam:CreateServiceLinkedRole, this call fails with an AccessDeniedException. You can pre-create the role manually (aws iam create-service-linked-role --aws-service-name devops-guru.amazonaws.com) to avoid granting this permission to automation principals.
Service-linked role permissions
The AWSServiceRoleForDevOpsGuru role is managed by AWS and grants DevOps Guru read access to CloudWatch metrics, CloudWatch Logs insights, and SSM OpsCenter (for creating OpsItems). You do not modify this role's policy — AWS maintains it. However, you must ensure that your ECS task execution role and Lambda execution role do not have explicit Deny statements on cloudwatch:PutMetricData that would prevent CloudWatch from receiving metrics that DevOps Guru needs to analyze.
DevOps Guru vs other AWS monitoring services
DevOps Guru occupies a specific niche in the AWS observability stack. Understanding where it fits — and where it does not replace other tools — helps avoid over-investing in its configuration:
| Service | What it does | Use alongside DevOps Guru? |
|---|---|---|
| CloudWatch Alarms | Threshold-based alerts on specific metrics you define | Yes — alarms for SLO breaches (p99 latency > 2s); DevOps Guru for unexpected patterns you did not anticipate |
| AWS X-Ray | Distributed trace sampling, service map, latency percentiles per operation | Yes — X-Ray for root-causing trace-level latency; DevOps Guru for resource-level anomaly correlation |
| Application Signals | Auto-instrumentation, service topology, SLO tracking | Yes — Application Signals for per-tool SLO tracking; DevOps Guru for detecting infrastructure anomalies beneath the application layer |
| CloudWatch Anomaly Detection | ML-based upper/lower bands on a single metric for use in alarms | Partially — DevOps Guru subsumes single-metric anomaly detection but adds cross-resource correlation and recommendations; use CloudWatch Anomaly Detection for metric-level alarms in dashboards |
| GuardDuty | Security threat detection on CloudTrail, DNS logs, VPC Flow Logs | Yes — GuardDuty detects unauthorized access; DevOps Guru detects operational degradation; complementary scopes |
DevOps Guru is weakest at: very high-frequency anomalies that last under five minutes (its detection window is based on multi-minute CloudWatch metric periods), purely application-layer anomalies that do not manifest as infrastructure metric changes (e.g., malformed tool call responses), and environments where less than two weeks of steady-state metric history exists.
Pricing and cost management
DevOps Guru pricing is based on resource-hours — the number of supported AWS resources under monitoring, multiplied by the number of hours they are monitored:
- Free tier: The first 90 days are free for accounts with fewer than 100 resources under DevOps Guru monitoring. This free tier is per-account, per-region, and applies once per AWS account lifecycle.
- Paid tier: Approximately $0.0028 per resource-hour after the free tier. For a typical MCP server deployment with 10 resources (one ECS service, two Lambda functions, one SQS queue, one DynamoDB table, one API Gateway, one ElastiCache cluster, etc.), that is roughly $20/month.
Use DescribeAccountHealth to check the current resource count under monitoring. The ResourceHours field in the response counts resource-hours consumed in the current calendar month — multiply by $0.0028 to estimate cost.
async function estimateMonthlyDevOpsGuruCost(): Promise<number> {
const { ResourceHours } = await devopsGuru.send(
new DescribeAccountHealthCommand({})
);
const PRICE_PER_RESOURCE_HOUR = 0.0028;
const estimatedMonthlyCost = (ResourceHours ?? 0) * PRICE_PER_RESOURCE_HOUR;
return estimatedMonthlyCost;
}
To control costs, use CloudFormation stack-based collection to limit coverage to only the stacks containing your MCP server infrastructure. Avoid enabling ALL_RESOURCES coverage in accounts with many AWS resources not related to MCP server operations.
Use AliveMCP alongside DevOps Guru: AliveMCP provides real-time external health checks (HTTP ping + MCP protocol validation every 60 seconds) while DevOps Guru provides internal infrastructure anomaly detection. External health check failures (what AliveMCP detects) can lag infrastructure anomalies (what DevOps Guru detects) by several minutes — having both gives you earlier warning and faster root cause identification.