-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocals_metrics.tf
80 lines (73 loc) · 2.04 KB
/
locals_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
locals {
metrics_shortname = "postgres-exporter"
zone = var.zone
scheme = var.zone.https == 1 ? "https" : "http"
hostname = "${local.metrics_shortname}-${local.postfix}"
entrypoint = var.zone.entrypoint
route = local.metrics_shortname
metrics_service_port = 9187
middleware_rewrite = "${local.metrics_shortname}-rewrite"
middlewares = local.middleware_rewrite
metrics_path = "/stats/postgres/metrics"
metrics_rewrite_path = "/stats/postgres/"
}
locals {
metrics_env = [
"DATA_SOURCE_NAME=${local.connection}"
]
metrics_cmd = [
]
}
locals {
labels_https = [{
label = "traefik.http.routers.${local.route}.entrypoints"
value = "https"
}, {
label = "traefik.http.routers.${local.route}.tls"
value = "true"
}, {
label = "traefik.http.routers.${local.route}.tls.certresolver"
value = "le"
}]
labels_entrypoint = [
{
label = "traefik.http.routers.${local.route}.rule"
value = "${var.zone.host_rule} && PathPrefix(`${local.metrics_path}`)"
},
{
label = "traefik.http.routers.${local.route}.entrypoints"
value = local.entrypoint
}
]
labels_service = [
{
label = "traefik.http.routers.${local.route}.service"
value = "${local.metrics_shortname}@docker"
},
{
label = "traefik.http.services.${local.metrics_shortname}.loadbalancer.server.port"
value = local.metrics_service_port
}
]
labels_strip_prefix = [
{
label = "traefik.http.middlewares.${local.middleware_rewrite}.stripprefix.prefixes"
value = local.metrics_rewrite_path
}
]
metrics_labels = concat(
var.network_params.labels,
var.zone.labels,
local.labels_entrypoint,
local.labels_service,
var.zone.https == 1 ? local.labels_https : [],
local.labels_strip_prefix,
[{
label = "traefik.http.routers.${local.route}.middlewares"
value = local.middlewares
}, {
label = "role"
value = local.metrics_shortname
}]
)
}