CloudWatch disk_used_percent alerts for multiple volumes on Nitro instance

0

With Nitro instanaces, attached EBS volumes are not given a predictable device name (i.e. an ec2 instanace with two attached EBS volumes, the first volume might be nvme0n1 or nvme1n1)

I'm using CloudFormation to build linux ec2 instances, each with a root volume and an additional EBS volume (mounted to /mnt/data for example.) I want CloudWatch disk_used_percent alerts for both volumes.

I was able to use the information from https://forums.aws.amazon.com/thread.jspa?messageID=896255 to configure a CloudWatch disk_used_percent alert for the root volume (/), but I can't figure out how to also add a disk_used_percent alert for the other volume (/mnt/data)

Here is my amazon-cloudwatch-agent.json:

{
  "metrics": {
    "append_dimensions": {
      "AutoScalingGroupName": "${!aws:AutoScalingGroupName}",
      "ImageId": "${!aws:ImageId}",
      "InstanceId": "${!aws:InstanceId}",
      "InstanceType": "${!aws:InstanceType}"
    },
    "aggregation_dimensions" : [["InstanceId","fstype","path"]],
    "metrics_collected": {
      "disk": {
        "measurement": [
          "disk_used_percent"
        ],
        "append_dimensions": {
          "fstype": "ext4",
          "path": "/"
        }
      }
    }
  }
}

Here is the relevant portion of my CloudFormation Template

  RootDiskUsedPercentAlarm:
    Type: AWS::CloudWatch::Alarm
    Properties:
      AlarmActions:
        - !Sub arn:aws:sns:${AWS::Region}:xxxxxxxxxxxx:RootDiskUsedPercentAlarm
      AlarmDescription: disk_used_percent alarm for root volume of EC2 instance
      MetricName: disk_used_percent
      Namespace: CWAgent
      Statistic: Average
      Period: 300
      EvaluationPeriods: 1
      Threshold: 90
      ComparisonOperator: GreaterThanThreshold
      Dimensions:
        - Name: InstanceId
          Value: !Ref EC2Instance
        - Name: fstype
          Value: ext4
        - Name: path
          Value: /
a-ron
asked 4 years ago2190 views
3 Answers
0
Accepted Answer

The "append_dimensions" inside "disk" section is not needed.
If you want disk metrics aggregated per EC2 Instance(across all path and fstype), you can specify \["InstanceId"] in the "aggregation_dimensions". If you want disk metrics per path, fstype and EC2 Instance, you can specify \["InstanceId","fstype","path"] in the "aggregation_dimensions". If you want both, please specify the aggregation_dimensions as following:
"aggregation_dimensions": \[\["InstanceId"], \["InstanceId","fstype","path"]]

answered 4 years ago
0

Thank you. That worked. Looks like I was over complicating it.

a-ron
answered 4 years ago
0

Thanks for this. Any idea if it is possible to monitor multiple disks on one/all EC2 instances (Windows for instance)?
I basically want to monitor all my disks for < 10% free across the whole environment.
At the moment I need to specify an Alarm for C: and D: and E:, etc...
Instead of being able to specify A - Z for instance, or only C, D, E, R in one Alarm.

Tsa
answered 3 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions