Skip to content

100% Serverless Website Monitor Tool Using AWS

License

Notifications You must be signed in to change notification settings

akki-io/serverless-website-monitoring

Repository files navigation

serverless-monitor
Serverless Monitor

A serverless website monitoring tool built on AWS Infrastructure.

serverless-monitor

Key Features

  • 100% Serverless
  • Unlimited website monitoring
  • Slack alerts only when status is changed
  • SNS Topic Publish only on status change. SNS can send alerts via
    • SMS/Text Message
    • Email
    • Push
    • etc.
  • Basic Cloudwatch Graphs and Metrics
  • Docker support For development environment
  • *Low cost monitoring

Cost Estimation

Below is quick cost estimation of using this tool. These are just sample cost estimation. Please note these prices cannot be used as a final or real price for using this tool and can vary depending on the configuration.

Please do your own research and check AWS pricing before using the tool.

Assumptions

  • Paid tier
  • Scheduler runs every 5 minutes
  • Lambda function timeout set to 30 seconds
  • Lambda function uses max 128 MB Memory
  • Lambda number of request is 8640
  • Lambda request duration is 30000 ms
  • 500 Text Message (United States) per month
  • 500 Email per month
  • Cost is per month

With CloudWatch Metrics

# Endpoints Lambda Cost Metrics DynamoDB SNS Total
1 10 $0.54 $6 $0 $3.235 $9.775
2 50 $0.54 $30 $0 $3.235 $33.775
3 100 $0.54 $60 $0 $3.235 $63.775
4 500 $0.54 $300 $0 $3.235 $303.775

Without CloudWatch Metrics

# Endpoints Lambda Cost Metrics DynamoDB SNS Total
1 10 $0.54 $0 $0 $3.235 $3.775
2 50 $0.54 $0 $0 $3.235 $3.775
3 100 $0.54 $0 $0 $3.235 $3.775
4 500 $0.54 $0 $0 $3.235 $3.775

Prerequisite

Getting Started

  1. Clone the repo locally
git clone [email protected]:akki-io/serverless-monitor.git

With Docker

  1. Start the docker container
docker-compose up -d
  1. Install Dependencies
docker-compose exec node npm install
  1. Configure AWS CLI
docker-compose exec node aws configure

Without Docker

  1. Install Dependencies
npm install
  1. Configure AWS CLI
aws configure

Update serverless.yml

Copy serverless-example.yml to serverless.yml

cp serverless-example.yml serverless.yml

Configure a slack incoming webhook and update slackWebhookUrl

environment:    
    slackWebhookUrl: UPDATE_YOUR_SLACK_WEBHOOK HERE # https://slack.com/intl/en-ca/help/articles/115005265063-Incoming-Webhooks-for-Slack

If you want to disable cloud metrics set enableMetrics to false in serverless.yml

environment:    
    enableMetrics: false

Update your website/api urls under input

input:
    - 'https://www.google.com'
    - 'https://www.tekz.io'
    - 'https://www.akki.io'

Deployment

Once you have modified your serverless.yml it is time to deploy the project to AWS.

With Docker

docker-compose exec node serverless deploy --stage prod --region us-east-1

Without Docker

serverless deploy --stage prod --region us-east-1

This will deploy the project to us-east-1

Deployment Output

Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service monitor.zip file to S3 (1.37 MB)...
Serverless: Validating template...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
...........
Serverless: Stack update finished...
Service Information
service: monitor
stage: prod
region: us-east-1
stack: monitor-prod
resources: 9
api keys:
  None
endpoints:
  None
functions:
  http: monitor-prod-http
layers:
  None
Serverless: Run the "serverless" command to setup monitoring, troubleshooting and testing.

A quick look at the Resources created by AWS using CloudFormation

serverless-monitor-resources

Add new website/api or deploying changes

If you made changes to the serverless.yml or added new inputs for website/API.

You can simply call this command to update the existing stack.

With Docker

docker-compose exec node serverless deploy --stage prod --region us-east-1

Without Docker

serverless deploy --stage prod --region us-east-1

Adding Subscriptions to the SNS Topic

This tool creates a empty topic without any subscriptions attached. You can add your own subscriptions like email, SMS etc.

serverless-monitor-sns-subscription

Local Tinkering

With Docker

Invoke the cloud function

docker-compose exec node \
	serverless invoke \
	--stage prod --region us-east-1 --function http \
	--data '["https://www.google.com"]'

Invoke the local copy of the function

docker-compose exec node \
	serverless invoke local \
	--stage prod --function http \
	--data '["https://www.google.com"]'

Without Docker

Invoke the cloud function

serverless invoke \
    --stage prod --region us-east-1 --function http \
	--data '["https://www.google.com"]'

Invoke the local copy of the function

serverless invoke local \
	--stage prod --function http \
	--data '["https://www.google.com"]'

You will then see an output similar to below.

endpoints: [ 'https://www.google.com' ]
Requesting https://www.google.com
https://www.google.com : {"statusCode":200,"durationMS":229.07045600000015}
Final results:
{"https://www.google.com":{"statusCode":200,"durationMS":229.07045600000015}}
{
    "https://www.google.com": {
        "statusCode": 200,
        "durationMS": 229.07045600000015
    }
}
Logged metrics in Cloudwatch at: serverless-monitor

Screenshots

Slack Alerts

serverless-monitor-resources

CloudWatch Graph

serverless-monitor-resources

Text Alerts

serverless-monitor-text

Email Alerts

serverless-monitor-email

Contributions

All contributions are welcomed, please create a Pull Request.

Credits

Todo

  • AWS SNS Topic
  • Enable/Disable Metrics
  • Enable/Disable Slack
  • Custom Success Status Code
  • Cost Estimation
  • ... suggestions?

Donations

License

Licensed under the MIT license.

Built with in Canada

About

100% Serverless Website Monitor Tool Using AWS

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published