Skip to content

AnomalyDetector

Source: src/AWS/CloudWatch/AnomalyDetector.ts

A CloudWatch anomaly detector — trains a model on a metric’s historical data and computes an expected-value band, which alarms can use via the ANOMALY_DETECTION_BAND metric-math function.

Single Metric Detector

const detector = yield* AnomalyDetector("ErrorsDetector", {
Namespace: "AWS/Lambda",
MetricName: "Errors",
Stat: "Sum",
});

Detector on a Custom Metric

// pair with PutMetricData publishing to the same namespace/metric
const detector = yield* AnomalyDetector("PaymentsDetector", {
Namespace: "MyApp/Payments",
MetricName: "PaymentProcessed",
Stat: "Sum",
});
// init — see DescribeAnomalyDetectors
const describeAnomalyDetectors = yield* AWS.CloudWatch.DescribeAnomalyDetectors();
// runtime
const result = yield* describeAnomalyDetectors({ Namespace: "MyApp/Payments" });