Skip to content

Commit ad0098a

Browse files
committed
test: add monitoring-real test stack for alarm webhook smoke testing
1 parent 61834d9 commit ad0098a

2 files changed

Lines changed: 65 additions & 0 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import type { APIGatewayProxyHandlerV2 } from 'aws-lambda';
2+
3+
const handler: APIGatewayProxyHandlerV2 = async (event) => {
4+
const mode = event.queryStringParameters?.mode || 'ok';
5+
6+
if (mode === 'error') {
7+
throw new Error('Intentional monitoring real-stack error');
8+
}
9+
10+
return {
11+
statusCode: 200,
12+
headers: { 'content-type': 'application/json' },
13+
body: JSON.stringify({ ok: true, mode })
14+
};
15+
};
16+
17+
export default handler;
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
import { defineConfig, LambdaFunction, StacktapeLambdaBuildpackPackaging } from '../../__release-npm';
2+
3+
export default defineConfig(() => {
4+
const monitoredLambda = new LambdaFunction({
5+
packaging: new StacktapeLambdaBuildpackPackaging({
6+
entryfilePath: './src/handler.ts'
7+
}),
8+
url: {
9+
enabled: true,
10+
cors: {
11+
enabled: true
12+
}
13+
},
14+
alarms: [
15+
{
16+
description: 'Monitoring real alarm smoke test',
17+
includeInHistory: true,
18+
notificationTargets: [
19+
{
20+
type: 'webhook',
21+
properties: {
22+
url: 'https://httpbin.org/post',
23+
headers: {
24+
'X-Stacktape-Monitoring-Test': 'real-alarm'
25+
}
26+
}
27+
}
28+
],
29+
evaluation: {
30+
period: 60,
31+
evaluationPeriods: 1,
32+
breachedPeriods: 1
33+
},
34+
trigger: {
35+
type: 'lambda-error-rate',
36+
properties: {
37+
comparisonOperator: 'GreaterThanThreshold',
38+
thresholdPercent: 0
39+
}
40+
}
41+
}
42+
]
43+
});
44+
45+
return {
46+
resources: { monitoredLambda }
47+
};
48+
});

0 commit comments

Comments
 (0)