Skip to content

指标监控

Lizardcd-server 和 lizardcd-agent 基于 go-zero 框架编写,支持 Prometheus 格式的指标收集。详见 指标监控

开启指标收集

只需要在配置中添加几行配置就可开启,无需修改任何代码,示例如下:

  • lizardcd-server.yaml
yaml
......
Prometheus:
  Host: 0.0.0.0
  Port: 15117
  Path: /metrics
  • lizardcd-agent.yaml
yaml
......
Prometheus:
  Host: 0.0.0.0
  Port: 15017
  Path: /metrics

访问指标监控

sh
$ curl http://127.0.0.1:15117/metrics
# HELP go_gc_duration_seconds A summary of the pause duration of garbage collection cycles.
# TYPE go_gc_duration_seconds summary
go_gc_duration_seconds{quantile="0"} 7.3427e-05
go_gc_duration_seconds{quantile="0.25"} 7.3427e-05
go_gc_duration_seconds{quantile="0.5"} 7.3427e-05
go_gc_duration_seconds{quantile="0.75"} 7.3427e-05
go_gc_duration_seconds{quantile="1"} 7.3427e-05
go_gc_duration_seconds_sum 7.3427e-05
go_gc_duration_seconds_count 1
# HELP go_goroutines Number of goroutines that currently exist.
# TYPE go_goroutines gauge
go_goroutines 12

go-zero 默认的指标如下:

RPC Server

指标名Label说明
rpc_server_requests_duration_msmethodHistogram,耗时统计单位为毫秒
rpc_server_requests_code_totalmethod、codeCounter,错误码统计

RPC Client

指标名Label说明
rpc_client_requests_duration_msmethodHistogram,耗时统计单位为毫秒
rpc_client_requests_code_totalmethod、codeCounter,错误码统计

HTTP Server

指标名Label说明
http_server_requests_duration_mspathHistogram,耗时统计单位为毫秒
http_server_requests_code_totalpath、codeCounter,错误码统计