AWS CloudWatch Agent Monitor Memory With IMDSv2

Viewed 471

I'm trying to monitor memory on an EC2 Amazon Linux 2 instance. I'm using these instructions for reference and I'm seeing the error ERROR: Cannot obtain instance id from EC2 meta-data.. I disabled IMDVs1 in my instance which I'm guessing is the way the CloudWatch agent is trying to get my instance id. Does anyone know if there're updated docs on this or a way to fix this? I looked at the AWS script here and I think I could figure out how to have it get this instance ID with IMDSv2 but I'd be surprised if they didn't have a way to do this already. I think I'm missing something though.

1 Answers

I figured it out...

TLDR: Don't use the amazon script to monitor memory, use the CloudWatch Agent

I clicked the first link that showed up when looking at how to monitor memory on EC2 and unfortunately that link is to an old way to monitor memory using a script.

They've updated how to monitor memory and the CloudWatch agent can be configured to do this starting here. There's an automated way to set it up from this documentation and a manual way. This will create a Custom Namespace in the CloudWatch metric view.

Related