-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathcloudwatch-agent.tf
53 lines (52 loc) · 1.23 KB
/
cloudwatch-agent.tf
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
resource "aws_ssm_parameter" "cloudwatch-agent" {
count = var.cloudwatch_agent_parameter == "" ? 1 : 0
name = "AmazonCloudWatch-${local.dns_name}"
type = "String"
insecure_value = jsonencode({
"agent" : {
"run_as_user" : "cwagent",
"quiet" : true
},
"metrics" : {
"aggregation_dimensions" : [
[
"InstanceId"
]
],
"append_dimensions" : {
"InstanceId" : "$${aws:InstanceId}",
},
"metrics_collected" : {
"disk" : {
"measurement" : [
"used_percent",
"used",
"free"
],
"metrics_collection_interval" : 60,
"resources" : [
"*"
]
},
"mem" : {
"measurement" : [
"used_percent",
"used",
"free"
],
"metrics_collection_interval" : 60
},
"swap" : {
"measurement" : [
"free",
"used_percent"
],
"metrics_collection_interval" : 60
}
}
}
})
}
locals {
cloudwatch_agent_parameter = var.cloudwatch_agent_parameter == "" ? aws_ssm_parameter.cloudwatch-agent[0].name : var.cloudwatch_agent_parameter
}