How-to guidemonitoring7–9 minIntermediate
Opening Incidents from AWS Lambda Failures
Send Lambda errors into TG2G so serverless incidents don't get lost.
Last updated 2025-11-26
awslambdaserverless
Share:
Pattern overview
The simplest pattern is to catch unhandled errors in your Lambda and call the Event API with a structured summary. You can also wire CloudWatch alarms to TG2G, but this guide focuses on application-level events.
Node.js handler example
Lambda + Event API
const https = require("https");
function postEvent(payload) {
return new Promise((resolve, reject) => {
const req = https.request({
hostname: "ingest.techguys2go.com",
path: "/api/webhook/ingest",
method: "POST",
headers: {
"X-TG2G-Api-Key": process.env.TG2G_EVENT_KEY,
"Content-Type": "application/json"
}
}, res => {
res.on("data", () => {});
res.on("end", resolve);
});
req.on("error", reject);
req.write(JSON.stringify(payload));
req.end();
});
}
exports.handler = async (event) => {
try {
// your normal logic here
} catch (err) {
await postEvent({
summary: "Lambda failure: " + err.message,
severity: "critical",
labels: {
function: process.env.AWS_LAMBDA_FUNCTION_NAME,
env: "prod"
},
details: JSON.stringify({ error: err.message, stack: err.stack })
});
throw err;
}
};