command
Version:
v1.0.0
Opens a new window with list of versions in this module.
Published: Jun 20, 2025
License: MIT
Opens a new window with license information.
Imports: 12
Opens a new window with list of imports.
Imported by: 0
Opens a new window with list of known importers.
README
¶
ELK Coordinator 监控配置指南
方法1:直接查看 Prometheus 指标(最简单)
-
确保你的 main 程序正在运行(应该在 :8080
端口提供监控服务)
-
在浏览器中直接访问:
-
你可以看到所有的监控指标,包括:
# Leader 状态
elk_coordinator_leader_is_leader{worker_id="hostname-12345-abcd1234"} 1
# 活跃工作节点数
elk_coordinator_active_workers_total 1
# 已处理任务数
elk_coordinator_tasks_processed_total{worker_id="hostname-12345-abcd1234"} 5
# 任务处理耗时
elk_coordinator_task_processing_duration_seconds_bucket{worker_id="hostname-12345-abcd1234",le="0.1"} 0
elk_coordinator_task_processing_duration_seconds_bucket{worker_id="hostname-12345-abcd1234",le="1"} 0
elk_coordinator_task_processing_duration_seconds_bucket{worker_id="hostname-12345-abcd1234",le="2.5"} 5
# 熔断器状态
elk_coordinator_circuit_breaker_state{worker_id="hostname-12345-abcd1234",breaker_name="process_breaker"} 0
方法2:使用 Grafana Dashboard(推荐)
前提条件
确保 Docker Desktop 已安装并运行:
启动步骤
-
启动 ELK Coordinator 监控程序:
cd /Users/ihewe/GolandProjects/elk_coordinator/examples/monitoring
go run main.go
-
启动 Prometheus 和 Grafana:
cd /Users/ihewe/GolandProjects/elk_coordinator/examples/monitoring
docker-compose up -d
-
访问 Grafana Dashboard:
Grafana 仪表板功能
仪表板包含以下监控面板:
- Leader Status - 显示当前 Leader 状态
- Active Workers - 活跃工作节点数量
- Task Processing Rate - 任务处理速率(每秒)
- Task Processing Duration - 任务处理耗时分布
- Circuit Breaker State - 熔断器状态监控
- Task Error Rate - 任务错误率
监控指标说明
指标名称 |
说明 |
值含义 |
elk_coordinator_leader_is_leader |
Leader 状态 |
1=是Leader, 0=不是Leader |
elk_coordinator_active_workers_total |
活跃工作节点数 |
当前集群中活跃的工作节点数量 |
elk_coordinator_tasks_processed_total |
已处理任务数 |
累计处理的任务数量 |
elk_coordinator_tasks_errors_total |
任务错误数 |
累计发生的任务错误数 |
elk_coordinator_task_processing_duration_seconds |
任务处理耗时 |
任务处理时间分布(直方图) |
elk_coordinator_circuit_breaker_state |
熔断器状态 |
0=关闭, 1=开启, 2=半开 |
elk_coordinator_heartbeat_timestamp |
心跳时间戳 |
最后一次心跳的时间戳 |
方法3:使用 curl 命令查看指标
如果你只想快速查看指标,可以使用 curl:
# 查看所有指标
curl http://localhost:8080/metrics
# 查看特定指标(Leader 状态)
curl http://localhost:8080/metrics | grep elk_coordinator_leader_is_leader
# 查看任务处理指标
curl http://localhost:8080/metrics | grep elk_coordinator_tasks_processed
# 查看熔断器状态
curl http://localhost:8080/metrics | grep elk_coordinator_circuit_breaker_state
故障排除
- 检查 main 程序是否正在运行
- 检查是否有其他程序占用 8080 端口:
lsof -i :8080
2. Docker 相关问题
- 确保 Docker Desktop 已启动
- 如果端口冲突,修改
docker-compose.yml
中的端口映射
3. Grafana 无法连接 Prometheus
清理资源
停止所有服务:
# 停止 Docker 服务
docker-compose down
# 停止 main 程序(Ctrl+C)
Documentation
¶
There is no documentation for this package.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.