Skip to content

Questions about our "amazon-cloudwatch-agent.json" configuration file for EC2 instances.

0

Hi re:Post,

We have an CloudWatch agent config file that we pieced together from templates found in the docs and from re:Post. We have edited it to suit our needs but we have some questions about a few areas that we're not sure what to put for certain key / value pairs. Namely:

"append_dimensions": {
              "customized_dimension_key_1": "customized_dimension_value_1",
              "customized_dimension_key_2": "customized_dimension_value_2"

"append_dimensions": {
              "customized_dimension_key_3": "customized_dimension_value_3",
              "customized_dimension_key_4": "customized_dimension_value_4"

What would we put for the 1,2,3,4 dimensions key and values?

Do we need this section?

Below is the full .json file:

{
      "agent": {
        "metrics_collection_interval": 60,
        "logfile": "/opt/aws/amazon-cloudwatch-agent/logs/amazon-cloudwatch-agent.log",
	"run_as_user": "root",
	"region": "us-east-2"
      },
      "metrics": {
        "metrics_collected": {
          "cpu": {
            "resources": [
              "*"
            ],
            "measurement": [
              {"name": "cpu_usage_idle", "rename": "CPU_USAGE_IDLE", "unit": "Percent"},
              {"name": "cpu_usage_nice", "unit": "Percent"},
              "cpu_usage_guest"
            ],
            "totalcpu": false,
            "metrics_collection_interval": 10,
            "append_dimensions": {
              "customized_dimension_key_1": "customized_dimension_value_1",
              "customized_dimension_key_2": "customized_dimension_value_2"
            }
          },
          "disk": {
            "resources": [
              "/",
              "/tmp"
            ],
            "measurement": [
              {"name": "free", "rename": "DISK_FREE", "unit": "Gigabytes"},
              "total",
              "used",
	      "used_percent"
            ],
             "ignore_file_system_types": [
              "sysfs", "devtmpfs"
            ],
            "metrics_collection_interval": 60,
            "append_dimensions": {
              "customized_dimension_key_3": "customized_dimension_value_3",
              "customized_dimension_key_4": "customized_dimension_value_4"
            }
          },
          "diskio": {
            "resources": [
              "*"
            ],
            "measurement": [
              "reads",
              "writes",
              "read_time",
              "write_time",
              "io_time"
            ],
            "metrics_collection_interval": 60
          },
          "swap": {
            "measurement": [
              "swap_used",
              "swap_free",
              "swap_used_percent"
            ]
          },
          "mem": {
            "measurement": [
              "mem_used",
              "mem_cached",
              "mem_total"
            ],
            "metrics_collection_interval": 10
          },
          "net": {
            "resources": [
              "eth0"
            ],
            "measurement": [
              "bytes_sent",
              "bytes_recv",
              "drop_in",
              "drop_out"
            ]
          },
          "netstat": {
            "measurement": [
              "tcp_established",
              "tcp_syn_sent",
              "tcp_close"
            ],
            "metrics_collection_interval": 60
          },
          "processes": {
            "measurement": [
              "running",
              "sleeping",
              "dead"
            ]
          }
        },
        "append_dimensions": {
          "ImageId": "${aws:ImageId}",
          "InstanceId": "${aws:InstanceId}",
          "InstanceType": "${aws:InstanceType}",
          "AutoScalingGroupName": "${aws:AutoScalingGroupName}"
        },
        "aggregation_dimensions" : [["ImageId"], ["InstanceId", "InstanceType"], ["d1"],[]]
      },
      "logs": {
        "logs_collected": {
          "files": {
            "collect_list": [
              {
                "file_path": "/opt/aws/amazon-cloudwatch-agent/logs/amazon-cloudwatch-agent.log",
                "log_group_name": "/ec2/CloudWatchAgentLog/",
                "log_stream_name": "{instance_id}_{hostname}",
                "timezone": "Local"
              },
              {
                "file_path": "/var/log/messages",
                "log_group_name":  "/ec2/var/log/messages",
                "log_stream_name": "{instance_id}_{hostname}",
                "timezone": "Local"
              },
              {
                "file_path": "/var/log/secure",
                "log_group_name":  "/ec2/var/log/secure",
                "log_stream_name": "{instance_id}_{hostname}",
                "timezone": "Local"
              },
              {
                "file_path": "/var/log/yum.log",
                "log_group_name":  "/ec2/var/log/yum",
                "log_stream_name": "{instance_id}_{hostname}",
                "timezone": "Local"
              }
            ]
          }
        },
		"log_stream_name": "/ec2/catchall"
      }
    }

Thank you for your time and help!

Best Regards, Donald

1 Answer
1
Accepted Answer

Hello.

"append_dimensions" is an option to add dimensions with arbitrary values ​​and publish metrics.
It's an option, so there's no problem if you don't have it.
The configuration you create will now set custom dimensions for CPU and disk metrics.
https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/CloudWatch-Agent-Configuration-File-Details.html

What I often do is set instance type and instance ID as dimensions in the metrics section as shown below.
By doing this, it will be easier to determine which EC2 metric it is.

{
  "metrics": {
    "append_dimensions": {
      "InstanceId": "${aws:InstanceId}",
      "InstanceType": "${aws:InstanceType}"
    }
  }
}
EXPERT

answered 2 years ago

  • Thank you for your quick reply and help Riku! We'll adjust our dimensions section, we like your good idea of adding instance type/id ! Best Regards, Donald

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.