aboutsummaryrefslogtreecommitdiff
path: root/terraform/hash-prometheus/prometheus.tf
diff options
context:
space:
mode:
Diffstat (limited to 'terraform/hash-prometheus/prometheus.tf')
-rw-r--r--terraform/hash-prometheus/prometheus.tf71
1 files changed, 71 insertions, 0 deletions
diff --git a/terraform/hash-prometheus/prometheus.tf b/terraform/hash-prometheus/prometheus.tf
new file mode 100644
index 0000000..dd25727
--- /dev/null
+++ b/terraform/hash-prometheus/prometheus.tf
@@ -0,0 +1,71 @@
+data "docker_registry_image" "prometheus" {
+ name = "prom/prometheus:v2.53.2"
+}
+
+resource "docker_image" "prometheus" {
+ name = data.docker_registry_image.prometheus.name
+ pull_triggers = [data.docker_registry_image.prometheus.sha256_digest]
+}
+
+resource "docker_volume" "prometheus" {
+ name = "prometheus"
+}
+
+resource "docker_container" "prometheus" {
+ image = docker_image.prometheus.image_id
+ name = "prometheus"
+ must_run = true
+
+ env = [
+ ]
+
+ networks_advanced {
+ name = data.docker_network.dn42.name
+ }
+
+ # networks_advanced {
+ # name = data.docker_network.traefik.name
+ # }
+
+ # dynamic "labels" {
+ # for_each = [
+ # { label = "traefik.enable", value = "true" },
+ # { label = "traefik.docker.network", value = data.docker_network.traefik.name },
+ # { label = "traefik.http.routers.prometheus.rule", value = "Host(`prometheus.trygvis.io`)" },
+ # { label = "traefik.http.routers.prometheus.entrypoints", value = "websecure" },
+ # { label = "traefik.http.routers.prometheus.tls.certresolver", value = "linode" },
+ # ]
+ # content {
+ # label = labels.value["label"]
+ # value = labels.value["value"]
+ # }
+ # }
+
+ mounts {
+ source = "${local.path}"
+ target = "/etc/prometheus"
+ type = "bind"
+ }
+
+ volumes {
+ volume_name = docker_volume.prometheus.name
+ read_only = false
+ container_path = "/prometheus"
+ }
+
+ depends_on = [ null_resource.mkdir ]
+}
+
+locals {
+ path = "/etc/docker-service/prometheus"
+}
+
+resource "null_resource" "mkdir" {
+ triggers = {
+ path = local.path
+ }
+
+ provisioner "local-exec" {
+ command = "ssh ${local.host} sudo mkdir -p ${local.path}"
+ }
+}