forked from chime/terraform-aws-alternat
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcwagent.json.tftpl
More file actions
67 lines (63 loc) · 2.34 KB
/
cwagent.json.tftpl
File metadata and controls
67 lines (63 loc) · 2.34 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/usr/bin/env bash
CWAGENT_CONFIG_DIR="/opt/aws/amazon-cloudwatch-agent/etc"
CWAGENT_CONFIG_FILE="$CWAGENT_CONFIG_DIR/amazon-cloudwatch-agent.json"
# Check if parent directory exists and is writable
if [ ! -d $CWAGENT_CONFIG_DIR ] || [ ! -w $CWAGENT_CONFIG_DIR ]; then
echo "Error: Directory $CWAGENT_CONFIG_DIR does not exist or is not writable"
exit 1
fi
# Configuration that aims to report most metrics as provided for managed NAT Gateways.
#
# Adapted from the fck-nat project. All credit goes to its original contributors.
# Original documentation: https://fck-nat.dev/develop/features/#metrics
cat <<EOF > $CWAGENT_CONFIG_FILE
{
"agent": {
"metrics_collection_interval": 60,
"run_as_user": "root",
"usage_data": false
},
"metrics": {
"namespace": "${cloudwatch_namespace}",
"metrics_collected": {
"net": {
"resources": ${cloudwatch_interfaces},
"measurement": [
{ "name": "bytes_recv", "rename": "BytesIn", "unit": "Bytes" },
{ "name": "bytes_sent", "rename": "BytesOut", "unit": "Bytes" },
{ "name": "packets_sent", "rename": "PacketsOutCount", "unit": "Count" },
{ "name": "packets_recv", "rename": "PacketsInCount", "unit": "Count" },
{ "name": "drop_in", "rename": "PacketsDropInCount", "unit": "Count" },
{ "name": "drop_out", "rename": "PacketsDropOutCount", "unit": "Count" }
]
},
"netstat": {
"measurement": [
{ "name": "tcp_syn_sent", "rename": "ConnectionAttemptOutCount", "unit": "Count" },
{ "name": "tcp_syn_recv", "rename": "ConnectionAttemptInCount", "unit": "Count" },
{ "name": "tcp_established", "rename": "ConnectionEstablishedCount", "unit": "Count" }
]
},
"ethtool": {
"interface_include": ${cloudwatch_interfaces},
"metrics_include": [
"bw_in_allowance_exceeded",
"bw_out_allowance_exceeded",
"conntrack_allowance_exceeded",
"pps_allowance_exceeded"
]
},
"mem": {
"measurement": [
{ "name": "used_percent", "rename": "MemoryUsed", "unit": "Percent" }
]
}
},
"append_dimensions": {
"InstanceId": "\$${aws:InstanceId}",
"AutoScalingGroupName": "\$${aws:AutoScalingGroupName}"
}
}
}
EOF
systemctl restart amazon-cloudwatch-agent