Skip to content

CloudWatch Agent Aggrerate Disk Metric

0

I have following CloudWatch Agent config file

{
    "agent": {
      "metrics_collection_interval": 30,
      "run_as_user": "root",
      "debug": false,
      "omit_hostname": true,
      "logfile": "/opt/aws/amazon-cloudwatch-agent/logs/amazon-cloudwatch-agent.log",
      "rotate_max_files": 5,
      "rotate_max_file_size_mb": 100
    },
    "metrics": {
      "namespace": "test",
      "force_flush_interval": 60,
      "metrics_collected": {
        "cpu": {
          "measurement": [
            "cpu_usage_active"
          ],
          "totalcpu": true
        },
        "disk": {
          "measurement": [
            "used_percent"
          ],
          "resources": [
            "*"
          ],
          "drop_original_metrics": true,
          "aggregation_dimensions": [["device", "fstype", "path", "mount"]]
        },
        "mem": {
          "measurement": [
            "mem_used_percent"
          ]
        }
      }
    }
  }
  

I want disk to be reported as a single metric just like CPU(total-cpu) & memory but currently its reported with multiple dimensions. Enter image description here

How should the config be changed to aggreate disk to a single metric (% disk used)?

2 Answers
0

This worked for me. Note that host might not be the aggregation_dimensions you want. It might be InstanceId.

This is a setup for an autoscaling group using Amazon Linux 2023.

{
  "agent": { ...
  },
  "metrics": {
    "aggregation_dimensions": [["host"]],
    "metrics_collected": {
      "disk": {
        "measurement": ["used_percent"],
        "resources": ["*"],
        "drop_original_metrics": ["used_percent"],
        "drop_device": true
      }
    }
  }
}
answered 5 months ago
-1

To aggregate the disk metrics into a single metric representing the total disk usage percentage across all disks, you need to modify the "disk" section in your CloudWatch Agent configuration file. Here's how you can change the configuration to achieve this:

  1. Remove the "aggregation_dimensions" line from the "disk" section.
  2. Add "drop_device": true to the "disk" section.

Your modified "disk" section should look like this:

"disk": {
  "measurement": [
    "used_percent"
  ],
  "resources": [
    "*"
  ],
  "drop_original_metrics": true,
  "drop_device": true
}

The "drop_device" option tells the CloudWatch agent to remove the device dimension from the metric, effectively aggregating the disk usage across all devices into a single metric.

This change will result in a single disk metric that represents the overall disk usage percentage across all disks, similar to how your CPU and memory metrics are reported. The metric will be reported without any device-specific dimensions, giving you a consolidated view of disk utilization for your instance.

Remember to restart the CloudWatch agent after making these changes to the configuration file for the new settings to take effect.
Sources
Metrics collected by the CloudWatch agent - Amazon CloudWatch
Manually create or edit the CloudWatch agent configuration file - Amazon CloudWatch

answered a year ago
EXPERT
reviewed a year ago
  • This does not work. It just removes device column from the screenshot I posted above and displays all the rows.

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.