main:重构指标系统并切换为 Redis 方案

变更内容:
- 重构指标系统实现,支持基于 Redis 的多实例指标管理。
- 替换原有的 Pushgateway 和 Redis Exporter 方案。
- 更新 Prometheus 配置,适配新的指标抓取方式。
- 添加 Redis 指标相关配置和告警规则文件。
- 更新 Dockerfile 和 docker-compose 文件,移除多余服务,精简配置。
- 编写 `metrics_unified.py` 模块及单元测试。
- 修复部分代码中的冗余和格式问题。
This commit is contained in:
2026-02-02 13:30:28 +08:00
parent 5921f71756
commit 3254fdc3f0
11 changed files with 1047 additions and 94 deletions

View File

@@ -8,10 +8,7 @@ from typing import Optional
class Settings(BaseSettings):
"""应用配置"""
model_config = ConfigDict(
env_file=".env",
case_sensitive=False
)
model_config = ConfigDict(env_file=".env", case_sensitive=False)
# 应用信息
app_name: str = "FunctionalScaffold"
@@ -42,6 +39,16 @@ class Settings(BaseSettings):
database_url: Optional[str] = None
# Redis 配置
redis_host: str = "localhost"
redis_port: int = 6379
redis_db: int = 0
redis_password: Optional[str] = None
# 指标配置
metrics_config_path: str = "config/metrics.yaml"
metrics_instance_id: Optional[str] = None # 默认使用 hostname
# 全局配置实例
settings = Settings()