-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmetrics.tf
83 lines (76 loc) · 2.32 KB
/
metrics.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
locals {
service_dims = tomap({
"FunctionName" = local.resource_name
})
metrics_mappings = concat(local.base_metrics, local.cap_metrics)
cap_metrics_defs = lookup(local.capabilities, "metrics", [])
cap_metrics = [
for m in local.cap_metrics_defs : {
name = m.name
type = m.type
unit = m.unit
mappings = {
for metric_id, mapping in jsondecode(lookup(m, "mappings", "{}")) : metric_id => {
account_id = mapping.account_id
dimensions = mapping.dimensions
stat = lookup(mapping, "stat", null)
namespace = lookup(mapping, "namespace", null)
metric_name = lookup(mapping, "metric_name", null)
expression = lookup(mapping, "expression", null)
hide_from_results = lookup(mapping, "hide_from_results", null)
}
}
}
]
base_metrics = [
{
name = "invocations"
type = "invocations"
unit = "count"
mappings = {
invocations_total = {
account_id = local.account_id
stat = "Sum"
namespace = "AWS/Lambda"
metric_name = "Invocations"
dimensions = local.service_dims
}
invocations_errors = {
account_id = local.account_id
stat = "Sum"
namespace = "AWS/Lambda"
metric_name = "Errors"
dimensions = local.service_dims
}
}
},
{
name = "duration"
type = "duration"
unit = "milliseconds"
mappings = {
duration_average = {
account_id = local.account_id
stat = "Average"
namespace = "AWS/Lambda"
metric_name = "Duration"
dimensions = local.service_dims
}
duration_min = {
account_id = local.account_id
stat = "Minimum"
namespace = "AWS/Lambda"
metric_name = "Duration"
dimensions = local.service_dims
}
duration_max = {
account_id = local.account_id
stat = "Maximum"
namespace = "AWS/Lambda"
metric_name = "Duration"
dimensions = local.service_dims
}
}
}
]
}