diff --git a/docker/.env.example b/docker/.env.example index 3e78aeb4d0f..22554e9db66 100644 --- a/docker/.env.example +++ b/docker/.env.example @@ -85,4 +85,9 @@ IMGPROXY_ENABLE_WEBP_DETECTION=true ############ LOGFLARE_LOGGER_BACKEND_API_KEY=your-super-secret-and-long-logflare-key +# Change vector.toml sinks.logflare to reflect this change LOGFLARE_HTTP_PORT=4001 +LOGFLARE_API_KEY=your-super-secret-and-long-logflare-key +# Change vector.toml sources.docker_syslog to reflect this change +VECTOR_PORT=9000 +VECTOR_API_PORT=9001 \ No newline at end of file diff --git a/docker/docker-compose.yml b/docker/docker-compose.yml index 51f3beef7a6..a758ed798ab 100644 --- a/docker/docker-compose.yml +++ b/docker/docker-compose.yml @@ -11,6 +11,14 @@ services: container_name: supabase-studio image: supabase/studio:20230216-e731b77 restart: unless-stopped + logging: + driver: syslog + options: + syslog-address: "tcp://localhost:${VECTOR_PORT}" + tag: studio + depends_on: + logs: + condition: service_healthy healthcheck: test: [ @@ -40,6 +48,14 @@ services: container_name: supabase-kong image: kong:2.8.1 restart: unless-stopped + logging: + driver: syslog + options: + syslog-address: "tcp://localhost:${VECTOR_PORT}" + tag: kong + depends_on: + logs: + condition: service_healthy ports: - ${KONG_HTTP_PORT}:8000/tcp - ${KONG_HTTPS_PORT}:8443/tcp @@ -62,6 +78,13 @@ services: db: # Disable this if you are using an external Postgres database condition: service_healthy + logs: + condition: service_healthy + logging: + driver: syslog + options: + syslog-address: "tcp://localhost:${VECTOR_PORT}" + tag: auth healthcheck: test: [ @@ -120,7 +143,14 @@ services: db: # Disable this if you are using an external Postgres database condition: service_healthy + logs: + condition: service_healthy restart: unless-stopped + logging: + driver: syslog + options: + syslog-address: "tcp://localhost:${VECTOR_PORT}" + tag: rest environment: PGRST_DB_URI: postgres://authenticator:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB} PGRST_DB_SCHEMAS: ${PGRST_DB_SCHEMAS} @@ -135,6 +165,13 @@ services: db: # Disable this if you are using an external Postgres database condition: service_healthy + logs: + condition: service_healthy + logging: + driver: syslog + options: + syslog-address: "tcp://localhost:${VECTOR_PORT}" + tag: realtime healthcheck: test: [ @@ -168,7 +205,7 @@ services: logs: container_name: supabase-logs - image: supabase/logflare:1.0.0 + image: supabase/logflare:latest healthcheck: test: [ @@ -188,6 +225,8 @@ services: db: # Disable this if you are using an external Postgres database condition: service_healthy + vector: + condition: service_healthy ports: - ${LOGFLARE_HTTP_PORT}:4000/tcp volumes: @@ -205,6 +244,7 @@ services: DB_PASSWORD: ${POSTGRES_PASSWORD} DB_NAME: ${POSTGRES_DB} LOGFLARE_SINGLE_TENANT: true + LOGFLARE_API_KEY: ${LOGFLARE_API_KEY} GOOGLE_PROJECT_ID: logflare-dev-238720 GOOGLE_PROJECT_NUMBER: 1023172132421 @@ -219,6 +259,13 @@ services: condition: service_started imgproxy: condition: service_started + logs: + condition: service_healthy + logging: + driver: syslog + options: + syslog-address: "tcp://localhost:${VECTOR_PORT}" + tag: storage healthcheck: test: [ @@ -274,6 +321,14 @@ services: db: # Disable this if you are using an external Postgres database condition: service_healthy + logs: + condition: service_healthy + + logging: + driver: syslog + options: + syslog-address: "tcp://localhost:${VECTOR_PORT}" + tag: meta restart: unless-stopped environment: PG_META_PORT: 8080 @@ -287,11 +342,19 @@ services: db: container_name: supabase-db image: supabase/postgres:15.1.0.54-rc0 + logging: + driver: syslog + options: + syslog-address: "tcp://localhost:${VECTOR_PORT}" + tag: db healthcheck: test: pg_isready -U postgres -h localhost interval: 5s timeout: 5s retries: 10 + depends_on: + vector: + condition: service_healthy command: - postgres - -c @@ -318,3 +381,26 @@ services: - ./volumes/db/roles.sql:/docker-entrypoint-initdb.d/init-scripts/99-roles.sql:Z # PGDATA directory is persisted between restarts - ./volumes/db/data:/var/lib/postgresql/data:Z + vector: + container_name: supabase-vector + image: timberio/vector:0.28.1-alpine + healthcheck: + test: + [ + + "CMD", + "wget", + "--no-verbose", + "--tries=1", + "--spider", + "http://localhost:9001/health" + ] + timeout: 5s + interval: 5s + retries: 3 + + ports: + - ${VECTOR_PORT}:${VECTOR_PORT} + - ${VECTOR_API_PORT}:${VECTOR_API_PORT} + volumes: + - $PWD/vector.toml:/etc/vector/vector.toml:ro diff --git a/docker/vector.toml b/docker/vector.toml new file mode 100644 index 00000000000..967f8160ec2 --- /dev/null +++ b/docker/vector.toml @@ -0,0 +1,80 @@ +[api] +enabled = true +address = "0.0.0.0:9001" + +[sources.docker_syslog] +type = "syslog" +address = "0.0.0.0:9000" +mode = "tcp" +path = "/tmp/socket" + +[transforms.router] +type = "route" +inputs = [ "docker_syslog" ] + [transforms.router.route] + studio = '.appname == "studio"' + kong = '.appname == "kong"' + auth = '.appname == "auth"' + rest = '.appname == "rest"' + realtime = '.appname == "realtime"' + storage = '.appname == "storage"' + imgproxy = '.appname == "imgproxy"' + meta = '.appname == "meta"' + db = '.appname == "db"' + +[sinks.logflare_auth] +type = "http" +inputs = [ "router.auth" ] +encoding.codec = "json" +method = "post" +uri = "http://logs:4000/api/logs?source_name=gotrue.logs.prod&api_key=gd9tDpgiCVJe" + +[sinks.logflare_realtime] +type = "http" +inputs = [ "router.realtime" ] +encoding.codec = "json" +method = "post" +uri = "http://logs:4000/api/logs?source_name=realtime.logs.prod&api_key=gd9tDpgiCVJe" + +[sinks.studio] +inputs = ["router.studio"] +target = "stdout" +type = "console" +encoding.codec = "json" + +[sinks.kong] +inputs = ["router.kong"] +target = "stdout" +type = "console" +encoding.codec = "json" + +[sinks.rest] +inputs = ["router.rest"] +target = "stdout" +type = "console" +encoding.codec = "json" + +[sinks.storage] +inputs = ["router.storage"] +target = "stdout" +type = "console" +encoding.codec = "json" + +[sinks.imgproxy] +inputs = ["router.imgproxy"] +target = "stdout" +type = "console" +encoding.codec = "json" + +[sinks.meta] +inputs = ["router.meta"] +target = "stdout" +type = "console" +encoding.codec = "json" + +[sinks.db] +inputs = ["router.db"] +target = "stdout" +type = "console" +encoding.codec = "json" +