Skip to content

Commit d7711bb

Browse files
committed
services/nomad: Use per-machine log shippers
1 parent 742dba9 commit d7711bb

9 files changed

Lines changed: 101 additions & 136 deletions

File tree

ansible/ansible.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,7 @@
22
inventory = inventory
33
nocows = 1
44
retry_files_enabled = false
5+
6+
[ssh_connection]
7+
pipelining = True
8+
control_path = /tmp/ansible-ssh-%%h-%%p-%%r

ansible/roles/nomad-client/templates/40-client.hcl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ client {
2121
path = "/var/log"
2222
read_only = false
2323
}
24+
25+
host_volume "dockersocket" {
26+
path = "/run/docker.sock"
27+
read_only = true
28+
}
2429
{% for volume in nomad_host_volumes|default([]) %}
2530

2631
host_volume "{{volume.name}}" {
@@ -34,3 +39,9 @@ vault {
3439
enabled = true
3540
address = "http://active.vault.service.consul:8200"
3641
}
42+
43+
plugin "docker" {
44+
config {
45+
extra_labels = ["*"]
46+
}
47+
}

ansible/roles/vault/tasks/main.yml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@
44
pkg: vault
55
state: present
66

7-
- name: Enforce ownership on /etc/vault
8-
file:
9-
path: /etc/vault
10-
state: directory
11-
owner: _vault
12-
group: _vault
13-
mode: 0750
14-
157
- name: Install Storage config
168
template:
179
src: 25-storage.hcl.j2

services/nomad/apps/debuginfod.nomad

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -81,37 +81,5 @@ job "debuginfod" {
8181
delay = "30s"
8282
}
8383
}
84-
task "promtail" {
85-
driver = "docker"
86-
87-
config {
88-
image = "grafana/promtail:2.1.0"
89-
args = ["-config.file=/local/promtail.yml"]
90-
}
91-
92-
template {
93-
data = <<EOT
94-
---
95-
server:
96-
disable: true
97-
clients:
98-
- url: http://loki.service.consul:3100/loki/api/v1/push
99-
positions:
100-
filename: /alloc/positions.yaml
101-
scrape_configs:
102-
- job_name: debuginfod
103-
static_configs:
104-
- targets:
105-
- localhost
106-
labels:
107-
__path__: /alloc/logs/debuginfod*
108-
nomad_namespace: "{{ env "NOMAD_NAMESPACE" }}"
109-
nomad_job: "debuginfod"
110-
nomad_group: "{{ env "NOMAD_GROUP_NAME" }}"
111-
nomad_task: "{{ env "NOMAD_TASK_NAME" }}"
112-
EOT
113-
destination = "local/promtail.yml"
114-
}
115-
}
11684
}
11785
}

services/nomad/build/buildsync-aarch64.nomad

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -51,37 +51,5 @@ EOF
5151
destination = "local/known_hosts"
5252
}
5353
}
54-
task "promtail" {
55-
driver = "docker"
56-
57-
config {
58-
image = "grafana/promtail:2.1.0"
59-
args = ["-config.file=/local/promtail.yml"]
60-
}
61-
62-
template {
63-
data = <<EOT
64-
---
65-
server:
66-
disable: true
67-
clients:
68-
- url: http://loki.service.consul:3100/loki/api/v1/push
69-
positions:
70-
filename: /alloc/positions.yaml
71-
scrape_configs:
72-
- job_name: buildsync-aarch64
73-
static_configs:
74-
- targets:
75-
- localhost
76-
labels:
77-
__path__: /alloc/logs/rsync*
78-
nomad_namespace: "{{ env "NOMAD_NAMESPACE" }}"
79-
nomad_job: "buildsync-aarch64"
80-
nomad_group: "{{ env "NOMAD_GROUP_NAME" }}"
81-
nomad_task: "{{ env "NOMAD_TASK_NAME" }}"
82-
EOT
83-
destination = "local/promtail.yml"
84-
}
85-
}
8654
}
8755
}

services/nomad/build/buildsync-dist.nomad

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -69,37 +69,5 @@ EOF
6969
destination = "local/known_hosts"
7070
}
7171
}
72-
task "promtail" {
73-
driver = "docker"
74-
75-
config {
76-
image = "grafana/promtail:2.1.0"
77-
args = ["-config.file=/local/promtail.yml"]
78-
}
79-
80-
template {
81-
data = <<EOT
82-
---
83-
server:
84-
disable: true
85-
clients:
86-
- url: http://loki.service.consul:3100/loki/api/v1/push
87-
positions:
88-
filename: /alloc/positions.yaml
89-
scrape_configs:
90-
- job_name: buildsync-dist
91-
static_configs:
92-
- targets:
93-
- localhost
94-
labels:
95-
__path__: /alloc/logs/rsync*
96-
nomad_namespace: "{{ env "NOMAD_NAMESPACE" }}"
97-
nomad_job: "buildsync-dist"
98-
nomad_group: "{{ env "NOMAD_GROUP_NAME" }}"
99-
nomad_task: "{{ env "NOMAD_TASK_NAME" }}"
100-
EOT
101-
destination = "local/promtail.yml"
102-
}
103-
}
10472
}
10573
}

