使用Prometheus搞定微服务监控
最近对服务进行监控,而当前监控最流行的数据库就是 Prometheus,同时 go-zero 默认接入也是这款数据库。今天就对 go-zero 是如何接入 Prometheus ,以及开发者如何自己定义自己监控指标。 监控接入 go-zero 框架中集成了基于 prometheus 的服务指标监控。但是没有显式打开,需要开发者在 config.yaml 中配置: Prometheus: Host: 127.0.0.1 Port: 9091 Path: /metrics 如果开发者是在本地搭建 Prometheus,需要在 Prometheus 的配置文件 prometheus.yaml 中写入需要收集服务监控信息的配置: - job_name: 'file_ds' static_configs: - targets: ['your-local-ip:9091'] labels: job: activeuser app: activeuser-api env: dev instance: your-local-ip:service-port 因为本地是用 docker 运行的。将 pro...