categraf postgresql 配置一直报错

Viewed 49

./categraf -test -inputs postgresql

使用 address = "host=127.0.0.1:5430 user=monitor password=monitor sslmode=disable"
报错:2023/07/19 17:08:40 postgresql.go:171: E! failed to execute Query : failed to connect to host=127.0.0.1:5430 user=monitor database=: hostname resolving error (lookup 127.0.0.1:5430: no such host)

使用 postgres://monitor:monitor@127.0.0.1:5430/postgres?sslmode=disable
报错:2023/07/19 17:11:08 metrics_agent.go:217: E! failed to load configuration of plugin: local.postgresql error: toml: line 10 (last key "instances"): expected '.' or '=', but got ':' instead

2 Answers

升级了categraf最新版本
address = "host=127.0.0.1:5430 user=monitor password=monitor sslmode=disable" 改成
address = "host=127.0.0.1 port:5430 user=monitor password=monitor database=postgres sslmode=disable"

也就是增加了
port:5430
database=postgres