services/nomad/build/buildsync-musl.nomad

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -51,37 +51,5 @@ EOF
5151
destination = "local/known_hosts"
5252
}
5353
}
54-
task "promtail" {
55-
driver = "docker"
56-
57-
config {
58-
image = "grafana/promtail:2.1.0"
59-
args = ["-config.file=/local/promtail.yml"]
60-
}
61-
62-
template {
63-
data = <<EOT
64-
---
65-
server:
66-
disable: true
67-
clients:
68-
- url: http://loki.service.consul:3100/loki/api/v1/push
69-
positions:
70-
filename: /alloc/positions.yaml
71-
scrape_configs:
72-
- job_name: buildsync-musl
73-
static_configs:
74-
- targets:
75-
- localhost
76-
labels:
77-
__path__: /alloc/logs/rsync*
78-
nomad_namespace: "{{ env "NOMAD_NAMESPACE" }}"
79-
nomad_job: "buildsync-musl"
80-
nomad_group: "{{ env "NOMAD_GROUP_NAME" }}"
81-
nomad_task: "{{ env "NOMAD_TASK_NAME" }}"
82-
EOT
83-
destination = "local/promtail.yml"
84-
}
85-
}
8654
}
8755
}

services/nomad/monitoring/grafana.nomad

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ EOT
108108
image = "ghcr.io/netauth/ldap:v0.2.3"
109109
}
110110

111+
resources {
112+
memory = 100
113+
}
114+
111115
env {
112116
NETAUTH_LOGLEVEL = "trace"
113117
}
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
job "vector" {
2+
datacenters = [
3+
"VOID",
4+
"VOID-MX",
5+
"VOID-PROXY",
6+
"VOID-MIRROR",
7+
"VOID-CONTROL",
8+
]
9+
namespace = "monitoring"
10+
type = "system"
11+
priority = 99
12+
13+
group "vector" {
14+
network {
15+
mode = "bridge"
16+
port "metrics" { to = 8088 }
17+
}
18+
19+
volume "dockersocket" {
20+
type = "host"
21+
source = "dockersocket"
22+
read_only = true
23+
}
24+
25+
service {
26+
name = "vector"
27+
port = "8088"
28+
address_mode = "alloc"
29+
}
30+
31+
task "vector" {
32+
driver = "docker"
33+
34+
config {
35+
image = "timberio/vector:0.13.1-debian"
36+
args = ["-c", "/local/vector.yaml"]
37+
ports = ["metrics"]
38+
}
39+
40+
volume_mount {
41+
volume = "dockersocket"
42+
destination = "/var/run/docker.sock"
43+
read_only = true
44+
}
45+
46+
template {
47+
data = <<EOF
48+
---
49+
sources:
50+
docker:
51+
type: docker_logs
52+
exclude_containers:
53+
- "vector-"
54+
- "loki-"
55+
sinks:
56+
loki:
57+
type: loki
58+
inputs:
59+
- docker
60+
endpoint: http://loki.service.consul:3100
61+
encoding:
62+
codec: text
63+
healthcheck:
64+
enabled: false
65+
out_of_order_action: drop
66+
labels:
67+
nomad_namespace: "{{ label.com\\.hashicorp\\.nomad\\.namespace }}"
68+
nomad_job: "{{ label.com\\.hashicorp\\.nomad\\.job_name }}"
69+
nomad_group: "{{ label.com\\.hashicorp\\.nomad\\.task_group_name }}"
70+
nomad_task: "{{ label.com\\.hashicorp\\.nomad\\.task_name }}"
71+
nomad_node: "{{ label.com\\.hashicorp\\.nomad\\.node_name }}"
72+
nomad_alloc: "{{ label.com\\.hashicorp\\.nomad\\.alloc_id }}"
73+
EOF
74+
left_delimiter = "///1"
75+
right_delimiter = "///2"
76+
77+
destination = "local/vector.yaml"
78+
}
79+
80+
}
81+
}
82+
}

0 commit comments

Comments
 (0)