2022-07-25 17:46:16 +00:00
|
|
|
job "syslogng" {
|
|
|
|
datacenters = ["dc1"]
|
|
|
|
type = "service"
|
|
|
|
|
|
|
|
group "promtail" {
|
|
|
|
count = 1
|
|
|
|
|
|
|
|
network {
|
|
|
|
mode = "bridge"
|
|
|
|
|
|
|
|
port "main" {
|
|
|
|
to = 1514
|
|
|
|
}
|
|
|
|
|
|
|
|
port "metrics" {
|
|
|
|
to = 9080
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
service {
|
|
|
|
name = "syslogng-promtail"
|
2022-11-21 00:24:00 +00:00
|
|
|
provider = "nomad"
|
2022-07-25 17:46:16 +00:00
|
|
|
port = "main"
|
|
|
|
}
|
|
|
|
|
|
|
|
task "promtail" {
|
|
|
|
driver = "docker"
|
|
|
|
|
2023-01-13 23:47:48 +00:00
|
|
|
meta = {
|
|
|
|
"diun.sort_tags" = "semver"
|
|
|
|
"diun.watch_repo" = true
|
2023-02-14 20:28:41 +00:00
|
|
|
"diun.include_tags" = "^[0-9]+\\.[0-9]+\\.[0-9]+$"
|
2023-01-13 23:47:48 +00:00
|
|
|
}
|
|
|
|
|
2022-07-25 17:46:16 +00:00
|
|
|
config {
|
2023-09-19 04:58:00 +00:00
|
|
|
image = "grafana/promtail:2.9.1"
|
2022-07-25 17:46:16 +00:00
|
|
|
ports = ["main", "metrics"]
|
|
|
|
args = ["--config.file=/etc/promtail/promtail.yml"]
|
|
|
|
|
|
|
|
mount {
|
|
|
|
type = "bind"
|
|
|
|
target = "/etc/promtail/promtail.yml"
|
|
|
|
source = "local/promtail.yml"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template {
|
|
|
|
data = <<EOF
|
|
|
|
---
|
|
|
|
server:
|
|
|
|
http_listen_address: 0.0.0.0
|
|
|
|
http_listen_port: 9080
|
|
|
|
|
|
|
|
clients:
|
2022-11-21 00:24:00 +00:00
|
|
|
{{ range nomadService 1 (env "NOMAD_ALLOC_ID") "loki" -}}
|
|
|
|
- url: http://{{ .Address }}:{{ .Port }}/loki/api/v1/push
|
|
|
|
{{- end }}
|
2022-07-25 17:46:16 +00:00
|
|
|
|
|
|
|
scrape_configs:
|
|
|
|
# TCP syslog receiver
|
|
|
|
- job_name: syslog
|
|
|
|
syslog:
|
2022-07-25 22:49:29 +00:00
|
|
|
listen_address: 0.0.0.0:{{ env "NOMAD_PORT_main" }}
|
2022-07-25 17:46:16 +00:00
|
|
|
labels:
|
|
|
|
job: syslog
|
|
|
|
relabel_configs:
|
|
|
|
- source_labels: ['__syslog_message_hostname']
|
|
|
|
target_label: hostname
|
|
|
|
EOF
|
|
|
|
destination = "local/promtail.yml"
|
|
|
|
}
|
|
|
|
|
|
|
|
resources {
|
|
|
|
cpu = 50
|
2022-07-25 23:35:30 +00:00
|
|
|
memory = 20
|
2022-07-25 17:46:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
group "syslogng" {
|
|
|
|
count = 1
|
|
|
|
|
|
|
|
network {
|
|
|
|
mode = "bridge"
|
|
|
|
port "main" {
|
2022-09-04 21:07:04 +00:00
|
|
|
to = 514
|
2022-07-25 17:46:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
service {
|
|
|
|
name = "syslogng"
|
2023-03-24 18:24:36 +00:00
|
|
|
provider = "nomad"
|
2022-07-25 17:46:16 +00:00
|
|
|
port = "main"
|
|
|
|
}
|
|
|
|
|
|
|
|
task "syslogng" {
|
|
|
|
driver = "docker"
|
|
|
|
|
|
|
|
config {
|
2022-07-25 22:49:29 +00:00
|
|
|
image = "balabit/syslog-ng:3.37.1"
|
2022-07-25 17:46:16 +00:00
|
|
|
ports = ["main"]
|
|
|
|
args = ["--no-caps"]
|
|
|
|
|
|
|
|
mount {
|
|
|
|
type = "bind"
|
|
|
|
target = "/etc/syslog-ng/syslog-ng.conf"
|
|
|
|
source = "local/syslog-ng.conf"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template {
|
|
|
|
data = <<EOF
|
2022-09-04 21:07:04 +00:00
|
|
|
@version: 3.37
|
|
|
|
@include "scl.conf"
|
2022-07-25 17:46:16 +00:00
|
|
|
|
2022-09-04 21:07:04 +00:00
|
|
|
source s_network {
|
|
|
|
default-network-drivers(
|
|
|
|
);
|
2022-07-25 17:46:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
source s_internal {
|
|
|
|
internal();
|
|
|
|
};
|
|
|
|
|
|
|
|
destination d_loki {
|
2022-11-21 00:24:00 +00:00
|
|
|
{{ range nomadService 1 (env "NOMAD_ALLOC_ID") "syslogng-promtail" -}}
|
|
|
|
syslog("{{ .Address }}" transport("tcp") port({{ .Port }}));
|
|
|
|
{{- end }}
|
2022-07-25 17:46:16 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
log { source(s_internal); destination(d_loki); };
|
2022-09-04 21:07:04 +00:00
|
|
|
log { source(s_network); destination(d_loki); };
|
2022-07-25 17:46:16 +00:00
|
|
|
EOF
|
|
|
|
destination = "local/syslog-ng.conf"
|
|
|
|
}
|
|
|
|
|
|
|
|
resources {
|
|
|
|
cpu = 50
|
2022-07-25 23:35:30 +00:00
|
|
|
memory = 10
|
2022-07-25 17:46:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|