检索调试信息
每个Dgraph
数据节点都在/debug/pprof
端点上公开概要文件,在/debug/vars
端点上公开度量。每个Dgraph数据节点都有自己的分析和度量信息。下面是Dgraph公开的调试信息列表,以及检索这些信息的相应命令。
Metrics 信息
如果想从Dgraph
实例外部收集这些Metrics
信息,则需要在Alpha
启动时传递--expose_trace=true
标志,否则仅可以通过localhost
收集metrics
信息。
curl http://<IP>:<HTTP_PORT>/debug/vars
Metrics
信息也能在/debug/promethus_metrics
通过Promethus
的格式检索。详情查看链接
性能信息
性能信息能够通过GO
内建的工具go tool pprof
查看,可以浏览这篇帖子关于pprof
工具的使用。
每一个Dgraph Alpha
和Dgraph Zero
都会通过HTTP
端口在/debug/pprof/<profile>
暴露性能信息:
go tool pprof http://<IP>:<HTTP_PORT>/debug/pprof/heap
Fetching profile from ...
Saved Profile in ...
上面的命令运行成功之后将输出性能信息的保存位置。
在交互式的pprof shell中,你可以使用像top这样的命令来获取配置文件中top函数的列表,web命令来获取在web浏览器中打开的配置文件的可视化图形,或者list命令来显示覆盖了配置信息的代码列表。
CPU Profile
go tool pprof http://<IP>:<HTTP_PORT>/debug/pprof/profile
内存 Profile
go tool pprof http://<IP>:<HTTP_PORT>/debug/pprof/heap
块 Profile
默认情况下,Dgraph不收集块配置文件。Dgraph必须以——profile_mode=block和——block_rate=
go tool pprof http://<IP>:<HTTP_PORT>/debug/pprof/block