Guide · Amazon DevOps Guru · Insights and Anomalies
Amazon DevOps Guru Insights for MCP Servers — ListInsights, GetRecommendations, and PutFeedback
Once Amazon DevOps Guru detects anomalies in your MCP server infrastructure, the insights it generates are queryable via a structured API that lets you build operational dashboards, integrate with incident management tools, and train the ML model to reduce false positives over time. This guide covers the ListInsights status filter variants (Ongoing, Closed, Any), the GetInsight response structure, paginating anomalies within an insight via ListAnomaliesForInsight (CAUSAL vs CONTEXTUAL types), retrieving remediation steps with GetRecommendations, and providing feedback with PutFeedback to improve future insight quality. For enabling DevOps Guru and configuring resource coverage, see Resource Collection. For alert delivery via SNS and EventBridge, see Notifications.
TL;DR
ListInsights requires a StatusFilter that specifies exactly one of three variants: Ongoing (currently active anomalies), Closed (resolved, filtered by EndTimeRange), or Any (both, filtered by StartTimeRange). Both Closed and Any require a time range using JavaScript Date objects. ListAnomaliesForInsight returns anomalies scoped to a specific insight ID; each anomaly has type CAUSAL (root cause) or CONTEXTUAL (downstream symptom). GetRecommendations returns actionable steps tied to the specific anomaly patterns detected. Submit PutFeedback with VALID_FINDING or INVALID_FINDING after each incident triage to improve detection accuracy over time — DevOps Guru uses feedback to adjust its ML models per account.
Insight lifecycle
Understanding the insight lifecycle is essential for building reliable polling and alerting logic. A reactive insight moves through three states:
- ONGOING: DevOps Guru has detected an active anomaly and the affected metrics have not returned to baseline. New anomalies can be added to an ongoing insight as they are detected on correlated resources. This is the state you alert on immediately.
- CLOSED: All associated anomalies have resolved — metrics have returned to their learned baselines. The insight is closed automatically by DevOps Guru; you cannot close it manually. Closed insights are retained for 90 days.
Proactive insights follow a slightly different lifecycle because they describe predicted future anomalies:
- ONGOING: DevOps Guru predicts an anomaly is approaching. The
PredictionTimeRange.StartTimefield estimates when the anomaly is expected to begin. - CLOSED: The prediction window has passed. Either the predicted anomaly occurred and resolved (confirmed), or it did not occur (false positive). Submit
PutFeedbackafter each proactive insight to tell DevOps Guru which outcome happened.
ListInsights: status filter variants
The ListInsights API requires a StatusFilter containing exactly one of the Ongoing, Closed, or Any sub-fields. The choice determines both what insights are returned and what filtering options are available:
import {
DevOpsGuruClient,
ListInsightsCommand,
GetInsightCommand,
ListAnomaliesForInsightCommand,
GetRecommendationsCommand,
PutFeedbackCommand,
type ReactiveInsight,
type ProactiveInsight,
type ListInsightsCommandInput,
} from "@aws-sdk/client-devops-guru";
const devopsGuru = new DevOpsGuruClient({ region: process.env.AWS_REGION! });
// --- Variant 1: Ongoing filter ---
// Returns all currently active reactive or proactive insights.
// No time range required — returns everything currently ONGOING.
async function listOngoingInsights(
type: "REACTIVE" | "PROACTIVE"
): Promise<Array<ReactiveInsight | ProactiveInsight>> {
const all: Array<ReactiveInsight | ProactiveInsight> = [];
let nextToken: string | undefined;
do {
const input: ListInsightsCommandInput = {
StatusFilter: {
Ongoing: { Type: type },
},
MaxResults: 100,
NextToken: nextToken,
};
const { ReactiveInsights, ProactiveInsights, NextToken } =
await devopsGuru.send(new ListInsightsCommand(input));
all.push(...(ReactiveInsights ?? []), ...(ProactiveInsights ?? []));
nextToken = NextToken;
} while (nextToken);
return all;
}
// --- Variant 2: Closed filter ---
// Returns insights that CLOSED within the specified EndTimeRange.
// FromTime/ToTime are JavaScript Date objects — not epoch integers.
async function listRecentlyClosedInsights(
windowHours = 24
): Promise<ReactiveInsight[]> {
const toTime = new Date();
const fromTime = new Date(toTime.getTime() - windowHours * 60 * 60 * 1000);
const insights: ReactiveInsight[] = [];
let nextToken: string | undefined;
do {
const { ReactiveInsights, NextToken } = await devopsGuru.send(
new ListInsightsCommand({
StatusFilter: {
Closed: {
Type: "REACTIVE",
EndTimeRange: {
FromTime: fromTime,
ToTime: toTime,
},
},
},
MaxResults: 100,
NextToken: nextToken,
})
);
insights.push(...(ReactiveInsights ?? []));
nextToken = NextToken;
} while (nextToken);
return insights;
}
// --- Variant 3: Any filter ---
// Returns all insights (ONGOING + CLOSED) with StartTime in the given range.
// Use this for incident retrospectives: "all insights from the past week".
async function listAllInsightsInWindow(
startHoursAgo: number,
endHoursAgo = 0
): Promise<Array<ReactiveInsight | ProactiveInsight>> {
const now = new Date();
const fromTime = new Date(now.getTime() - startHoursAgo * 3600 * 1000);
const toTime = new Date(now.getTime() - endHoursAgo * 3600 * 1000);
const all: Array<ReactiveInsight | ProactiveInsight> = [];
let nextToken: string | undefined;
do {
const { ReactiveInsights, ProactiveInsights, NextToken } =
await devopsGuru.send(
new ListInsightsCommand({
StatusFilter: {
Any: {
Type: "REACTIVE",
StartTimeRange: { FromTime: fromTime, ToTime: toTime },
},
},
MaxResults: 100,
NextToken: nextToken,
})
);
all.push(...(ReactiveInsights ?? []), ...(ProactiveInsights ?? []));
nextToken = NextToken;
} while (nextToken);
return all;
}
Gotcha — ListInsights returns only IDs and high-level metadata: The ReactiveInsight and ProactiveInsight objects returned by ListInsights contain the insight ID, name, severity, status, and time range, but NOT the associated anomalies or recommendations. Call GetInsight with the insight ID to retrieve associated resource ARNs and resource collection. Call ListAnomaliesForInsight and GetRecommendations for the full detail needed to triage and remediate.
GetInsight: full insight detail
async function getInsightFull(insightId: string) {
const response = await devopsGuru.send(
new GetInsightCommand({ Id: insightId })
);
// GetInsight returns either ReactiveInsight or ProactiveInsight, not both.
const insight = response.ReactiveInsight ?? response.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 ReactiveInsight: InsightTimeRange with StartTime and EndTime
// For ProactiveInsight: PredictionTimeRange with StartTime and EndTime
insightTimeRange:
"InsightTimeRange" in insight
? insight.InsightTimeRange
: undefined,
predictionTimeRange:
"PredictionTimeRange" in insight
? insight.PredictionTimeRange
: undefined,
// The CloudFormation stacks or tag filters whose resources are involved
resourceCollection: insight.ResourceCollection,
// ARNs of AWS resources associated with this insight
associatedResourceArns: insight.AssociatedResourceArns ?? [],
};
}
Gotcha — AssociatedResourceArns can be empty on fresh insights: DevOps Guru populates AssociatedResourceArns as it correlates anomalies across resources. On a very recently opened insight (within the first few minutes), this array may be empty even though the insight is ONGOING. Call ListAnomaliesForInsight to get per-anomaly resource details, which populate faster.
ListAnomaliesForInsight: CAUSAL vs CONTEXTUAL
An insight groups multiple anomalies — metric deviations on individual AWS resources. Each anomaly is classified as either CAUSAL (the root cause DevOps Guru identified) or CONTEXTUAL (a correlated symptom on a related resource). For MCP server incident triage, start with the CAUSAL anomaly to identify the resource that caused the problem, then review CONTEXTUAL anomalies to understand downstream impact.
import {
ListAnomaliesForInsightCommand,
type ReactiveAnomaly,
type ProactiveAnomaly,
} from "@aws-sdk/client-devops-guru";
async function getInsightAnomalies(insightId: string): Promise<{
causal: ReactiveAnomaly[];
contextual: ReactiveAnomaly[];
}> {
const causal: ReactiveAnomaly[] = [];
const contextual: ReactiveAnomaly[] = [];
let nextToken: string | undefined;
do {
const { ReactiveAnomalies, NextToken } = await devopsGuru.send(
new ListAnomaliesForInsightCommand({
InsightId: insightId,
MaxResults: 500, // max allowed per page
NextToken: nextToken,
})
);
for (const anomaly of ReactiveAnomalies ?? []) {
if (anomaly.Type === "CAUSAL") {
causal.push(anomaly);
} else {
contextual.push(anomaly); // "CONTEXTUAL"
}
}
nextToken = NextToken;
} while (nextToken);
return { causal, contextual };
}
// Extract the CloudWatch metric details from each anomaly to identify
// which metric and resource is anomalous.
function describeAnomaly(anomaly: ReactiveAnomaly): void {
console.log("Anomaly ID:", anomaly.Id);
console.log("Type:", anomaly.Type); // CAUSAL | CONTEXTUAL
console.log(
"Anomaly time range:",
anomaly.AnomalyTimeRange?.StartTime,
"→",
anomaly.AnomalyTimeRange?.EndTime
);
// AnomalyReportedTimeRange is when DevOps Guru first reported this anomaly
// vs AnomalyTimeRange which is when the metric actually deviated
console.log(
"Reported at:",
anomaly.AnomalyReportedTimeRange?.OpenTime
);
// SourceDetails contains the specific CloudWatch metric that was anomalous
for (const source of anomaly.SourceDetails?.CloudWatchMetrics ?? []) {
console.log(
" Metric:",
source.Namespace, // e.g., "AWS/ECS"
"/",
source.MetricName, // e.g., "CPUUtilization"
"on",
source.Dimensions?.map((d) => `${d.Name}=${d.Value}`).join(", ")
);
console.log(" Stat:", source.Stat); // "Average" | "Sum" | "p99" etc.
console.log(" Period:", source.Period, "seconds");
}
// AssociatedResources links the anomaly to the specific AWS resource ARN
for (const resource of anomaly.AssociatedResources ?? []) {
console.log(" Resource:", resource.Type, resource.Name);
}
}
Gotcha — AnomalyTimeRange vs AnomalyReportedTimeRange: These two time ranges are different and both are useful. AnomalyTimeRange tells you when the metric actually started deviating from baseline. AnomalyReportedTimeRange.OpenTime tells you when DevOps Guru first reported the anomaly to the insight. The gap between these is DevOps Guru's detection latency — typically 5–15 minutes for reactive anomalies. When correlating a DevOps Guru alert with other incident signals (CloudWatch alarms, AliveMCP downtime alerts), use AnomalyTimeRange.StartTime, not the report time.
GetRecommendations: actionable remediation steps
For each insight, DevOps Guru generates one or more recommendations based on the patterns of anomalies it detected. Recommendations include a human-readable description, a documentation link, and a list of related anomalies explaining why the recommendation was generated.
import { GetRecommendationsCommand } from "@aws-sdk/client-devops-guru";
async function getInsightRecommendations(insightId: string): Promise<void> {
let nextToken: string | undefined;
do {
const { Recommendations, NextToken } = await devopsGuru.send(
new GetRecommendationsCommand({
InsightId: insightId,
// Locale defaults to "EN_US". DevOps Guru supports localized
// recommendations in EN_US, DE_DE, JA_JP, IT_IT, ZH_CN, KO_KR,
// FR_FR, ZH_TW, ES_ES, PT_BR.
Locale: "EN_US",
NextToken: nextToken,
})
);
for (const rec of Recommendations ?? []) {
console.log("Recommendation:", rec.Name);
console.log(" Reason:", rec.Reason);
console.log(" Description:", rec.Description);
console.log(" Link:", rec.Link); // AWS documentation URL
// RelatedAnomalies links each recommendation to the specific
// anomalies that triggered it.
for (const relatedAnomaly of rec.RelatedAnomalies ?? []) {
for (const resource of relatedAnomaly.Resources ?? []) {
console.log(" Triggered by resource:", resource.Name);
}
for (const event of relatedAnomaly.SourceDetails ?? []) {
console.log(
" Source metric:",
event.CloudWatchMetrics
?.map((m) => `${m.MetricName}/${m.Namespace}`)
.join(", ")
);
}
}
}
nextToken = NextToken;
} while (nextToken);
}
Common DevOps Guru recommendations for MCP server deployments:
- ECS CPU spike: "Review recent ECS task count changes and consider scaling out your ECS service. Check if a deployment or config change occurred at the anomaly start time."
- Lambda throttles: "Increase the reserved concurrency for your Lambda function or request a service quota increase for concurrent executions in this region."
- SQS queue depth: "Review your message processing Lambda's error rate and duration. Consider increasing Lambda concurrency or reviewing visibility timeout settings."
- DynamoDB throttles: "Review your table's partition key design. Consider using DynamoDB Accelerator (DAX) for read-heavy workloads or switching to on-demand capacity mode."
PutFeedback: training the ML model
DevOps Guru uses per-account feedback to refine its anomaly detection models. After triaging each insight — whether it was a real incident or a false positive — submit feedback using PutFeedback. This is especially important during the first few months after enabling DevOps Guru, when the model is still learning the normal patterns of your specific MCP server deployment.
import {
PutFeedbackCommand,
InsightFeedbackOption,
} from "@aws-sdk/client-devops-guru";
// Submit feedback after reviewing an insight.
// VALID_COLLECTION: The insight correctly identified a real anomaly, and the
// associated resources were the right ones to include in the insight.
// INVALID_COLLECTION: The insight grouped unrelated resources together
// (the anomaly was real but the correlation was wrong).
// VALID_FINDING: The insight correctly identified a real problem.
// INVALID_FINDING: The insight was a false positive — no real problem occurred.
async function submitInsightFeedback(
insightId: string,
feedback: "VALID_COLLECTION" | "INVALID_COLLECTION" | "VALID_FINDING" | "INVALID_FINDING"
): Promise<void> {
await devopsGuru.send(
new PutFeedbackCommand({
InsightFeedback: {
Id: insightId,
Feedback: feedback as InsightFeedbackOption,
},
})
);
console.log(`Feedback ${feedback} submitted for insight ${insightId}`);
}
// Practical triage workflow for MCP server incidents:
async function triageInsight(insightId: string): Promise<void> {
// 1. Get insight detail
const { ReactiveInsight } = await devopsGuru.send(
new GetInsightCommand({ Id: insightId })
);
if (!ReactiveInsight) return;
console.log("Severity:", ReactiveInsight.Severity);
console.log("Status:", ReactiveInsight.Status);
console.log(
"Started:",
ReactiveInsight.InsightTimeRange?.StartTime
);
// 2. Get anomaly details to find root cause
const { causal, contextual } = await getInsightAnomalies(insightId);
console.log(`CAUSAL anomalies: ${causal.length}`);
console.log(`CONTEXTUAL anomalies: ${contextual.length}`);
causal.forEach(describeAnomaly);
// 3. Get recommendations
await getInsightRecommendations(insightId);
// 4. After triage, submit feedback
// If the incident was real: VALID_FINDING
// If DevOps Guru correctly identified the impacted resources: VALID_COLLECTION
// Both can be submitted; VALID_FINDING is the most impactful for model training
await submitInsightFeedback(insightId, "VALID_FINDING");
}
Gotcha — feedback only improves future insights, not the current one: PutFeedback sends a training signal to DevOps Guru's ML model for future insight generation. It does not change the current insight's status, severity, or recommendations. The effect accumulates over weeks as the model re-calibrates. Submit feedback consistently — even a few minutes per incident triage pays dividends over months of operation.
Gotcha — INVALID_FINDING reduces sensitivity for similar patterns: Submitting INVALID_FINDING tells DevOps Guru that the specific metric pattern that triggered this insight is not meaningful in your environment. If you submit this for a genuinely anomalous pattern (a known planned event like a deployment that temporarily spiked CPU), use INVALID_COLLECTION instead — this tells DevOps Guru the insight was real but the resource grouping was wrong.
Building an operational health dashboard
The following pattern polls DevOps Guru for active insights on a schedule and publishes a summary to Slack. Use this as a lightweight operational overview for MCP server teams without a full incident management platform:
import { DescribeAccountOverviewCommand } from "@aws-sdk/client-devops-guru";
// Get account-wide insight summary for a time window.
// Use this for a "weekly ops review" digest.
async function getAccountOverview(fromTime: Date, toTime: Date): Promise<void> {
const overview = await devopsGuru.send(
new DescribeAccountOverviewCommand({
FromTime: fromTime,
ToTime: toTime,
})
);
console.log(
"Reactive insights in window:",
overview.ReactiveInsights
);
console.log(
"Proactive insights in window:",
overview.ProactiveInsights
);
console.log(
"MTTR (mean time to recover):",
overview.MeanTimeToRecoverInMilliseconds,
"ms"
);
}
// Health check function: returns true if no HIGH-severity reactive
// insights are currently ONGOING. Use this in your MCP server's
// /health endpoint to surface infrastructure anomalies.
async function hasActiveHighSeverityAnomaly(): Promise<boolean> {
const { ReactiveInsights } = await devopsGuru.send(
new ListInsightsCommand({
StatusFilter: { Ongoing: { Type: "REACTIVE" } },
MaxResults: 100,
})
);
return (ReactiveInsights ?? []).some(
(insight) => insight.Severity === "HIGH"
);
}
The MeanTimeToRecoverInMilliseconds field in DescribeAccountOverview gives you a rolling MTTR metric for all reactive insights within the time window — a useful KPI for MCP server reliability reporting alongside the uptime percentage from AliveMCP's monitoring data. Tracking these two metrics together (uptime % from external probing + MTTR from internal infrastructure anomaly recovery) gives a complete picture of MCP server operational health.