diff --git a/production/nomad/loki-simple/README.md b/production/nomad/loki-simple/README.md index cb59ee3709ce3..e5869d2e72795 100644 --- a/production/nomad/loki-simple/README.md +++ b/production/nomad/loki-simple/README.md @@ -22,7 +22,7 @@ To deploy a different version change `variable.version` default value or specify from command line: ```shell -nomad job run -var="version=2.7.5" job.nomad.hcl +nomad job run -var="version=3.5.7" job.nomad.hcl ``` ### Scale Loki diff --git a/production/nomad/loki-simple/config.yml b/production/nomad/loki-simple/config.yml index 750c6c483cf97..808797f753bf2 100644 --- a/production/nomad/loki-simple/config.yml +++ b/production/nomad/loki-simple/config.yml @@ -9,6 +9,8 @@ common: replication_factor: 1 # Tell Loki which address to advertise instance_addr: {{ env "NOMAD_IP_grpc" }} + # Add the compactor address + compactor_address: http://loki-backend.service.consul ring: # Tell Loki which address to advertise in ring instance_addr: {{ env "NOMAD_IP_grpc" }} @@ -35,7 +37,7 @@ schema_config: period: 24h storage_config: - boltdb_shipper: + tsdb_shipper: # Nomad ephemeral disk is used to store index and cache # it will try to preserve /alloc/data between job updates active_index_directory: {{ env "NOMAD_ALLOC_DIR" }}/data/index diff --git a/production/nomad/loki-simple/job.nomad.hcl b/production/nomad/loki-simple/job.nomad.hcl index a96ea3dd0639c..123262d486ef2 100644 --- a/production/nomad/loki-simple/job.nomad.hcl +++ b/production/nomad/loki-simple/job.nomad.hcl @@ -1,7 +1,7 @@ variable "version" { type = string description = "Loki version" - default = "2.7.5" + default = "3.5.7" } job "loki" { @@ -83,6 +83,82 @@ job "loki" { } } + group "backend" { + count = 1 + + ephemeral_disk { + size = 1000 + sticky = true + } + + network { + port "http" {} + port "grpc" {} + } + + task "backend" { + driver = "docker" + user = "nobody" + + config { + image = "grafana/loki:${var.version}" + + ports = [ + "http", + "grpc", + ] + + args = [ + "-target=backend", + "-config.file=/local/config.yml", + "-config.expand-env=true", + ] + } + + template { + data = file("config.yml") + destination = "local/config.yml" + } + + template { + data = <<-EOH + S3_ACCESS_KEY_ID= + S3_SECRET_ACCESS_KEY= + EOH + + destination = "secrets/s3.env" + env = true + } + + service { + name = "loki-backend" + port = "http" + + tags = [ + "traefik.enable=true", + "traefik.http.routers.loki-backend.entrypoints=https", + "traefik.http.routers.loki-backend.rule=Host(`loki-backend.service.consul`)", + ] + + check { + name = "Loki backend" + port = "http" + type = "http" + path = "/ready" + interval = "20s" + timeout = "1s" + + initial_status = "passing" + } + } + + resources { + cpu = 500 + memory = 256 + } + } + } + group "write" { count = 2