Skip to content

Instantly share code, notes, and snippets.

@jbontech
Forked from mdemblani/amazon-cloudwatch-agent.log
Created September 28, 2021 19:20
Show Gist options
  • Save jbontech/c264d0f29696ca3954d35f2774da93ae to your computer and use it in GitHub Desktop.
Save jbontech/c264d0f29696ca3954d35f2774da93ae to your computer and use it in GitHub Desktop.
Cloudwatch Agent Configuration Snippets
2020-05-06T10:17:35Z I! will use file based credentials provider
2020-05-06T10:17:35Z I! cloudwatch: publish with ForceFlushInterval: 1m0s, Publish Jitter: 37s
2020-05-06T10:17:35Z I! Starting AmazonCloudWatchAgent (version 1.237768.0)
2020-05-06T10:17:35Z I! Loaded outputs: cloudwatch cloudwatchlogs
2020-05-06T10:17:35Z I! Loaded inputs: tail cpu diskio processes statsd swap disk mem netstat socket_listener
2020-05-06T10:17:35Z I! Tags enabled: host=ip-X-X-X-X
2020-05-06T10:17:35Z I! Agent Config: Interval:1m0s, Quiet:false, Hostname:"ip-X-X-X-X", Flush Interval:1s
2020-05-06T10:17:35Z I! Started the statsd service on :8125
2020-05-06T10:17:35Z I! Statsd listener listening on: [::]:8125
2020-05-06T10:17:35Z I! will use file based credentials provider
{
"agent": {
"metrics_collection_interval": 60,
"region": "us-east-2",
"debug": false,
"run_as_user": "ubuntu"
},
"logs": {
"logs_collected": {
"files": {
"collect_list": [
{
"file_path": "/var/log/amazon/amazon-cloudwatch-agent/amazon-cloudwatch-agent.log",
"log_group_name": "amazon-cloudwatch-agent",
"log_stream_name": "amazon-cloudwatch-agent-{instance_id}.log"
},
{
"file_path": "/var/log/amazon/amazon-cloudwatch-agent/configuration-validation.log",
"log_group_name": "amazon-cloudwatch-agent",
"log_stream_name": "configuration-validation-{instance_id}.log"
}
]
}
}
},
"aggregation_dimensions" : [["AutoScalingGroupName"], ["InstanceId", "InstanceType"],[]],
"metrics": {
"namespace": "CloudWatch Agent",
"append_dimensions": {
"AutoScalingGroupName": "${aws:AutoScalingGroupName}",
"ImageId": "${aws:ImageId}",
"InstanceId": "${aws:InstanceId}",
"InstanceType": "${aws:InstanceType}"
},
"metrics_collected": {
"collectd": {
"metrics_aggregation_interval": 60
},
"cpu": {
"measurement": [
{"name": "cpu_usage_idle", "rename": "CPU_USAGE_IDLE", "unit": "Percent"},
{"name": "cpu_usage_iowait", "rename": "CPU_USAGE_IOWAIT", "unit": "Percent"},
{"name": "cpu_usage_user", "rename": "CPU_USAGE_USER", "unit": "Percent"},
{"name": "cpu_usage_system", "rename": "CPU_USAGE_SYSTEM", "unit": "Percent"},
{"name": "cpu_usage_nice", "rename": "CPU_USAGE_NICE", "unit": "Percent"}
],
"metrics_collection_interval": 60,
"resources": [
"*"
],
"totalcpu": true
},
"disk": {
"measurement": [
{"name": "used_percent", "rename": "DISK_USED_PERCENT", "unit": "Percent"},
{"name": "free", "rename": "DISK_FREE"},
{"name": "inodes_free", "rename": "DISK_INODES_FREE"}
],
"metrics_collection_interval": 60,
"resources": [
"*"
]
},
"diskio": {
"measurement": [
{"name": "io_time", "rename": "DISK_IO_IO_TIME", "unit": "Milliseconds"},
{"name": "write_bytes", "rename": "DISK_IO_WRITE_BYTES", "unit": "Bytes"},
{"name": "read_bytes", "rename": "DISK_IO_READ_BYTES", "unit": "Bytes"},
{"name": "writes", "rename": "DISK_IO_WRITES", "unit": "Count"},
{"name": "reads", "rename": "DISK_IO_READS", "unit": "Count"}
],
"metrics_collection_interval": 60,
"resources": [
"*"
]
},
"processes": {
"measurement": [
{"name": "total", "rename": "PROCESS_TOTAL", "unit": "Count"},
{"name": "zombies", "rename": "PROCESS_ZOMBIES", "unit": "Count"}
],
"metrics_collection_interval": 60
},
"mem": {
"measurement": [
{"name": "mem_used_percent", "rename": "MEM_USED_PERCENT", "unit": "Percent"},
{"name": "mem_available_percent", "rename": "MEM_AVAILABLE_PERCENT", "unit": "Percent"}
],
"metrics_collection_interval": 60
},
"netstat": {
"measurement": [
{"name": "tcp_established", "rename": "NETSTAT_TCP_ESTABLISHED", "unit": "Count"},
{"name": "tcp_time_wait", "rename": "NETSTAT_TCP_TIME_WAIT", "unit": "Count"}
],
"metrics_collection_interval": 60
},
"statsd": {
"metrics_aggregation_interval": 60,
"metrics_collection_interval": 30,
"service_address": ":8125"
},
"swap": {
"measurement": [
{"name": "swap_used_percent", "rename": "SWAP_USED_PERCENT", "unit": "Percent"}
],
"metrics_collection_interval": 60
}
}
}
}
# This common-config is used to configure items used for both ssm and cloudwatch access
## Configuration for shared credential.
## Default credential strategy will be used if it is absent here:
## Instance role is used for EC2 case by default.
## AmazonCloudWatchAgent profile is used for onPremise case by default.
[credentials]
shared_credential_profile = "AmazonCloudWatchAgent"
shared_credential_file = "/home/ubuntu/.aws/credentials"
## Configuration for proxy.
## System-wide environment-variable will be read if it is absent here.
## i.e. HTTP_PROXY/http_proxy; HTTPS_PROXY/https_proxy; NO_PROXY/no_proxy
## Note: system-wide environment-variable is not accessible when using ssm run-command.
## Absent in both here and environment-variable means no proxy will be used.
# [proxy]
# http_proxy = "{http_url}"
# https_proxy = "{https_url}"
# no_proxy = "{domain}"
# [ssl]
# ca_bundle_path = "{ca_bundle_file_path}"
/opt/aws/amazon-cloudwatch-agent/bin/config-downloader --output-dir /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d --download-source file:/opt/aws/amazon-cloudwatch-agent/bin/config.json --mode ec2 --config /opt/aws/amazon-cloudwatch-agent/etc/common-config.toml --multi-config default
Got Home directory: /root
I! Set home dir Linux: /root
I! SDKRegionWithCredsMap region: us-east-2
Successfully fetched the config and saved in /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d/file_config.json.tmp
Start configuration validation...
/opt/aws/amazon-cloudwatch-agent/bin/config-translator --input /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.json --input-dir /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d --output /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.toml --mode ec2 --config /opt/aws/amazon-cloudwatch-agent/etc/common-config.toml --multi-config default
2020/05/06 10:17:34 Reading json config file path: /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.d/file_config.json.tmp ...
Valid Json input schema.
I! Detecting runasuser...
No csm configuration found.
Configuration validation first phase succeeded
/opt/aws/amazon-cloudwatch-agent/bin/amazon-cloudwatch-agent -schematest -config /opt/aws/amazon-cloudwatch-agent/etc/amazon-cloudwatch-agent.toml
Configuration validation second phase succeeded
Configuration validation succeeded
Created symlink /etc/systemd/system/multi-user.target.wants/amazon-cloudwatch-agent.service → /etc/systemd/system/amazon-cloudwatch-agent.service.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment