brunch

You can make anything
by writing

C.S.Lewis

by 무명 Jul 10. 2018

[AWS] API 개발, 로깅

API Gateway ~ CloudWatch 사용 후 메모

회사 서비스의 검색 API 일부를 AWS API Gateway와 Lambda를 이용해서 만들었었다. 

예전에 적었던 것처럼 정말 쉽게 최소한의 시간으로 개발할 수 있던 점이 좋았다. 


그렇게 서비스를 돌리다가 몇몇 복잡한 검색에서 504가 나거나 하는.. 다양한 문제들이 발견되었다. 

찾아보니 API Gateway는 1분마다 CloudWatch에 지표 데이터를 보낸다고 한다. 

관련 설정을 수정하지 않았다면, 기본적으로 API Gateway의 여러 지표들을 로깅하고 있을 것이다. 


확인할 수 있는 지표들은 4XX, 5XX, CacheHitCount, CacheMissCount, Count, IntergrationLatency, Latency이 있다. 

https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-metrics-and-dimensions.html


아래의 경로에서 CloudWatch Console을 확인할 수 있다. 

https://docs.aws.amazon.com/apigateway/latest/developerguide/metrics_dimensions_view_in_cloud_watch.html


파이썬 logger 모듈을 이용해서 더 세세하게 로깅할 수도 있다. 

https://docs.aws.amazon.com/ko_kr/lambda/latest/dg/python-logging.html


딥하게는 별도의 에이전트를 만들어 장비 자체의 하드웨어 정보들까지 모니터링 가능하다. 

API Gateway - Lambda만 보면 되어서 이 정도까진 필요하지 않았다. 

https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/create-cloudwatch-agent-configuration-file-wizard.html


특정 커스텀 메트릭에 따라 메일 알람 보내는 방법도 있다. 

http://interconnection.tistory.com/48

Configuring CloudTrail to Send Notifications

https://docs.aws.amazon.com/awscloudtrail/latest/userguide/configure-cloudtrail-to-send-notifications.html


작가의 이전글 [리뷰] 양자컴퓨팅 관련 논문 #01

작품 선택

키워드 선택 0 / 3 0

댓글여부

afliean
브런치는 최신 브라우저에 최적화 되어있습니다. IE chrome safari