-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgrafana.tf
76 lines (73 loc) · 1.8 KB
/
grafana.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
resource "docker_service" "grafana" {
name = "grafana_app"
labels {
label = "com.docker.stack.namespace"
value = local.stack_namespaces.grafana
}
labels {
label = "prometheus-job"
value = "grafana"
}
labels {
label = "prometheus-job-port"
value = "3000"
}
labels {
label = "traefik.enable"
value = "true"
}
labels {
label = "traefik.http.routers.grafana.entrypoints"
value = "websecure"
}
labels {
label = "traefik.http.services.grafana.loadbalancer.server.port"
value = "3000"
}
task_spec {
container_spec {
labels {
label = "com.docker.stack.namespace"
value = local.stack_namespaces.grafana
}
image = "grafana/grafana:latest"
env = {
GF_SERVER_DOMAIN = "${local.stack_namespaces.grafana}.${var.domain}",
GF_SERVER_ROOT_URL = "https://${local.stack_namespaces.grafana}.${var.domain}",
}
mounts {
target = "/var/lib/grafana"
source = docker_volume.grafana_data.id
type = "volume"
}
configs {
config_id = docker_config.grafana_datasources.id
config_name = docker_config.grafana_datasources.name
file_name = "/etc/grafana/provisioning/datasources/datasources.yml"
}
}
networks_advanced {
name = docker_network.traefik.id
}
networks_advanced {
name = docker_network.prometheus.id
}
placement {
constraints = [
"node.labels.monitoring == true"
]
}
}
lifecycle {
ignore_changes = [
task_spec[0].container_spec[0].image,
]
}
}
resource "docker_volume" "grafana_data" {
name = "grafana_data"
}
resource "docker_config" "grafana_datasources" {
name = "grafana_datasources"
data = base64encode(file("${path.module}/configs/datasources.yml"))
}