我下载的postgres_exporter
https://github.com/rnaveiras/postgres_exporter#start-of-content
这个postgres_exporter 是用go写的,我看到的其他几个也是go写的。在目录下,使用go mod 添加依赖(当然要有go语言的环境,如果目录里没有go.mod文件还需要 go mod init )
然后编译go文件,再执行,记住这个监听的端口号(编译后的文件可以放在其他服务器执行)
去 prometheus.yml增加内容,增加一个job_name
然后reload
curl -X POST http://localhost:9090/-/reload/
然后 查看 localhost:9090/targets,可以看到刚刚增加的state是up
这边有个 grafana+prometheus 监控postgresql的文章
https://www.cnblogs.com/ilifeilong/p/10543876.html