Skip to content

Instantly share code, notes, and snippets.

@boostrack
Forked from csereno/CloudWatchAgentConfig.json
Created February 4, 2021 15:47
Show Gist options
  • Save boostrack/711720dabdc7ab5466300bde187a9a27 to your computer and use it in GitHub Desktop.
Save boostrack/711720dabdc7ab5466300bde187a9a27 to your computer and use it in GitHub Desktop.
AWS CloudWatch Agent configuration file example for Linux with standard /var/log/messages, secure, and yum logs
{
"agent": {
"metrics_collection_interval": 10,
"logfile": "/opt/aws/amazon-cloudwatch-agent/logs/amazon-cloudwatch-agent.log"
},
"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"
],
"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"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment