I’ll provide the complete solution addressing all three focus areas:
Greengrass CloudWatch Integration:
Greengrass v2 publishes system metrics through the aws.greengrass.Telemetry component. Verify this component is deployed and running:
sudo /greengrass/v2/bin/greengrass-cli component list
# Check aws.greengrass.Telemetry status
The component configuration should specify CloudWatch as the telemetry destination. Check component config:
{
"telemetryPublisher": "CloudWatch",
"publishInterval": "300",
"metricsNamespace": "AWS/Greengrass"
}
IAM Role Permissions:
Your IAM role has an incorrect Resource restriction. CloudWatch PutMetricData doesn’t use namespace in the Resource ARN. Update your IAM policy:
{
"Version": "2012-10-17",
"Statement": [{
"Effect": "Allow",
"Action": "cloudwatch:PutMetricData",
"Resource": "*",
"Condition": {
"StringEquals": {
"cloudwatch:namespace": [
"AWS/Greengrass",
"CustomMetrics"
]
}
}
}]
}
The Token Exchange Service (TES) role must also have these permissions. Verify TES role:
aws iot describe-role-alias --role-alias GreengrassCoreTokenExchangeRoleAlias
Ensure the role referenced has the CloudWatch policy attached.
Metric Publishing Endpoint:
Verify the Greengrass core device can reach the CloudWatch endpoint. Test connectivity:
curl -I https://monitoring.us-west-2.amazonaws.com
If using VPC endpoints, ensure the endpoint policy allows cloudwatch:PutMetricData:
{
"Statement": [{
"Effect": "Allow",
"Principal": "*",
"Action": "cloudwatch:PutMetricData",
"Resource": "*"
}]
}
Resolution Steps:
- Update IAM policy to remove incorrect Resource restriction
- Use Condition block with cloudwatch:namespace instead
- Verify TES role has same permissions
- Restart Greengrass core to pick up new credentials:
sudo systemctl restart greengrass
5. Monitor Greengrass logs for successful metric publishing:
```bash
sudo tail -f /greengrass/v2/logs/aws.greengrass.Telemetry.log
- Check CloudWatch console after 5-10 minutes for metrics in AWS/Greengrass namespace
The root cause is the Resource restriction in your IAM policy using an invalid ARN format for CloudWatch metrics. Metrics should appear in CloudWatch within 10 minutes of applying the corrected IAM policy and restarting Greengrass.