CloudWatch - devian-al/AWS-Solutions-Architect-Prep GitHub Wiki

Amazon CloudWatch is a monitoring and observability service. It provides you with data and actionable insights to monitor your applications, respond to system-wide performance changes, optimize resource utilization, and get a unified view of operational health. Applies only to AWS resources

CloudWatch Key Details

  • CloudWatch collects monitoring and operational data in the form of logs, metrics, and events.

  • You can use CloudWatch to

    • detect anomalous behavior in your environments
    • set alarms
    • visualize logs and metrics side by side
    • take automated actions
    • troubleshoot issues
    • discover insights to keep your applications running smoothly.
  • Within the compute domain, CloudWatch can inform you about the health of EC2 instances, Autoscaling Groups, Elastic Load Balancers, and Route53 Health Checks.

  • Within the storage and content delivery domains, CloudWatch can inform you about the health of EBS Volumes, Storage Gateways, and CloudFront.

  • With regards to EC2, CloudWatch can only monitor host level metrics such as CPU, network, disk, and status checks for insights like the health of the underlying hypervisor.

    • monitors events every 5 minutes by default, but you can have 1 minute intervals if you use Detailed Monitoring.

    CloudWatch is NOT CloudTrail`

    so it is important to know that only CloudTrail can monitor AWS access for security and auditing reasons. CloudWatch is all about performance. CloudTrail is all about auditing.

  • You can customize your CloudWatch dashboards for insights.

  • There is a multi-platform CloudWatch agent which can be installed on both Linux and Windows-based instances.

    • This agent enables you to select the metrics to be collected, including sub-resource metrics such as per-CPU core. You can use this single agent to collect both system metrics and log files from Amazon EC2 instances and on-premises servers.
  • The following metrics are not collected from EC2 instances via CloudWatch

    • Memory utilization
    • Disk swap utilization
    • Disk space utilization
    • Page file utilization
    • Log collection
  • If you need the above information, then you can retrieve it via the official CloudWatch agent or you can create a custom metric and send the data on your own via a custom script.

  • CloudWatch's key purpose

    • Collect metrics
    • Collect logs
    • Collect events
    • Create alarms
    • Create dashboards

CloudWatch Logs

  • You can use Amazon CloudWatch Logs to monitor, store, and access your log files from Amazon EC2 instances, AWS CloudTrail, Amazon Route 53, and other sources.
    • You can then retrieve the associated log data from CloudWatch Logs.
  • It helps you centralize the logs from all of your systems, applications, and AWS services that you use, in a single, highly scalable service.
  • You can create log groups so that you join logical units of CloudWatch Logs together.
  • You can stream custom log files for further insights.

CloudWatch Events

  • Amazon CloudWatch Events delivers a near real-time stream of system events that describe changes in AWS resources.
  • You can use events to trigger lambdas for example while using alarms to inform you that something went wrong.

CloudWatch Alarms

  • CloudWatch alarms send notifications or automatically make changes to the resources you are monitoring based on rules that you define.

    For example, you can create custom CloudWatch alarms which will trigger notifications such as surpassing a set billing threshold.

    You can create an alarm for monitoring CPU usage and load balancer latency, for managing instances, and for billing alarms.

    • When an alarm is on a dashboard, it turns red when it is in the ALARM state.
    • Alarms invoke actions for sustained state changes only.
    • Alarm States
      • OK— The metric or expression is within the defined threshold.
      • ALARM— The metric or expression is outside of the defined threshold.
      • INSUFFICIENT_DATA— The alarm has just started, the metric is not available, or not enough data is available for the metric to determine the alarm state.
    • You can also monitor your estimated AWS charges by using Amazon CloudWatch Alarms.

      However, take note that you can only track the estimated AWS charges in CloudWatch and not the actual utilization of your resources. Remember that you can only set coverage targets for your reserved EC2 instances in AWS Budgets or Cost Explorer, but not in CloudWatch.