How to Monitor AWS Lambda Functions with Uptime Monitoring
AWS Lambda functions are often treated as "serverless so it monitors itself," but that assumption leads to silent failures. Lambda functions can fail for reasons CloudWatch doesn't always catch clearly, and cold start latency can cause timeout errors that users experience as downtime.
This guide covers how to set up external uptime monitoring for Lambda functions — catching failures that CloudWatch alone misses.
Why External Monitoring for Lambda?
CloudWatch monitors Lambda from the inside: invocation counts, error rates, duration, throttles. These are useful metrics, but they have blind spots:
- Cold start delays that exceed your timeout cause errors, but CloudWatch shows them as errors not "downtime"
- API Gateway issues upstream of Lambda can cause failures CloudWatch doesn't attribute to Lambda
- DNS or networking failures between your users and the Lambda endpoint
- SSL certificate issues on your custom domain
- Configuration drift — environment variables or layers changed unexpectedly
External uptime monitoring checks from outside your AWS account, the same way real users do. This catches the full stack, not just the Lambda execution.
Option 1: Monitor Your Lambda API Endpoint Directly
If your Lambda is exposed via API Gateway or Function URL, you can monitor it directly.
Lambda Function URL
AWS Lambda Function URLs create an HTTPS endpoint directly for your function:
https://abc123def456.lambda-url.us-east-1.on.aws/
Add this URL to Vigilmon as a monitor. Set the expected HTTP status to 200.
API Gateway Endpoint
https://api.example.com/health
For best results, create a dedicated /health endpoint in your Lambda that returns a 200 with a simple JSON response:
// handler.js
exports.handler = async (event) => {
if (event.path === '/health' || event.rawPath === '/health') {
return {
statusCode: 200,
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
status: 'healthy',
timestamp: new Date().toISOString()
})
};
}
// ... rest of your handler
};
Then monitor https://api.example.com/health — this verifies:
- API Gateway is routing correctly
- Lambda is cold-starting successfully
- The execution environment is healthy
- DNS resolves to your API
Option 2: Cron Job Monitoring (for Scheduled Lambdas)
If your Lambda runs on a schedule (via EventBridge/CloudWatch Events), external uptime monitoring works differently. You want to detect if the Lambda fails to run or runs but fails.
Use a heartbeat/cron monitoring approach:
- At the end of your Lambda execution, send a GET request to a monitoring URL
- If the Lambda doesn't send that ping within the expected window, you get alerted
With Vigilmon, you can set this up as a synthetic check — though most teams use a webhook-based approach:
// At the end of your scheduled Lambda
const https = require('https');
async function pingMonitor() {
return new Promise((resolve) => {
const req = https.get('https://your-monitoring-webhook-url', (res) => {
resolve(res.statusCode);
});
req.on('error', () => resolve(0));
req.setTimeout(5000, () => { req.destroy(); resolve(0); });
});
}
exports.handler = async (event) => {
try {
// Your Lambda logic here
await doWork();
// Ping the monitor to signal success
await pingMonitor();
return { statusCode: 200 };
} catch (error) {
console.error('Lambda failed:', error);
throw error; // CloudWatch will record this as an error
}
};
Option 3: Custom Health Check Lambda
For comprehensive monitoring, deploy a separate "health check" Lambda that tests your production Lambda:
// health-check-lambda.js
const https = require('https');
exports.handler = async () => {
const start = Date.now();
// Call your production Lambda endpoint
const response = await fetch('https://api.example.com/health');
const latency = Date.now() - start;
if (!response.ok) {
throw new Error(`Health check failed: ${response.status}`);
}
const body = await response.json();
return {
statusCode: 200,
latency_ms: latency,
upstream_status: body.status,
};
};
Schedule this health check Lambda to run every 5 minutes via EventBridge. Add it to Vigilmon as a monitored endpoint.
Setting Up Vigilmon for Lambda Monitoring
- Sign up at vigilmon.online — free tier, no credit card
- Add your Lambda endpoint: Click "Add Monitor" and enter your API Gateway or Function URL
- Set check interval: 5 minutes (free tier) checks every 5 minutes from multiple regions
- Configure alerts: Enter your email for downtime notifications
- Optional: Add your custom domain if you're using Route 53 + API Gateway
Vigilmon checks from multiple geographic regions, so you'll know if your Lambda endpoint is down globally or just in one region — useful when debugging API Gateway or CloudFront issues.
What Uptime Monitoring Catches That CloudWatch Doesn't
| Issue | CloudWatch | Vigilmon |
|---|---|---|
| Lambda timeout errors | Yes (as errors) | Yes (as downtime) |
| API Gateway misconfiguration | Sometimes | Yes |
| DNS resolution failures | No | Yes |
| SSL certificate expiry | No | Yes |
| Cold start exceeding API Gateway timeout | Sometimes | Yes |
| Regional AWS endpoint issues | Partially | Yes |
| Scheduled Lambda not running | No | Yes (with ping pattern) |
Common Lambda Monitoring Mistakes
Monitoring a URL that always returns 200. Your health check endpoint should actually test your downstream dependencies (database, external APIs) — not just confirm Lambda is running.
Not accounting for cold starts. If you're on a low-traffic Lambda, set your monitoring timeout high enough to allow for cold start + execution. A 1-minute cold start causes a timeout with a 30-second check timeout.
Relying only on error rate metrics. A Lambda that times out 10% of the time has a 90% "success rate" — but that 10% is 10% of your users getting a broken experience.
Uptime monitoring and CloudWatch are complementary. CloudWatch gives you deep internal metrics; Vigilmon gives you the user-perspective view of whether your Lambda endpoint is actually working. Both together give full coverage.
Get started at vigilmon.online — free, no credit card required.
Top comments (0)