fix: silence loud paths + add dozzle for logs

This commit is contained in:
2026-03-15 17:29:01 +01:00
parent d1b736fa3b
commit e8e8217bf5
3 changed files with 41 additions and 15 deletions

View File

@@ -26,6 +26,10 @@ R2_SECRET_ACCESS_KEY="" # R2 API token Secre
R2_BUCKET="vash-esports-images" # Bucket name, e.g. vash-esports-images
R2_PUBLIC_URL="https://cdn.esports.vash.software" # Public URL for the bucket, e.g. https://cdn.esports.vash.software
# Dozzle log viewer (https://dozzle.dev)
DOZZLE_USERNAME="admin"
DOZZLE_PASSWORD="" # Password for the Dozzle web UI
# Sentry error tracking (https://sentry.io)
PUBLIC_SENTRY_DSN="" # DSN is write-only, safe to expose client-side
SENTRY_AUTH_TOKEN="" # Only needed in CI for source map uploads

View File

@@ -85,6 +85,18 @@ services:
retries: 5
start_period: 30s
dozzle:
image: amir20/dozzle:latest
restart: unless-stopped
ports:
- '127.0.0.1:8080:8080' # Proxy via nginx at e.g. logs.vash.software
volumes:
- /var/run/docker.sock:/var/run/docker.sock:ro
environment:
DOZZLE_AUTH_PROVIDER: simple
DOZZLE_USERNAME: ${DOZZLE_USERNAME:-admin}
DOZZLE_PASSWORD: ${DOZZLE_PASSWORD}
volumes:
pgdata:
umamidata:

View File

@@ -39,6 +39,9 @@ if (!building) {
}
// ── Request logging middleware ──
// Paths that are too noisy to log every time (healthchecks, polling)
const SILENT_PATHS = new Set(['/api/health', '/api/queue']);
const handleRequestLogging: Handle = async ({ event, resolve }) => {
const requestId = crypto.randomUUID();
const start = performance.now();
@@ -48,26 +51,33 @@ const handleRequestLogging: Handle = async ({ event, resolve }) => {
const response = await resolve(event);
const duration = Math.round(performance.now() - start);
const userId = event.locals.user?.id;
const path = event.url.pathname;
const status = response.status;
// Always count metrics, but only log interesting requests
metrics.requestCount++;
metrics.totalResponseTime += duration;
const isSilent = SILENT_PATHS.has(path) && status < 400;
if (!isSilent) {
const userId = event.locals.user?.id;
log.http.info(
{
requestId,
method: event.request.method,
path: event.url.pathname,
status: response.status,
path,
status,
duration,
userId: userId ?? null,
ip: event.getClientAddress()
},
`${event.request.method} ${event.url.pathname} ${response.status} ${duration}ms`
`${event.request.method} ${path} ${status} ${duration}ms`
);
metrics.requestCount++;
metrics.totalResponseTime += duration;
}
if (duration > 1000) {
log.http.warn({ requestId, path: event.url.pathname, duration }, 'Slow request');
log.http.warn({ requestId, path, duration }, 'Slow request');
metrics.slowRequests++;
}