feat: support ClickHouse log database (#5663)
* feat: support ClickHouse log database * feat(log): optimize log deletion process for ClickHouse
This commit is contained in:
@@ -28,6 +28,9 @@ services:
|
||||
environment:
|
||||
- SQL_DSN=postgresql://root:123456@postgres:5432/new-api # ⚠️ IMPORTANT: Change the password in production!
|
||||
# - SQL_DSN=root:123456@tcp(mysql:3306)/new-api # Point to the mysql service, uncomment if using MySQL
|
||||
# - LOG_SQL_DSN=postgresql://root:123456@postgres:5432/new-api-log # OPTIONAL: If you want a separate database for logging, uncomment and set this
|
||||
# - LOG_SQL_DSN=clickhouse://default:123456@clickhouse:9000/new_api_logs # OPTIONAL: Use ClickHouse for logs only; also uncomment clickhouse in depends_on and the clickhouse service below
|
||||
# - LOG_SQL_CLICKHOUSE_TTL_DAYS=0 # OPTIONAL: ClickHouse log retention days. Unset or 0 disables automatic deletion; set to e.g. 30 to keep 30 days
|
||||
- REDIS_CONN_STRING=redis://:123456@redis:6379 # ⚠️ IMPORTANT: Change the password in production!
|
||||
- TZ=Asia/Shanghai
|
||||
- ERROR_LOG_ENABLED=true # 是否启用错误日志记录 (Whether to enable error log recording)
|
||||
@@ -45,6 +48,7 @@ services:
|
||||
- redis
|
||||
- postgres
|
||||
# - mysql # Uncomment if using MySQL
|
||||
# - clickhouse # Uncomment if using ClickHouse for LOG_SQL_DSN
|
||||
networks:
|
||||
- new-api-network
|
||||
healthcheck:
|
||||
@@ -90,9 +94,27 @@ services:
|
||||
# ports:
|
||||
# - "3306:3306" # Uncomment if you need to access MySQL from outside Docker
|
||||
|
||||
# clickhouse:
|
||||
# image: clickhouse/clickhouse-server:24.8
|
||||
# container_name: clickhouse
|
||||
# restart: always
|
||||
# environment:
|
||||
# CLICKHOUSE_DB: new_api_logs
|
||||
# CLICKHOUSE_USER: default
|
||||
# CLICKHOUSE_PASSWORD: 123456 # ⚠️ IMPORTANT: Change this password in production!
|
||||
# CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT: 1
|
||||
# volumes:
|
||||
# - clickhouse_data:/var/lib/clickhouse
|
||||
# networks:
|
||||
# - new-api-network
|
||||
# ports:
|
||||
# - "8123:8123" # HTTP interface, uncomment if you need external access
|
||||
# - "9000:9000" # Native interface used by the LOG_SQL_DSN example above
|
||||
|
||||
volumes:
|
||||
pg_data:
|
||||
# mysql_data:
|
||||
# clickhouse_data:
|
||||
|
||||
networks:
|
||||
new-api-network:
|
||||
|
||||
Reference in New Issue
Block a user