Skip to content

How do I resolve the "Insufficient Data" error for CloudWatch alarms that monitor disk and memory usage for EC2 instances?

5 minute read
1

My Amazon CloudWatch alarms that monitor disk or memory metrics for Amazon Elastic Compute Cloud (Amazon EC2) instances are stuck in the "INSUFFICIENT_DATA" state.

Short description

The "INSUFFICIENT_DATA" state occurs in the following situations:

  • You didn't install or correctly configure the CloudWatch agent. Or, the CloudWatch agent isn't running.
  • The alarm dimensions don't match the dimensions the CloudWatch agent publishes, so CloudWatch can't find a matching metric.

For general troubleshooting steps, see How do I troubleshoot my CloudWatch alarm in the INSUFFICIENT_DATA state? To resolve the issue specifically for EC2 instances, use the following troubleshooting steps.

Resolution

Check the CloudWatch agent

The CloudWatch agent collects and publishes disk and memory metrics to CloudWatch Logs. You must install the agent for the metrics to appear in CloudWatch Logs.

If you already installed the agent, then complete the following steps to check whether it's running:

  1. Run one of the following commands for your operating system (OS) to check the agent status.
    Linux:

    sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a status

    Windows:

    & $Env:ProgramFiles\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent-ctl.ps1 -m ec2 -a status
  2. In the output, check whether the status field displays running. If the status is stopped, then start the CloudWatch agent.

Verify that the metric exists

Complete the following steps:

  1. Open the CloudWatch console.
  2. In the navigation pane, choose Metrics, and then choose All metrics.
  3. Choose the CWAgent namespace or your custom namespace.
  4. Confirm that data points appear for your disk or memory metrics.

If the metrics appear in the CWAgent namespace, then the CloudWatch agent successfully publishes metrics to CloudWatch. Proceed to the Resolve dimension mismatches section.

If the metrics don't appear in the CWAgent namespace, then open the CloudWatch agent configuration file and check whether the Metrics section includes disk and memory definitions.

If the configuration file doesn't include disk or memory definitions, then add the metric definitions to the configuration file. Then, restart the agent. If the configuration file includes disk and memory definitions but the metrics still don't appear in the CWAgent namespace, then the agent doesn't successfully publish metrics. Review the CloudWatch agent log file for errors.

After you update the configuration file, run one of the following fetch-config commands for your OS to apply the updated configuration and restart the CloudWatch agent.

Linux:

sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json

Windows:

& "C:\Program Files\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent-ctl.ps1" -a fetch-config -m ec2 -s -c file:"C:\Program Files\Amazon\AmazonCloudWatchAgent\config.json"

Resolve dimension mismatches

Check the alarm and configuration file dimensions

By default, The CloudWatch agent publishes metrics with multiple dimensions. For example, disk metrics include the InstanceId, ImageId, InstanceType, device, fstype, and path dimensions. If your alarm only specifies InstanceId, then CloudWatch can't find a matching metric because it exists with a specific combination of dimensions.

To determine whether there's a dimension mismatch, check the Metrics section of the alarm and the CloudWatch agent configuration file.

If differences exist between the dimensions, then update the alarm dimensions or the agent configuration file. To aggregate metrics by InstanceId or AutoScalingGroupName, update the configuration file. The AutoScalingGroupName dimension aggregates metrics from all instances in an Amazon EC2 Auto Scaling group.

Update the alarm dimensions

If the alarm dimensions don't match the dimensions the CloudWatch agent publishes, then edit the alarm and select the metric that includes all published dimensions. When you update the alarm dimensions, navigate to the Metrics section and confirm that all key and value pairs match the dimensions that the agent publishes.

Note: After you update the alarm, the alarm transitions to OK or ALARM state based on the threshold.

Update the CloudWatch agent configuration to aggregate metrics

Complete the following steps:

  1. Open the CloudWatch agent configuration file.

  2. Add the aggregation_dimensions parameter in the Metrics section.
    Note: For more information, choose the CloudWatch agent configuration file: Metrics section tab.

  3. Use one of the following configurations to aggregate metrics by InstanceId or AutoScalingGroupName.
    InstanceId:

    {
            "agent": {
                    "metrics_collection_interval": 60,
                    "run_as_user": "cwagent"
            },
    	"metrics": {
                    "aggregation_dimensions": [
                            [
                                    "InstanceId"
                            ]
                    ],
                    "metrics_collected": {
                            "disk": {
                                    "measurement": [
                                            "used_percent"
                                    ],
                                    "metrics_collection_interval": 60,
                                    "resources": [
                                            "*"
                                    ]
                            },
                            "mem": {
                                    "measurement": [
                                            "mem_used_percent"
                                    ],
                                    "metrics_collection_interval": 60
                            }
                    }
            }
    }
    

    AutoScalingGroupName:

    "aggregation_dimensions": [
        [
            "AutoScalingGroupName"
        ]
    ]
    
  4. Save the configuration file.

  5. Run one of the following fetch-config commands for your OS to apply the updated configuration and restart the CloudWatch agent.
    Linux:

    sudo /opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent-ctl -a fetch-config -m ec2 -s -c file:/opt/aws/amazon-cloudwatch-agent/bin/config.json

    Windows:

    & "C:\Program Files\Amazon\AmazonCloudWatchAgent\amazon-cloudwatch-agent-ctl.ps1" -a fetch-config -m ec2 -s -c file:"C:\Program Files\Amazon\AmazonCloudWatchAgent\config.json"

    Note: After you save the configuration, wait up to 5 minutes for the agent to publish metrics with the updated configuration. The alarm then transitions to OK or ALARM state based on the threshold value.

For more information, see Manually create or edit the CloudWatch agent configuration file.

No comments