Designing and Implementing Logging and Monitoring with Amazon
Total Page:16
File Type:pdf, Size:1020Kb
AWS Prescriptive Guidance Designing and implementing logging and monitoring with Amazon CloudWatch AWS Prescriptive Guidance Designing and implementing logging and monitoring with Amazon CloudWatch AWS Prescriptive Guidance: Designing and implementing logging and monitoring with Amazon CloudWatch Copyright © Amazon Web Services, Inc. and/or its affiliates. All rights reserved. Amazon's trademarks and trade dress may not be used in connection with any product or service that is not Amazon's, in any manner that is likely to cause confusion among customers, or in any manner that disparages or discredits Amazon. All other trademarks not owned by Amazon are the property of their respective owners, who may or may not be affiliated with, connected to, or sponsored by Amazon. AWS Prescriptive Guidance Designing and implementing logging and monitoring with Amazon CloudWatch Table of Contents Introduction ...................................................................................................................................... 1 Targeted business outcomes ................................................................................................................ 4 Accelerate operational readiness .................................................................................................. 4 Improve operational excellence .................................................................................................... 4 Enhance operational visibility ...................................................................................................... 4 Scale operations and reduce overhead costs .................................................................................. 4 Planning your CloudWatch deployment ................................................................................................ 6 Using CloudWatch in centralized or distributed accounts ................................................................. 6 Creating and storing standard CloudWatch agent configuration files ................................................. 9 Storing CloudWatch configuration files in an S3 bucket .......................................................... 9 Configuring the CloudWatch agent for EC2 instances and on-premises servers ......................................... 11 Configuring the CloudWatch agent ............................................................................................. 11 Configuring log capture for EC2 instances ................................................................................... 12 Configuring metrics capture for EC2 instances ............................................................................. 14 System-level CloudWatch configuration ...................................................................................... 15 Configuring system-level logs ............................................................................................ 15 Configuring system-level metrics ........................................................................................ 17 Application-level CloudWatch configuration ................................................................................. 17 Configuring application-level logs ...................................................................................... 17 Configuring application-level metrics .................................................................................. 18 AWS SDK Metrics for Enterprise Support ............................................................................. 19 CloudWatch agent installation approaches for Amazon EC2 and on-premises servers ................................. 20 Installing the CloudWatch agent using Systems Manager Distributor and State Manager .................... 20 Set up State Manager and Distributor for CloudWatch agent deployment and configuration ....... 21 Use Systems Manager Quick Setup and manually update the created Systems Manager resources ......................................................................................................................... 22 Use AWS CloudFormation instead of Quick Setup ................................................................. 23 Customized Quick Setup in a single account and Region with an AWS CloudFormation stack ....... 23 Customized Quick Setup in multiple Regions and multiple accounts with AWS CloudFormation StackSets ........................................................................................................................ 24 Considerations for configuring on-premises servers .............................................................. 25 Considerations for ephemeral EC2 instances ........................................................................ 26 Using an automated solution to deploy the CloudWatch agent ............................................... 27 Deploying the CloudWatch agent during instance provisioning with the user data script ..................... 27 Including the CloudWatch agent in your AMIs .............................................................................. 27 Logging and monitoring on Amazon ECS ............................................................................................ 29 Configuring CloudWatch with an EC2 launch type ........................................................................ 29 Amazon ECS container logs for EC2 and Fargate launch types ........................................................ 30 Using custom log routing with FireLens for Amazon ECS ............................................................... 31 Metrics for Amazon ECS ............................................................................................................ 31 Creating custom application metrics in Amazon ECS ............................................................. 32 Logging and monitoring on Amazon EKS ............................................................................................ 33 Logging for Amazon EKS ......................................................................................................... 33 Amazon EKS control plane logging ..................................................................................... 33 Amazon EKS node and application logging ......................................................................... 34 Logging for Amazon EKS on Fargate ................................................................................... 35 Metrics for Amazon EKS and Kubernetes ..................................................................................... 35 Kubernetes control plane metrics ....................................................................................... 36 Node and system metrics for Kubernetes ............................................................................ 36 Application metrics ........................................................................................................... 36 Metrics for Amazon EKS on Fargate .................................................................................... 37 Prometheus monitoring on Amazon EKS ............................................................................................ 38 Logging and metrics for AWS Lambda ................................................................................................ 39 Lambda function logging .......................................................................................................... 39 iii AWS Prescriptive Guidance Designing and implementing logging and monitoring with Amazon CloudWatch Sending logs to other destinations from CloudWatch .................................................................... 40 Lambda function metrics ........................................................................................................... 40 System-level metrics ................................................................................................................. 40 Application metrics ................................................................................................................... 41 Searching and analyzing logs in CloudWatch ....................................................................................... 42 Collectively monitor and analyze applications with CloudWatch Application Insights .......................... 42 Performing log analysis with CloudWatch Logs Insights ................................................................ 44 Performing log analysis with OpenSearch Service ......................................................................... 45 Alarming options with CloudWatch ..................................................................................................... 47 Using CloudWatch alarms to monitor and alarm .......................................................................... 47 Using CloudWatch anomaly detection to monitor and alarm .......................................................... 47 Alarming across multiple Regions and accounts ............................................................................ 48 Automating alarm creation with EC2 instance tags ....................................................................... 48 Monitoring application and service availability ..................................................................................... 49 Tracing applications with AWS X-Ray .................................................................................................. 50 Deploying the X-Ray daemon to trace applications