变更内容: - 重构指标系统实现,支持基于 Redis 的多实例指标管理。 - 替换原有的 Pushgateway 和 Redis Exporter 方案。 - 更新 Prometheus 配置,适配新的指标抓取方式。 - 添加 Redis 指标相关配置和告警规则文件。 - 更新 Dockerfile 和 docker-compose 文件,移除多余服务,精简配置。 - 编写 `metrics_unified.py` 模块及单元测试。 - 修复部分代码中的冗余和格式问题。
79 lines
2.1 KiB
YAML
79 lines
2.1 KiB
YAML
# 指标配置文件
|
|
# 算法成员可以在此添加自定义指标
|
|
|
|
# Redis 连接配置(也可通过环境变量覆盖)
|
|
redis:
|
|
host: ${REDIS_HOST:localhost}
|
|
port: ${REDIS_PORT:6379}
|
|
db: ${REDIS_METRICS_DB:0}
|
|
password: ${REDIS_PASSWORD:}
|
|
|
|
# 全局配置
|
|
global:
|
|
prefix: "functional_scaffold" # 指标名称前缀
|
|
instance_label: true # 是否添加实例标签
|
|
|
|
# 内置指标(框架自动收集)
|
|
builtin_metrics:
|
|
http_requests:
|
|
enabled: true
|
|
name: "http_requests_total"
|
|
type: counter
|
|
description: "HTTP 请求总数"
|
|
labels: [method, endpoint, status]
|
|
|
|
http_latency:
|
|
enabled: true
|
|
name: "http_request_duration_seconds"
|
|
type: histogram
|
|
description: "HTTP 请求延迟"
|
|
labels: [method, endpoint]
|
|
buckets: [0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10]
|
|
|
|
http_in_progress:
|
|
enabled: true
|
|
name: "http_requests_in_progress"
|
|
type: gauge
|
|
description: "当前进行中的 HTTP 请求数"
|
|
labels: []
|
|
|
|
algorithm_executions:
|
|
enabled: true
|
|
name: "algorithm_executions_total"
|
|
type: counter
|
|
description: "算法执行总数"
|
|
labels: [algorithm, status]
|
|
|
|
algorithm_latency:
|
|
enabled: true
|
|
name: "algorithm_execution_duration_seconds"
|
|
type: histogram
|
|
description: "算法执行延迟"
|
|
labels: [algorithm]
|
|
buckets: [0.01, 0.05, 0.1, 0.5, 1, 5, 10, 30, 60]
|
|
|
|
# 自定义指标(算法成员在此添加)
|
|
custom_metrics:
|
|
# 示例:质数判断结果统计
|
|
prime_check_results:
|
|
name: "prime_check_results_total"
|
|
type: counter
|
|
description: "质数判断结果统计"
|
|
labels: [is_prime]
|
|
|
|
# 示例:输入数字大小分布
|
|
input_number_size:
|
|
name: "input_number_size"
|
|
type: histogram
|
|
description: "输入数字大小分布"
|
|
labels: []
|
|
buckets: [10, 100, 1000, 10000, 100000, 1000000]
|
|
|
|
# 添加更多自定义指标...
|
|
# my_custom_metric:
|
|
# name: "my_metric_name"
|
|
# type: counter|gauge|histogram
|
|
# description: "指标描述"
|
|
# labels: [label1, label2]
|
|
# buckets: [...] # 仅 histogram 需要
|