Skip to content

Logging and Monitoring for Python Environments

This tutorial maps AWS Elastic Beanstalk logging and monitoring features for Python workloads. It focuses on log retrieval, CloudWatch log streaming, metrics, and optional X-Ray integration paths.

Prerequisites

  • A running Elastic Beanstalk Python environment.
  • IAM permissions for CloudWatch Logs and Elastic Beanstalk APIs.
  • EB CLI installed for log retrieval operations.

What You'll Build

You will build an observation baseline that includes:

  • Instance log access for deployment and application diagnostics.
  • Request logs and full logs retrieval through EB CLI.
  • CloudWatch Logs streaming for centralized retention.
  • Metric and trace visibility aligned with AWS-managed integrations.

Steps

  1. Retrieve recent logs and full logs from the environment.
eb logs --zip
eb logs --all
  1. Review key files referenced in AWS documentation:

  2. /var/log/web.stdout.log

  3. /var/log/web.error.log
  4. /var/log/eb-engine.log
  5. /var/log/nginx/access.log
  6. /var/log/nginx/error.log

  7. Enable CloudWatch log streaming from configuration.

option_settings:
    aws:elasticbeanstalk:cloudwatch:logs:
        StreamLogs: true
        DeleteOnTerminate: false
        RetentionInDays: 14
  1. Deploy and verify CloudWatch log groups.
eb deploy --staged
aws logs describe-log-groups --log-group-name-prefix "/aws/elasticbeanstalk/" --region "$REGION"
  1. Check environment health and metrics trend.
eb health
aws cloudwatch get-metric-statistics --namespace "AWS/ElasticBeanstalk" --metric-name "EnvironmentHealth" --start-time "2026-01-01T00:00:00Z" --end-time "2026-01-01T01:00:00Z" --period 60 --statistics Average --region "$REGION"
  1. If your environment uses X-Ray integration, verify daemon or platform support per AWS docs.
flowchart TD
    A[App and Proxy Logs on Instance] --> B[eb logs retrieval]
    A --> C[CloudWatch Logs Streaming]
    C --> D[Retention and Central Search]
    E[Environment Metrics] --> F[CloudWatch Metrics]
    G[Optional X-Ray Traces] --> H[Service Map]
    B --> I[Troubleshooting Decisions]
    D --> I
    F --> I
    H --> I

Verification

Use repeatable checks after each deployment:

eb events --follow
eb logs --all
aws logs describe-log-streams --log-group-name "/aws/elasticbeanstalk/$ENV_NAME/var/log/web.stdout.log" --region "$REGION"

Expected outcomes:

  • eb-engine.log confirms deployment phases.
  • Application stdout and error logs are populated.
  • CloudWatch log streams appear after environment update.
  • Health transitions and metrics correlate with request behavior.

See Also

Sources