2.2.0 CloudWatch Logs
0. Learning Materials
Video: Week 2 CloudWatch Logs
Andrew's repo: week-2-cloudwatch-logs
My branch repo: 02-02-cloudwatch-logs
Task List
2. Update the backend docker container
Env Variables
backend
HONEYCOMB_API_KEY
OTEL_SERVICE_NAME
OTEL_EXPORTER_OTLP_ENDPOINT
OTEL_EXPORTER_OTLP_HEADERS
AWS_XRAY_URL
AWS_XRAY_DAEMON_ADDRESS
AWS_DEFAULT_REGION
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
x-ray daemon
AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY
AWS_REGION
1. Workflow
1. Implement a CloudWatch agent in backend
1.1. Plant a logger in the flask server app.
The python library watchtower
is a log handler for Amazon Web Services CloudWatch Logs. Run pip install
to install it in local.
pip install -r requirements.txt
Update app.py
by adding the following snippets across the file. Refer to the actual code here.
1.2. Set logger in the service (home_activities)
2. Update the backend docker container
The following env variables will be used by watchtower
.
Now our app is ready to test the CloudWatch agent in action.
Run
docker-compose
then hit some backend endpoints by clicking around in the frontend
Check your AWS CloudWatch console.
Last updated