Giter Site home page Giter Site logo

aws-samples / aws-cloudwatch-snapshot-graphs-alert-context Goto Github PK

View Code? Open in Web Editor NEW
14.0 13.0 8.0 26 KB

Code samples related to "Reduce Time to Resolution with Amazon CloudWatch Snapshot Graphs and Alerts” blog post published on the AWS DevOps blog. This sample demonstrates how to integrate CloudWatch snapshot graphs with email alerts to add more context to the alert.

License: MIT No Attribution

JavaScript 100.00%

aws-cloudwatch-snapshot-graphs-alert-context's Introduction

AWS Cloudwatch Snapshot Graphs Alert Context

Code samples related to "Reduce Time to Resolution with Amazon CloudWatch Snapshot Graphs and Alerts” blog post published on the AWS DevOps blog. This sample demonstrates how to integrate CloudWatch snapshot graphs with email alerts to add more context to the alert.

Note that whilst the CloudWatch snapshot graphs API is available in all public regions, the email service used in this sample (Simple Email Service) is only available in a limited number of regions. See the AWS service availability matrix for a full list of SES regions. To run this sample in a region that is not supported by SES you will need to use a different email service.

License Summary

This sample code is made available under a modified MIT license. See the LICENSE file.

Setup Instructions

This project includes code that is intended to run as an AWS Lambda function. Full instructions can be found in the associated blog post on the AWS DevOps blog.

Setup the Lambda:

  1. Download the repository.
  2. Run 'npm install' to create dependencies.
  3. ZIP the entire project 'zip -r snapshotgraphsalarmdemo.zip ./*'
  4. Create a new NodeJS Lambda function and upload the ZIP as the source code.
  5. Set handler to emailer.myHandler.
  6. Increase execution timeout to 30s.
  7. This Lambda function requires an IAM role with permissions for Amazon SES, Amazon SNS (readonly) and Amazon CloudWatch (readonly). This is in addition to the AWSLambdaBasicExecutionRole.
  8. Set the following environment variables - EMAIL_TO_ADDRESS, EMAIL_FROM_ADDRESS, MAIL_SERVER_REGION. Note that the email addresses have to be verified in the Amazon Simple Email Service before emails will be sent. SES is only available in a limited number of regions and you can run the Lambda and SES in different regions by specifying MAIL_SERVER_REGION.

Building the solution:

  1. Create an SNS topic.
  2. Create a CloudWatch alarm and set the SNS topic as the target.
  3. Subscribe the Lambda to the SNS topic.

When the CloudWatch alarm is triggered the Lambda function will send an email to the address set in the Lambda environment variable EMAIL_TO_ADDRESS.

Troubleshooting

  1. Check that Simple Email Service (SES) is available in your region.
  2. Check that your email address has been verified in Amazon Simple Email Service.
  3. View the Lambda log file in CloudWatch.

See the CloudWatch API documentation for GetMetricWidgetImage for more information.

aws-cloudwatch-snapshot-graphs-alert-context's People

Contributors

wisemaniv avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aws-cloudwatch-snapshot-graphs-alert-context's Issues

SES not available in US-Gov-East

I was trying to use your code and then I saw the part about SES. Is there an update so that this can work in us-gov-east without SES? Possibly just using a running EC2 instance or a SMTP server running somewhere else. Thanks!

Cannot show the blue line

Hi, I tried to follow your instruction and cannot show the blue line
fault

beside, is there any way to run on different region? For example, Tokyo...

SyntaxError: Unexpected token

Thanks for such a wonderful code. But I got the following error.
Do you have any idea what I did wrong? It appears though there is something wrong with json data inserted into emailer.js. Since I am a python person rather than node.js, any help will be appreciated.

2018-10-24T22:02:07.325Z 725ac861-d7d8-11e8-9e05-97b47dd9afb0 SyntaxError: Unexpected token e in JSON at position 0 at Object.parse (native) at exports.myHandler (/var/task/emailer.js:43:26)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.