Using AWS Lambda with Lookout for Metrics - Amazon Lookout for Metrics

Using AWS Lambda with Lookout for Metrics

You can use AWS Lambda as a channel for anomaly alerts from an Amazon Lookout for Metrics detector. With a Lambda function, you can process anomaly alerts in your preferred programming language, and use the AWS SDK to interact with other AWS services.

Lambda is a serverless way for you to run code in AWS. Your code only runs and only incurs charges when it is invoked. If you don't already have a Lambda function, see Create a Lambda function with the console in the Lambda Developer Guide to get started.

To create a Lambda alert

  1. Open the Lookout for Metrics console Detectors page.

  2. Choose a detector.

  3. Choose Add alert.

  4. Choose AWS Lambda.

  5. Choose a function.


When you add a Lambda alert to your detector, the Lookout for Metrics console creates a service role with permission to invoke the function.

When your detector finds an anomaly with a severity score that meets or exceeds the alert's threshold, it invokes your Lambda function with an event that contains details about the anomaly. The Lambda runtime converts this document into an object and passes it to your function's handler method. You can use this object to perform additional processing, to record details about the anomaly in a database or storage, or to call another service.

For sample code in all programming languages supported by Lambda, see Lambda sample applications in the AWS Lambda Developer Guide.