반응형
◇ 공부 기록용으로 작성하였으니 틀린점, 피드백 주시면 감사하겠습니다 ◇
Lambda 함수를 작성하면 자동으로 Lambda의 특정 항목을 모니터링하여 CloudWatch에 Metrics(로그)로서 기록된다.
여기서 특정 항목이란 어떤걸까?
특정 항목
- Request (요청)
- Request당 Latency
- 에러가 된 Request
- 함수 코드 내 로그 출력: console.log(Node.js), print(Python), System.out.println(Java)
예시
REPORT RequestId: <request-id> Duration: <duration> ms Billed Duration: <billed-duration> ms Memory Size: <memory-size> MB Max Memory Used: <max-memory-used> MB
예시) CloudWatch 로그
START RequestId: 12345678-1234-1234-1234-123456789012 Version: $LATEST
2024-05-31T12:00:00.000Z 12345678-1234-1234-1234-123456789012 INFO Lambda 함수가 시작되었습니다.
2024-05-31T12:00:00.500Z 12345678-1234-1234-1234-123456789012 INFO 함수 결과: { message: '성공', key: 'exampleValue' }
2024-05-31T12:00:00.600Z 12345678-1234-1234-1234-123456789012 INFO Lambda 함수가 종료되었습니다.
END RequestId: 12345678-1234-1234-1234-123456789012
REPORT RequestId: 12345678-1234-1234-1234-123456789012 Duration: 600.00 ms Billed Duration: 700 ms Memory Size: 128 MB Max Memory Used: 48 MB
예시) CloudWatch 로그 (오류 발생 시)
START RequestId: 87654321-4321-4321-4321-210987654321 Version: $LATEST
2024-05-31T12:00:01.000Z 87654321-4321-4321-4321-210987654321 INFO Lambda 함수가 시작되었습니다.
2024-05-31T12:00:01.200Z 87654321-4321-4321-4321-210987654321 ERROR 오류 발생: Error: event에 key가 없습니다.
at someFunction (/var/task/index.js:14:11)
at Runtime.exports.handler (/var/task/index.js:4:19)
at Runtime.handleOnceNonStreaming (file:///var/runtime/index.mjs:1141:29)
2024-05-31T12:00:01.300Z 87654321-4321-4321-4321-210987654321 INFO Lambda 함수가 종료되었습니다.
END RequestId: 87654321-4321-4321-4321-210987654321
REPORT RequestId: 87654321-4321-4321-4321-210987654321 Duration: 300.00 ms Billed Duration: 400 ms Memory Size: 128 MB Max Memory Used: 50 MB
Lambda IAM Role
Lambda 로그를 Cloudwatch에 기록할때 AWS 리소스끼리 통신해야 하기때문에 IAM Role이 필요하다
참고자료) https://docs.aws.amazon.com/ko_kr/lambda/latest/dg/monitoring-metrics.html
https://docs.aws.amazon.com/lambda/latest/dg/lambda-intro-execution-role.html
728x90
반응형
'클라우드(AWS) > Lambda' 카테고리의 다른 글
[AWS] Lambda를 VPC에 배치&연결하기 (프라이빗 서브넷에 접근하는 법, VPC Access 설치하기) (0) | 2024.06.10 |
---|---|
[AWS] AWS Lambda 쉽게 개념 및 특징 정리 (Serverless, Concurrency) (0) | 2023.10.06 |