CloudWatch agent CPU collected metrics not displayed

Viewed 1897

I have installed CloudWatch agent on an EC2 micro instance running Ubuntu 16, mainly following this very good tutorial: https://www.youtube.com/watch?v=vAnIhIwE5hY The tutorial shows the installation on a Windows instance but more than 90% of the explanations are working just fine on Linux too.

After I finished the installation, the CloudWatch collected metrics started to show just fine on my AWS CloudWatch console, except the CPU related metrics which are nowhere to be found.

Below is my json config file which I used. All the defined metrics are accessible except the CPU related ones ("cpu_usage_idle","cpu_usage_iowait","cpu_usage_user","cpu_usage_system")

I created the json using the wizard.

Is there anything extra I should do in order to have those metrics available?

{
    "agent": {
        "metrics_collection_interval": 60,
        "run_as_user": "root"
    },
    "metrics": {
        "append_dimensions": {
            "AutoScalingGroupName": "${aws:AutoScalingGroupName}",
            "ImageId": "${aws:ImageId}",
            "InstanceId": "${aws:InstanceId}",
            "InstanceType": "${aws:InstanceType}"
        },
        "metrics_collected": {
            "collectd": {
                "metrics_aggregation_interval": 60
            },
            "cpu": {
                "measurement": [
                    "cpu_usage_idle",
                    "cpu_usage_iowait",
                    "cpu_usage_user",
                    "cpu_usage_system"
                ],
                "metrics_collection_interval": 60,
                "totalcpu": false
            },
            "disk": {
                "measurement": [
                    "used_percent",
                    "inodes_free"
                ],
                "metrics_collection_interval": 60,
                "resources": [
                    "*"
                ]
            },
            "diskio": {
                "measurement": [
                    "io_time"
                ],
                "metrics_collection_interval": 60,
                "resources": [
                    "*"
                ]
            },
            "mem": {
                "measurement": [
                    "mem_used_percent",
                    "mem_free"
                ],
                "metrics_collection_interval": 60
            },
            "statsd": {
                "metrics_aggregation_interval": 60,
                "metrics_collection_interval": 10,
                "service_address": ":8125"
            },
            "swap": {
                "measurement": [
                    "swap_used_percent"
                ],
                "metrics_collection_interval": 60
            }
        }
    }
}
1 Answers

As mentioned in comments, the "resources": [ "*" ], were missing.

From the docs :

cpu – Optional. Specifies that CPU metrics are to be collected. This section is valid only for Linux instances. You must include at least one of the resources and totalcpu fields for any CPU metrics to be collected. This section can include the following fields:

resources – Optional. Specify this field with a value of * to cause per-cpu metrics are to be collected. The only allowed value is *.

CloudWatch Agent Configuration File: Metrics Section.

Related