Basic instructions on how to use AWS for monitoring your websites. Note that I did not include instructions on creating the SNS topic, but check out the link in the Resources section for instructions on that one.
- Go to Lambda
- Click on
Create Function
button - Select a function from a
lambda-canary
blueprint - Enter a name like
check_AzuriteMaps
Choose an existing role
,service-role/lambda_canary_role
- Under the
Rule
, select theone_minute
rule - Enable the trigger
- Leave the function code as it is
- Under the
site
enivornment variable, enter the URL of the site - Under the 'expected`enivornment variable, enter the expected text on that site
- Click on the
Create Function
button
The following instructions will create an alarm that will run each minute and when it detects the website is down, it will send an email to the email address previously configured in the SNS topic Websites_status_alarms
. It will only send this email once during the same failure (it will not repeat the emails after one minute). Once the website is up again, it will send a new email stating the alarm is now OK.
- Go to CloudWatch
- Click on the
Alarms
in the left menu. - Click on the
Create Alarm
button. - In the
1. Select Metric
upper tab, in theBrowse Metric
combo box, selectLambda
and then, under theLambda > By Function Name
, find appropriate function name (likecheck_azuritemaps
) and chooseErrors
metric name. - Click on the
2. Define Alarm
tab at the top of the dialog. Name
should be something that easily identifies which website is down (likeAzuriteMaps is down
).- Set
Whenever
to>= 1
(leave the defaultfor 1 out of 1 datapoints
). - Under
Actions
section, we will add two notifications (one for when the alarm is triggered and another for when the alarm is back to OK status): a. 'Whenever this alarm' should haveState is ALARM
. b.Send notification to
should haveWebsites_status_alarms
(a SNS topic which we previously configured to send email to our email address). c. Click on+Notification
button and add another alarm, this time withState is OK
Period
should be 1 minute.Statistic:
Standard
,Average
Wait for one minute and then check the status of the alarm.
To repeat the procedure for other websites, you can easily copy the existing alarm definition and just change the targeted lambda function and the name of the alarm.
- On the Lambda function editing page, click on the
CloudWatch Events
box to open the events editor. - A list of events (or just one event called
one_minute
in this case) will be shown below. Uncheck theEnabled
checkbox to the right of the event. Save
the edited Lambda function.
- Using AWS Lambda to check if your website is online: this one describes writing the NodeJS lambda function, but I find the existing
lambda-canary
blueprint quite enough.