2023-05-12 17:11:11 +00:00
|
|
|
job "exporters" {
|
2022-03-03 17:37:49 +00:00
|
|
|
datacenters = ["dc1"]
|
2024-05-30 18:41:40 +00:00
|
|
|
type = "service"
|
|
|
|
priority = 55
|
2022-03-03 17:37:49 +00:00
|
|
|
|
2024-08-29 20:51:18 +00:00
|
|
|
constraint {
|
|
|
|
distinct_hosts = true
|
|
|
|
}
|
|
|
|
|
2022-07-25 22:49:29 +00:00
|
|
|
group "promtail" {
|
2024-05-30 18:41:40 +00:00
|
|
|
# TODO: This must be updated to match the nubmer of servers (possibly grabbed from TF)
|
2024-08-29 20:51:18 +00:00
|
|
|
# I am moving away from `system` jobs because of https://github.com/hashicorp/nomad/issues/1202
|
|
|
|
count = 2
|
2022-07-25 22:49:29 +00:00
|
|
|
|
|
|
|
network {
|
|
|
|
mode = "bridge"
|
|
|
|
|
|
|
|
port "promtail" {
|
2023-08-24 19:36:47 +00:00
|
|
|
%{~ if use_wesher ~}
|
2023-05-03 04:14:36 +00:00
|
|
|
host_network = "wesher"
|
2023-08-24 19:36:47 +00:00
|
|
|
%{~ endif ~}
|
2022-07-25 22:49:29 +00:00
|
|
|
to = 9080
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-07-25 17:46:16 +00:00
|
|
|
service {
|
|
|
|
name = "promtail"
|
2023-03-24 18:24:36 +00:00
|
|
|
provider = "nomad"
|
2022-07-25 17:46:16 +00:00
|
|
|
port = "promtail"
|
|
|
|
|
|
|
|
meta {
|
2023-08-24 19:36:47 +00:00
|
|
|
nomad_dc = "$${NOMAD_DC}"
|
|
|
|
nomad_node_name = "$${node.unique.name}"
|
2022-07-25 17:46:16 +00:00
|
|
|
}
|
|
|
|
|
2023-03-24 18:24:36 +00:00
|
|
|
tags = [
|
|
|
|
"prometheus.scrape",
|
2023-03-24 23:32:37 +00:00
|
|
|
]
|
2022-07-25 17:46:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
task "promtail" {
|
|
|
|
driver = "docker"
|
|
|
|
|
|
|
|
config {
|
2024-11-21 19:11:57 +00:00
|
|
|
image = "grafana/promtail:3.3.0"
|
2023-08-24 19:36:47 +00:00
|
|
|
args = ["-config.file=$${NOMAD_TASK_DIR}/promtail.yml"]
|
2022-07-25 17:46:16 +00:00
|
|
|
ports = ["promtail"]
|
|
|
|
|
|
|
|
# Bind mount host machine-id and log directories
|
|
|
|
|
|
|
|
mount {
|
|
|
|
type = "bind"
|
|
|
|
source = "/etc/machine-id"
|
|
|
|
target = "/etc/machine-id"
|
|
|
|
readonly = true
|
|
|
|
}
|
|
|
|
|
|
|
|
mount {
|
|
|
|
type = "bind"
|
|
|
|
source = "/var/log/journal/"
|
|
|
|
target = "/var/log/journal/"
|
|
|
|
readonly = true
|
|
|
|
}
|
|
|
|
|
|
|
|
mount {
|
|
|
|
type = "bind"
|
|
|
|
source = "/run/log/journal/"
|
|
|
|
target = "/run/log/journal/"
|
|
|
|
readonly = true
|
|
|
|
}
|
|
|
|
|
2022-07-25 22:49:29 +00:00
|
|
|
# mount {
|
|
|
|
# type = "bind"
|
|
|
|
# source = "/var/log/audit"
|
|
|
|
# target = "/var/log/audit"
|
|
|
|
# readonly = true
|
|
|
|
# }
|
2022-07-25 17:46:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
template {
|
|
|
|
data = <<EOF
|
|
|
|
---
|
|
|
|
server:
|
|
|
|
http_listen_address: 0.0.0.0
|
|
|
|
http_listen_port: 9080
|
|
|
|
|
|
|
|
clients:
|
2023-03-24 18:24:36 +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:
|
|
|
|
|
|
|
|
- job_name: journal
|
|
|
|
journal:
|
|
|
|
json: false
|
|
|
|
max_age: 12h
|
|
|
|
path: /var/log/journal
|
|
|
|
labels:
|
|
|
|
job: systemd-journal
|
|
|
|
relabel_configs:
|
|
|
|
- source_labels: ['__journal__systemd_unit']
|
|
|
|
target_label: unit
|
|
|
|
- source_labels: ['__journal__hostname']
|
|
|
|
target_label: hostname
|
|
|
|
- source_labels: ['__journal__transport']
|
|
|
|
target_label: journal_transport
|
|
|
|
# Docker log labels
|
|
|
|
- source_labels: ['__journal_syslog_identifier']
|
|
|
|
target_label: syslog_identifier
|
|
|
|
- source_labels: ['__journal_image_name']
|
|
|
|
target_label: docker_image_name
|
|
|
|
- source_labels: ['__journal_container_name']
|
|
|
|
target_label: docker_container_name
|
|
|
|
- source_labels: ['__journal_container_id']
|
|
|
|
target_label: docker_container_id
|
|
|
|
- source_labels: ['__journal_com_docker_compose_project']
|
|
|
|
target_label: docker_compose_project
|
|
|
|
- source_labels: ['__journal_com_docker_compose_service']
|
|
|
|
target_label: docker_compose_service
|
2023-03-17 18:47:40 +00:00
|
|
|
- source_labels: ['__journal_com_hashicorp_nomad_alloc_id']
|
|
|
|
target_label: nomad_alloc_id
|
|
|
|
- source_labels: ['__journal_com_hashicorp_nomad_job_id']
|
|
|
|
target_label: nomad_job_id
|
|
|
|
- source_labels: ['__journal_com_hashicorp_nomad_job_name']
|
|
|
|
target_label: nomad_job_name
|
|
|
|
- source_labels: ['__journal_com_hashicorp_nomad_node_name']
|
|
|
|
target_label: nomad_node_name
|
|
|
|
- source_labels: ['__journal_com_hashicorp_nomad_group_name']
|
|
|
|
target_label: nomad_group_name
|
|
|
|
- source_labels: ['__journal_com_hashicorp_nomad_task_name']
|
|
|
|
target_label: nomad_task_name
|
2022-07-25 17:46:16 +00:00
|
|
|
EOF
|
2023-08-24 19:36:47 +00:00
|
|
|
destination = "$${NOMAD_TASK_DIR}/promtail.yml"
|
2022-07-25 17:46:16 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
resources {
|
|
|
|
cpu = 50
|
2023-02-27 19:53:05 +00:00
|
|
|
memory = 100
|
2022-07-25 17:46:16 +00:00
|
|
|
}
|
|
|
|
}
|
2022-03-03 17:37:49 +00:00
|
|
|
}
|
|
|
|
}
|