lambda-watchtower
is a script for monitoring one or several HTTP(S) endpoints with AWS Lambda.
Logs are stored as AWS CloudWatch metrics.
lambda-watchtower
supports the following event parameters:
{
"targets": [
{
"url": "https://example.org",
"name": "example.org", //Optional, defaults to url; Display name of the target
},
{
"name": "Mailserver SMTP port check",
"type": "port",
"hostname": "mailserver.example.org",
"port": 25
}
],
"namespace": "Watchtower", //Optional, defaults to "Watchtower"; CloudWatch namespace
"timings": ["readable", "total"], Optional, defaults to ["readable", "total"]; Determine which timings are logged.
"timeout": 2000 //Optional, defaults to 2000: Time in ms before requests are aborted
}
The following timings are supported and can be logged by lambda-watchtower
:
lookup
: Time between beginning of request and successful DNS lookupconnect
: Time between DNS lookup and TCP connectsecureConnect
: Time between TCP connect and completion of HTTPS handshakereadable
: Time between successfully establishing the connection (and HTTPS handshake) and first byte receivedclose
: Time between first byte and the end of the requesttotal
: Total time from the beginning to the end of the request
There is a detailed step-by-step guide explaining how to set up lambda-watchtower
. Read the step-by-step instructions.
If you’re already familiar with AWS IAM and Lambda, here is the short version for you:
- Create a new IAM Role for Lambda with
PutMetricData
permissions for CloudWatch - Create a new Lambda Function with the contents of
index.js
assign the IAM role created above to this function. - Create a new CloudWatch Event Rule of type schedule.
- Select how often you would like to check your endpoints.
- Add the new Lambda function as the target.
- Configure the input of the target and select "Constant (JSON text)".
- Put the configuration JSON (see Usage) in the input field.
- Save everything and give it a few minutes. New CloudWatch metrics can take a little while to show up.
Pull requests and issues for additional features are welcome.
lambda-watchtower
is licensed under the terms of the MIT license. For further information, please refer to the LICENSE
file.