File tree Expand file tree Collapse file tree
_test-stacks/monitoring-real Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 ;
Original file line number Diff line number Diff line change 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+ } ) ;
You can’t perform that action at this time.
0 commit comments