Amazon CloudWatch - Developing and Deploying .NET Applications on AWS

This whitepaper is for historical reference only. Some content might be outdated and some links might not be available.

Amazon CloudWatch

The cornerstone for monitoring applications running on AWS is Amazon CloudWatch, a group of services that can store log files, track metrics, send alarms, and execute automated actions when specific events are triggered.

Sending data to CloudWatch from Windows applications can be handled automatically using the Amazon CloudWatch agent, which runs as a Windows service to integrate with CloudWatch from .NET applications hosted on Amazon EC2, Amazon ECS, or Amazon EKS.

Amazon CloudWatch provides a number of key features. CloudWatch dashboards are customizable home pages in the CloudWatch console that can be used to monitor resources and view the metrics and alarms for your AWS resources. CloudWatch Metrics stores data about the performance of your systems, and allows publishing your own application metrics. CloudWatch Alarms can monitor one or more metrics, and can trigger a variety of actions, including automatic scaling, or sending a notification to an Amazon Simple Notification Service (Amazon SNS) topic.

Amazon CloudWatch Logs stores and monitors log files, and can be used for centralized access to log files from a variety of applications, systems, and AWS services. Although logs can be sent from Windows using the CloudWatch agent, you can configure many .NET logging libraries, including Apache log4net, NLog, Serilog, and ASP.NET Core logging, to send log entries to CloudWatch, and call CloudWatch directly using the AWS SDK for .NET. For .NET serverless functions running in AWS Lambda, you can send messages to CloudWatch Logs by either writing output to stdout or stderr using the Console class, or by using the ILambda Context object.

Once logs are stored, you can view the logs from multiple sources as a time-ordered flow of events, search the logs, and display them in custom dashboards. Although CloudWatch Logs provides a number of common logging features, sometimes there are use cases that fit more closely with other logging tools. Common tools used alongside or instead of CloudWatch Logs include Amazon OpenSearch Service, Splunk, or Loggly.

Amazon CloudWatch Events receives system events from AWS resources, and can be used to send notifications or run automated scripts when specific conditions are met. Rules are defined to match particular sets of events and conditions, and, once triggered, events can be routed to target actions, allowing notifications to be sent, or custom actions to execute. CloudWatch Events can also be run on a schedule, and provides a flexible tool to trigger various types of system automation.