Skip to content

Instantly share code, notes, and snippets.

@marcelog
Created October 22, 2016 12:10
Show Gist options
  • Save marcelog/0cff0304f83ede051bdf982da6e2dc77 to your computer and use it in GitHub Desktop.
Save marcelog/0cff0304f83ede051bdf982da6e2dc77 to your computer and use it in GitHub Desktop.
This AWS Lambda can be used to check your website for availability
'use strict';
var url = require('url');
var target = 'http://www.yourwebsite.com'; // Change this one
exports.handler = function(event, context, callback) {
var urlObject = url.parse(target);
var mod = require(
urlObject.protocol.substring(0, urlObject.protocol.length - 1)
);
console.log('[INFO] - Checking ' + target);
var req = mod.request(urlObject, function(res) {
res.setEncoding('utf8');
res.on('data', function(chunk) {
console.log('[INFO] - Read body chunk');
});
res.on('end', function() {
console.log('[INFO] - Response end');
callback();
});
});
req.on('error', function(e) {
console.log('[ERROR] - ' + e.message);
callback(e);
});
req.end();
};
@dustball
Copy link

dustball commented Oct 12, 2020

Do you really use this to monitor your website? Do you find Lambda reliable enough for such a purpose?

  1. Because Lambda has failure built-in as a feature so-to-speak, and relies on the user to anticipate failures, I find Lambda gives more false positives then any other monitoring system I've tried.
  2. The alert e-mails generated are insanely verbose, while at the same time not supplying much useful information like what went wrong.
  3. Timezone usage seems inconsistent and confusing in the Cloudwatch Log Groups, it takes forever to find relevant entries, if I can find it at all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment