generated from kabisa/terraform-module-template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
86 lines (82 loc) · 2.08 KB
/
main.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
84
85
86
locals {
filters = [
"env:${var.env}",
# var.logs_service_identifier == "service" ? "service:${var.service}" : "url_host:${var.url_host}"
"${var.logs_service_identifier}:${var.service}"
]
tag_specials_regex = "/[^a-z0-9\\-_:.\\/]/"
tags = concat(
[
"terraform:true",
"env:${var.env}",
"${var.logs_service_identifier}:${var.service}"
],
var.additional_tags
)
# Normalize all the tags according to best practices defined by Datadog. The
# following changes are made:
#
# * Make all characters lowercase.
# * Replace special characters with an underscore.
# * Remove duplicate underscores.
# * Remove any non-letter leading characters.
# * Remove any trailing underscores.
#
# See: https://docs.datadoghq.com/developers/guide/what-best-practices-are-recommended-for-naming-metrics-and-tags
normalized_tags = [
for tag
in local.tags :
replace(
replace(
replace(
replace(lower(tag), local.tag_specials_regex, "_")
,
"/_+/",
"_"
),
"/^[^a-z]+/",
""
),
"/_+$/",
""
)
]
normalized_filters = [
for tag
in local.filters :
replace(
replace(
replace(
replace(lower(tag), local.tag_specials_regex, "_")
,
"/_+/",
"_"
),
"/^[^a-z]+/",
""
),
"/_+$/",
""
)
]
filter_str = var.slo_filter_str_override != null ? var.slo_filter_str_override : join(",", local.normalized_filters)
service_display_name = var.service_display_name != null ? var.service_display_name : var.service
duration_group_bys = coalesce(var.duration_group_bys_override, [
var.logs_service_identifier,
"status",
"env",
"host"
])
request_count_group_bys = coalesce(var.request_count_group_bys_override, [
var.logs_service_identifier,
"status",
"env",
"host"
])
latency_buckets_group_bys = coalesce(var.latency_buckets_group_bys_override, [
var.logs_service_identifier,
"status",
"env",
"host"
])
}