diff --git a/promtail.nomad b/promtail.nomad new file mode 100644 index 0000000..6a4e5aa --- /dev/null +++ b/promtail.nomad @@ -0,0 +1,97 @@ +# There can only be a single job definition per file. This job is named +# "example" so it will create a job with the ID and Name "example". + +# The "job" stanza is the top-most configuration option in the job +# specification. A job is a declarative specification of tasks that Nomad +# should run. Jobs have a globally unique name, one or many task groups, which +# are themselves collections of one or many tasks. +# +# For more information and examples on the "job" stanza, please see +# the online documentation at: +# +# https://www.nomadproject.io/docs/job-specification/job +# +job "promtail" { + datacenters = ["dc1"] + type = "system" + // constraint { + // attribute = "${node.class}" + // operator = "regexp" + // value = "32|64" + // } + + group "promtail" { + count = 1 + + network { + port "http" { + static = 9080 + } + } + + service { + name = "promtail" + tags = ["logs", "promtail", "observability"] + port = "http" + + check { + name = "promtail-alive" + type = "tcp" + interval = "10s" + timeout = "2s" + } + + } + + restart { + # The number of attempts to run the job within the specified interval. + attempts = 2 + interval = "30m" + + # The "delay" parameter specifies the duration to wait before restarting + # a task after it has failed. + delay = "15s" + + # The "mode" parameter controls what happens when a task has restarted + # "attempts" times within the interval. "delay" mode delays the next + # restart until the next interval. "fail" mode does not restart the task + # if "attempts" has been hit within the interval. + mode = "fail" + } + + ephemeral_disk { + size = 300 + } + + task "promtail" { + # The "driver" parameter specifies the task driver that should be used to + # run the task. + driver = "raw_exec" + + config { + command = "promtail" + args = ["-config.file=local/promtail.yml"] + } + + artifact { + source = "http://minio-deploy-run.service.consul:9000/loki-bin/promtail-linux-${attr.cpu.arch}.zip" + destination = "local/promtail" + mode = "file" + } + + + resources { + cpu = 500 # 500 MHz + memory = 256 # 256MB + } + + + template { + data = file("promtail.yml.tpl") + destination = "local/promtail.yml" + change_mode = "signal" + change_signal = "SIGHUP" + } + } + } +} diff --git a/promtail.yml.tpl b/promtail.yml.tpl new file mode 100644 index 0000000..d74825e --- /dev/null +++ b/promtail.yml.tpl @@ -0,0 +1,18 @@ +server: + http_listen_port: 9080 + grpc_listen_port: 0 + +positions: + filename: /tmp/positions.yaml + +clients: + - url: http://loki-http-server.service.consul:3100/loki/api/v1/push + +scrape_configs: +- job_name: system + static_configs: + - targets: + - localhost + labels: + job: consul + __path__: /var/log/consul*.log