Monitoring a Windows EC2 instance
#
OverviewThis module deploys monitoring and alerting of Windows EC2 instances.
It will:
- Save the Cloudwatch Agent configuration into the parameter store
- Create Cloudwatch rules for installing and configuring the Cloudwatch agent on instances
- Create an SNS queue and add a subscription for the provided email address(es)
- Create Cloudwatch alarms for either the default or provided metrics
#
UsageDeclare the module and provide the required inputs and optional inputs as needed:
ec2_instance_ids
is a list of strings that holds the instance_ids of the instances you want to monitor.
alert_emails
is a list of strings that holds the email addresses you want to receive alerts. Any new subscription will need to be confirmed by clicking on the "Confirm Subscription" link in the email that is sent post deployment.
#
Default monitors and alertsBy default, the module will alarm for:
- Instance status (when the instance is offline)
- CPU > 80% for 5 minutes
- Free space on C: drive less than 20% for one hour
- Memory above 80% for 5 minutes
#
Custom monitoringCustom monitoring can be implemented by providing the following optional variables:
ssm_cloudwatch_config_windows_value
is a JSON file which tells the Cloudwatch agent what metrics from the operating system to output to Cloudwatch. Examples can be found https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-Configuration-File-Details.html#CloudWatch-Agent-Configuration-File-Complete-Example
The default Cloudwatch Agent config for this project can be found here.
New Metrics can be either added to the default config if they are likely to be needed across all instances at Hackney, or the file can be copied, amended and provided as an optional value in the ssm_cloudwatch_config_windows_value
variable.
alarm_configs
is a YAML file which holds the desired configuration of the alarms that are required.
The default alarm config for this project can be found here.
New alarms can be either added to the default config if they are likely to be needed across all instances at Hackney, or the file can be copied, amended and provided as an optional value in the alarm_configs
variable.
The current default is below:
YAML:
#
Required Module VariablesSee 01-inputs-required.tf
#
Optional Module VariablesSee 02-inputs-optional.tf
#
Module Output VariablesSee 99-outputs.tf