feat(observability): label all services for promtail; enable Traefik access logs
This commit is contained in:
58
compose.yml
58
compose.yml
@@ -46,6 +46,8 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- ./infra/coredns/Corefile:/etc/coredns/Corefile:ro
|
- ./infra/coredns/Corefile:/etc/coredns/Corefile:ro
|
||||||
- ./infra/coredns/hosts:/etc/coredns/hosts:ro
|
- ./infra/coredns/hosts:/etc/coredns/hosts:ro
|
||||||
|
labels:
|
||||||
|
- "promtail=true"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
traefik:
|
traefik:
|
||||||
@@ -68,6 +70,12 @@ services:
|
|||||||
environment:
|
environment:
|
||||||
- DOMAIN=${DOMAIN:-fhirworx.io}
|
- DOMAIN=${DOMAIN:-fhirworx.io}
|
||||||
- OTEL_SERVICE_NAME=traefik
|
- OTEL_SERVICE_NAME=traefik
|
||||||
|
- TRAEFIK_ACCESSLOG=true
|
||||||
|
- TRAEFIK_ACCESSLOG_FORMAT=json
|
||||||
|
- TRAEFIK_ACCESSLOG_FIELDS_DEFAULTMODE=keep
|
||||||
|
- TRAEFIK_ACCESSLOG_FIELDS_HEADERS_DEFAULTMODE=keep
|
||||||
|
labels:
|
||||||
|
- "promtail=true"
|
||||||
security_opt:
|
security_opt:
|
||||||
- no-new-privileges:true
|
- no-new-privileges:true
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
@@ -86,6 +94,8 @@ services:
|
|||||||
volumes:
|
volumes:
|
||||||
- rustfs_data:/data
|
- rustfs_data:/data
|
||||||
- rustfs_logs:/logs
|
- rustfs_logs:/logs
|
||||||
|
labels:
|
||||||
|
- "promtail=true"
|
||||||
security_opt:
|
security_opt:
|
||||||
- no-new-privileges:true
|
- no-new-privileges:true
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
@@ -125,6 +135,8 @@ services:
|
|||||||
- POSTGRESQL_DATABASE=gitea
|
- POSTGRESQL_DATABASE=gitea
|
||||||
volumes:
|
volumes:
|
||||||
- postgres_data:/bitnami/postgresql
|
- postgres_data:/bitnami/postgresql
|
||||||
|
labels:
|
||||||
|
- "promtail=true"
|
||||||
security_opt:
|
security_opt:
|
||||||
- no-new-privileges:true
|
- no-new-privileges:true
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
@@ -194,6 +206,8 @@ services:
|
|||||||
depends_on:
|
depends_on:
|
||||||
- postgres
|
- postgres
|
||||||
- rustfs
|
- rustfs
|
||||||
|
labels:
|
||||||
|
- "promtail=true"
|
||||||
security_opt:
|
security_opt:
|
||||||
- no-new-privileges:true
|
- no-new-privileges:true
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
@@ -216,6 +230,8 @@ services:
|
|||||||
- ./infra/act-runner/config.yaml:/config.yaml:ro
|
- ./infra/act-runner/config.yaml:/config.yaml:ro
|
||||||
depends_on:
|
depends_on:
|
||||||
- git
|
- git
|
||||||
|
labels:
|
||||||
|
- "promtail=true"
|
||||||
security_opt:
|
security_opt:
|
||||||
- no-new-privileges:true
|
- no-new-privileges:true
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
@@ -258,6 +274,8 @@ services:
|
|||||||
count: all
|
count: all
|
||||||
capabilities: [gpu]
|
capabilities: [gpu]
|
||||||
shm_size: "1g"
|
shm_size: "1g"
|
||||||
|
labels:
|
||||||
|
- "promtail=true"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
zotero:
|
zotero:
|
||||||
@@ -306,6 +324,8 @@ services:
|
|||||||
- driver: nvidia
|
- driver: nvidia
|
||||||
count: 1
|
count: 1
|
||||||
capabilities: [gpu]
|
capabilities: [gpu]
|
||||||
|
labels:
|
||||||
|
- "promtail=true"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
webdav:
|
webdav:
|
||||||
@@ -331,6 +351,8 @@ services:
|
|||||||
- --vfs-cache-mode=full
|
- --vfs-cache-mode=full
|
||||||
tmpfs:
|
tmpfs:
|
||||||
- /tmp/rclone-cache
|
- /tmp/rclone-cache
|
||||||
|
labels:
|
||||||
|
- "promtail=true"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
depends_on:
|
depends_on:
|
||||||
- rustfs
|
- rustfs
|
||||||
@@ -362,6 +384,8 @@ services:
|
|||||||
depends_on:
|
depends_on:
|
||||||
- postgres
|
- postgres
|
||||||
- rustfs
|
- rustfs
|
||||||
|
labels:
|
||||||
|
- "promtail=true"
|
||||||
security_opt:
|
security_opt:
|
||||||
- no-new-privileges:true
|
- no-new-privileges:true
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
@@ -386,6 +410,8 @@ services:
|
|||||||
depends_on:
|
depends_on:
|
||||||
- nessie
|
- nessie
|
||||||
- rustfs
|
- rustfs
|
||||||
|
labels:
|
||||||
|
- "promtail=true"
|
||||||
security_opt:
|
security_opt:
|
||||||
- no-new-privileges:true
|
- no-new-privileges:true
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
@@ -420,6 +446,8 @@ services:
|
|||||||
depends_on:
|
depends_on:
|
||||||
- postgres
|
- postgres
|
||||||
- rustfs
|
- rustfs
|
||||||
|
labels:
|
||||||
|
- "promtail=true"
|
||||||
security_opt:
|
security_opt:
|
||||||
- no-new-privileges:true
|
- no-new-privileges:true
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
@@ -435,6 +463,8 @@ services:
|
|||||||
- ./assets/css/dashboard.css:/usr/share/nginx/html/dashboard.css:ro
|
- ./assets/css/dashboard.css:/usr/share/nginx/html/dashboard.css:ro
|
||||||
- ./assets/css/inject.css:/usr/share/nginx/html/fhirworx.css:ro
|
- ./assets/css/inject.css:/usr/share/nginx/html/fhirworx.css:ro
|
||||||
- ./assets/icons/fav32.png:/usr/share/nginx/html/fav32.png:ro
|
- ./assets/icons/fav32.png:/usr/share/nginx/html/fav32.png:ro
|
||||||
|
labels:
|
||||||
|
- "promtail=true"
|
||||||
security_opt:
|
security_opt:
|
||||||
- no-new-privileges:true
|
- no-new-privileges:true
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
@@ -448,6 +478,8 @@ services:
|
|||||||
container_name: docs
|
container_name: docs
|
||||||
networks:
|
networks:
|
||||||
- gateway
|
- gateway
|
||||||
|
labels:
|
||||||
|
- "promtail=true"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
api:
|
api:
|
||||||
@@ -482,6 +514,8 @@ services:
|
|||||||
- postgres
|
- postgres
|
||||||
- rustfs
|
- rustfs
|
||||||
- nessie
|
- nessie
|
||||||
|
labels:
|
||||||
|
- "promtail=true"
|
||||||
security_opt:
|
security_opt:
|
||||||
- no-new-privileges:true
|
- no-new-privileges:true
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
@@ -515,6 +549,8 @@ services:
|
|||||||
uv run --no-sync stack bib ingest-mail || true;
|
uv run --no-sync stack bib ingest-mail || true;
|
||||||
sleep $${MAIL_POLL_INTERVAL};
|
sleep $${MAIL_POLL_INTERVAL};
|
||||||
done'
|
done'
|
||||||
|
labels:
|
||||||
|
- "promtail=true"
|
||||||
security_opt:
|
security_opt:
|
||||||
- no-new-privileges:true
|
- no-new-privileges:true
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
@@ -557,6 +593,8 @@ services:
|
|||||||
timeout: 10s
|
timeout: 10s
|
||||||
retries: 5
|
retries: 5
|
||||||
start_period: 60s
|
start_period: 60s
|
||||||
|
labels:
|
||||||
|
- "promtail=true"
|
||||||
security_opt:
|
security_opt:
|
||||||
- no-new-privileges:true
|
- no-new-privileges:true
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
@@ -576,6 +614,8 @@ services:
|
|||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 5
|
retries: 5
|
||||||
start_period: 30s
|
start_period: 30s
|
||||||
|
labels:
|
||||||
|
- "promtail=true"
|
||||||
security_opt:
|
security_opt:
|
||||||
- no-new-privileges:true
|
- no-new-privileges:true
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
@@ -597,6 +637,8 @@ services:
|
|||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 5
|
retries: 5
|
||||||
start_period: 30s
|
start_period: 30s
|
||||||
|
labels:
|
||||||
|
- "promtail=true"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
nvidia-exporter:
|
nvidia-exporter:
|
||||||
@@ -616,6 +658,8 @@ services:
|
|||||||
capabilities: [gpu]
|
capabilities: [gpu]
|
||||||
cap_add:
|
cap_add:
|
||||||
- SYS_ADMIN
|
- SYS_ADMIN
|
||||||
|
labels:
|
||||||
|
- "promtail=true"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
promtail:
|
promtail:
|
||||||
@@ -631,6 +675,8 @@ services:
|
|||||||
- loki
|
- loki
|
||||||
group_add:
|
group_add:
|
||||||
- "${DOCKER_GID:-985}"
|
- "${DOCKER_GID:-985}"
|
||||||
|
labels:
|
||||||
|
- "promtail=true"
|
||||||
security_opt:
|
security_opt:
|
||||||
- no-new-privileges:true
|
- no-new-privileges:true
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
@@ -658,6 +704,8 @@ services:
|
|||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 3
|
retries: 3
|
||||||
start_period: 10s
|
start_period: 10s
|
||||||
|
labels:
|
||||||
|
- "promtail=true"
|
||||||
security_opt:
|
security_opt:
|
||||||
- no-new-privileges:true
|
- no-new-privileges:true
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
@@ -686,6 +734,8 @@ services:
|
|||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 5
|
retries: 5
|
||||||
start_period: 15s
|
start_period: 15s
|
||||||
|
labels:
|
||||||
|
- "promtail=true"
|
||||||
security_opt:
|
security_opt:
|
||||||
- no-new-privileges:true
|
- no-new-privileges:true
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
@@ -724,6 +774,8 @@ services:
|
|||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 5
|
retries: 5
|
||||||
start_period: 30s
|
start_period: 30s
|
||||||
|
labels:
|
||||||
|
- "promtail=true"
|
||||||
security_opt:
|
security_opt:
|
||||||
- no-new-privileges:true
|
- no-new-privileges:true
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
@@ -758,6 +810,8 @@ services:
|
|||||||
- ./infra/oauth2-proxy/auth-handler.conf:/etc/nginx/conf.d/default.conf:ro
|
- ./infra/oauth2-proxy/auth-handler.conf:/etc/nginx/conf.d/default.conf:ro
|
||||||
depends_on:
|
depends_on:
|
||||||
- oauth2-proxy
|
- oauth2-proxy
|
||||||
|
labels:
|
||||||
|
- "promtail=true"
|
||||||
security_opt:
|
security_opt:
|
||||||
- no-new-privileges:true
|
- no-new-privileges:true
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
@@ -799,6 +853,8 @@ services:
|
|||||||
timeout: 5s
|
timeout: 5s
|
||||||
retries: 5
|
retries: 5
|
||||||
start_period: 15s
|
start_period: 15s
|
||||||
|
labels:
|
||||||
|
- "promtail=true"
|
||||||
security_opt:
|
security_opt:
|
||||||
- no-new-privileges:true
|
- no-new-privileges:true
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
@@ -811,6 +867,8 @@ services:
|
|||||||
- gateway
|
- gateway
|
||||||
volumes:
|
volumes:
|
||||||
- ./infra/cloudflared:/home/nonroot/.cloudflared:ro
|
- ./infra/cloudflared:/home/nonroot/.cloudflared:ro
|
||||||
|
labels:
|
||||||
|
- "promtail=true"
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
|
|||||||
@@ -162,3 +162,68 @@ class TestGrafanaDatasources:
|
|||||||
tempo = ds["Tempo"]
|
tempo = ds["Tempo"]
|
||||||
assert tempo["jsonData"]["tracesToLogsV2"]["datasourceUid"] == "loki"
|
assert tempo["jsonData"]["tracesToLogsV2"]["datasourceUid"] == "loki"
|
||||||
assert tempo["jsonData"]["serviceMap"]["datasourceUid"] == "prometheus"
|
assert tempo["jsonData"]["serviceMap"]["datasourceUid"] == "prometheus"
|
||||||
|
|
||||||
|
|
||||||
|
PROMTAIL_LABELED = {
|
||||||
|
"coredns",
|
||||||
|
"traefik",
|
||||||
|
"rustfs",
|
||||||
|
"postgres",
|
||||||
|
"git",
|
||||||
|
"act-runner",
|
||||||
|
"notebooks",
|
||||||
|
"zotero",
|
||||||
|
"webdav",
|
||||||
|
"nessie",
|
||||||
|
"trino",
|
||||||
|
"polaris",
|
||||||
|
"dashboard",
|
||||||
|
"docs",
|
||||||
|
"api",
|
||||||
|
"mail-poller",
|
||||||
|
"auth-handler",
|
||||||
|
"oauth2-proxy",
|
||||||
|
"cloudflared",
|
||||||
|
"loki",
|
||||||
|
"promtail",
|
||||||
|
"tempo",
|
||||||
|
"cadvisor",
|
||||||
|
"otel-collector",
|
||||||
|
"prometheus",
|
||||||
|
"grafana",
|
||||||
|
"nvidia-exporter",
|
||||||
|
}
|
||||||
|
|
||||||
|
PROMTAIL_NOT_LABELED = {"mc", "wire"}
|
||||||
|
|
||||||
|
|
||||||
|
class TestPromtailLabels:
|
||||||
|
def test_eligible_services_have_promtail_label(self):
|
||||||
|
svcs = _services()
|
||||||
|
missing = []
|
||||||
|
for name in PROMTAIL_LABELED:
|
||||||
|
if name not in svcs:
|
||||||
|
missing.append(f" {name}: not in compose")
|
||||||
|
continue
|
||||||
|
labels = svcs[name].get("labels", []) or []
|
||||||
|
if "promtail=true" not in labels:
|
||||||
|
missing.append(f" {name}: missing promtail=true label")
|
||||||
|
assert not missing, "\n".join(missing)
|
||||||
|
|
||||||
|
def test_excluded_services_do_not_have_label(self):
|
||||||
|
svcs = _services()
|
||||||
|
for name in PROMTAIL_NOT_LABELED:
|
||||||
|
if name not in svcs:
|
||||||
|
continue
|
||||||
|
labels = svcs[name].get("labels", []) or []
|
||||||
|
assert "promtail=true" not in labels, f"{name} should NOT be labeled"
|
||||||
|
|
||||||
|
def test_traefik_access_logs_enabled(self):
|
||||||
|
traefik = _services()["traefik"]
|
||||||
|
cmd = traefik.get("command", [])
|
||||||
|
if isinstance(cmd, str):
|
||||||
|
cmd = cmd.split()
|
||||||
|
flat = " ".join(str(x) for x in cmd)
|
||||||
|
assert "--accesslog" in flat or any(
|
||||||
|
"TRAEFIK_ACCESSLOG" in str(e) for e in traefik.get("environment", [])
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user