# docker/logstash/bugsink.conf # ============================================================================ # Logstash Pipeline Configuration for Bugsink Error Tracking # ============================================================================ # This configuration aggregates logs from multiple sources and forwards errors # to Bugsink (Sentry-compatible error tracking) in the dev container. # # Sources: # - PM2 managed logs (/var/log/pm2/*.log) - API, Worker, Vite (ADR-014) # - Pino application logs (/app/logs/*.log) - JSON format (fallback) # - PostgreSQL logs (/var/log/postgresql/*.log) - Including fn_log() output # - NGINX logs (/var/log/nginx/*.log) - Access and error logs # - Redis logs (/var/log/redis/*.log) - Via shared volume (ADR-050) # # Bugsink Projects (3-project architecture): # - Project 1: Backend API (Dev) - Pino/PM2 app errors, PostgreSQL errors # DSN Key: cea01396c56246adb5878fa5ee6b1d22 # - Project 2: Frontend (Dev) - Configured via Sentry SDK in browser # DSN Key: d92663cb73cf4145b677b84029e4b762 # - Project 4: Infrastructure (Dev) - Redis, NGINX, PM2 operational logs # DSN Key: 14e8791da3d347fa98073261b596cab9 # # Routing Logic: # - Backend logs (type: pm2_api, pm2_worker, pino, postgres) -> Project 1 # - Infrastructure logs (type: redis, nginx_error, nginx_5xx) -> Project 4 # - Vite errors (type: pm2_vite with errors) -> Project 4 (build tooling) # # Related Documentation: # - docs/adr/0050-postgresql-function-observability.md # - docs/adr/0015-application-performance-monitoring-and-error-tracking.md # - docs/operations/LOGSTASH-QUICK-REF.md # ============================================================================ input { # ============================================================================ # PM2 Managed Process Logs (ADR-014, ADR-050) # ============================================================================ # PM2 manages all Node.js processes in the dev container, matching production. # Logs are written to /var/log/pm2 for Logstash integration. # # Process logs: # - api-out.log / api-error.log: API server (Pino JSON format) # - worker-out.log / worker-error.log: Background worker (Pino JSON format) # - vite-out.log / vite-error.log: Vite dev server (plain text) # ============================================================================ # PM2 API Server Logs (Pino JSON format) file { path => "/var/log/pm2/api-out.log" codec => json_lines type => "pm2_api" tags => ["app", "backend", "pm2", "api"] start_position => "beginning" sincedb_path => "/var/lib/logstash/sincedb_pm2_api_out" } file { path => "/var/log/pm2/api-error.log" codec => json_lines type => "pm2_api" tags => ["app", "backend", "pm2", "api", "stderr"] start_position => "beginning" sincedb_path => "/var/lib/logstash/sincedb_pm2_api_error" } # PM2 Worker Logs (Pino JSON format) file { path => "/var/log/pm2/worker-out.log" codec => json_lines type => "pm2_worker" tags => ["app", "worker", "pm2"] start_position => "beginning" sincedb_path => "/var/lib/logstash/sincedb_pm2_worker_out" } file { path => "/var/log/pm2/worker-error.log" codec => json_lines type => "pm2_worker" tags => ["app", "worker", "pm2", "stderr"] start_position => "beginning" sincedb_path => "/var/lib/logstash/sincedb_pm2_worker_error" } # PM2 Vite Logs (plain text format) file { path => "/var/log/pm2/vite-out.log" codec => plain type => "pm2_vite" tags => ["app", "frontend", "pm2", "vite"] start_position => "beginning" sincedb_path => "/var/lib/logstash/sincedb_pm2_vite_out" } file { path => "/var/log/pm2/vite-error.log" codec => plain type => "pm2_vite" tags => ["app", "frontend", "pm2", "vite", "stderr"] start_position => "beginning" sincedb_path => "/var/lib/logstash/sincedb_pm2_vite_error" } # ============================================================================ # Pino Application Logs (Fallback Path) # ============================================================================ # JSON-formatted logs from the Node.js application using Pino logger. # Note: Primary logs now go to /var/log/pm2. This is a fallback. # Log levels: 10=trace, 20=debug, 30=info, 40=warn, 50=error, 60=fatal file { path => "/app/logs/*.log" codec => json type => "pino" tags => ["app", "backend"] start_position => "beginning" sincedb_path => "/var/lib/logstash/sincedb_pino" } # ============================================================================ # PostgreSQL Function Logs (ADR-050) # ============================================================================ # Captures PostgreSQL log output including fn_log() structured JSON messages. # PostgreSQL is configured to write logs to /var/log/postgresql/ (shared volume). # Log format: "2026-01-22 14:30:00 PST [5724] postgres@flyer_crawler_dev LOG: message" # Note: Timestamps are in PST (America/Los_Angeles) timezone as configured in compose.dev.yml file { path => "/var/log/postgresql/*.log" type => "postgres" tags => ["postgres", "database"] start_position => "beginning" sincedb_path => "/var/lib/logstash/sincedb_postgres" } # ============================================================================ # NGINX Logs # ============================================================================ # Access logs for request monitoring and error logs for proxy/SSL issues. file { path => "/var/log/nginx/access.log" type => "nginx_access" tags => ["nginx", "access"] start_position => "beginning" sincedb_path => "/var/lib/logstash/sincedb_nginx_access" } file { path => "/var/log/nginx/error.log" type => "nginx_error" tags => ["nginx", "error"] start_position => "beginning" sincedb_path => "/var/lib/logstash/sincedb_nginx_error" } # ============================================================================ # Redis Logs (ADR-050) # ============================================================================ # Redis logs from the shared volume. Redis uses its own log format: # ":