问题描述
我无法使用MetricBeat从RHEL 7中的Postgresql获取指标
Postgres版本11
MetricBeat 7.8版
module / wrapper.go:“ 259”在获取指标数据时出现错误...“ postgres”
我们是否需要提供缺少的任何权限或配置
下面是Postgres模块的配置
- module: postgresql
metricsets:
- database
- bgwriter
- activity
period: 10s
hosts: ["postgres://localhost:5432?sslmode=disable"]
username: postgres
password: ********
详细日志
Aug 13 11:04:01 HOSTNAME metricbeat[94021]: 2020-08-13T11:04:01.647+0530 INFO module/wrapper.go:259 Error fetching data for metricset postgresql.activity: error in QueryStats: Failed to obtain a connection with the database: pq: Ident authentication Failed for user "postgres"
Aug 13 11:04:01 HOSTNAME metricbeat[94021]: 2020-08-13T11:04:01.667+0530 INFO module/wrapper.go:259 Error fetching data for metricset postgresql.bgwriter: error in QueryStats: Failed to obtain a connection with the database: pq: Ident authentication Failed for user "postgres"
Aug 13 11:04:01 HOSTNAME metricbeat[94021]: 2020-08-13T11:04:01.668+0530 INFO module/wrapper.go:259 Error fetching data for metricset postgresql.database: error in QueryStats: Failed to obtain a connection with the database: pq: Ident authentication Failed for user "postgres"
Aug 13 11:04:11 HOSTNAME metricbeat[94021]: 2020-08-13T11:04:11.648+0530 INFO module/wrapper.go:259 Error fetching data for metricset postgresql.activity: error in QueryStats: Failed to obtain a connection with the database: pq: Ident authentication Failed for user "postgres"
Aug 13 11:04:11 HOSTNAME metricbeat[94021]: 2020-08-13T11:04:11.667+0530 INFO module/wrapper.go:259 Error fetching data for metricset postgresql.bgwriter: error in QueryStats: Failed to obtain a connection with the database: pq: Ident authentication Failed for user "postgres"
Aug 13 11:04:11 HOSTNAME metricbeat[94021]: 2020-08-13T11:04:11.668+0530 INFO module/wrapper.go:259 Error fetching data for metricset postgresql.database: error in QueryStats: Failed to obtain a connection with the database: pq: Ident authentication Failed for user "postgres"
Aug 13 11:04:19 HOSTNAME metricbeat[94021]: 2020-08-13T11:04:19.936+0530 INFO [monitoring] log/log.go:145 Non-zero metrics in the last 30s {"monitoring": {"metrics": {"beat":{"cpu":{"system":{"ticks":84510,"time":{"ms":844}},"total":{"ticks":150820,"time":{"ms":1498},"value":150820},"user":{"ticks":66310,"time":{"ms":654}}},"handles":{"limit":{"hard":4096,"soft":1024},"open":28},"info":{"ephemeral_id":"62200651-b30e-4b7f-8048-04f9fbb57055","uptime":{"ms":3270201}},"memstats":{"gc_next":23756848,"memory_alloc":22309400,"memory_total":10172710312,"RSS":4096},"runtime":{"goroutines":163}},"libbeat":{"config":{"module":{"running":0}},"output":{"events":{"acked":111,"batches":6,"total":111}},"pipeline":{"clients":22,"events":{"active":0,"published":111,"total":111},"queue":{"acked":111}}},"metricbeat":{"docker":{"container":{"events":6,"success":6},"cpu":{"events":6,"diskio":{"events":6,"image":{"events":6,"info":{"events":3,"success":3},"memory":{"events":6,"network":{"events":6,"success":6}},"postgresql":{"activity":{"events":3,"failures":3},"bgwriter":{"events":3,"database":{"events":3,"failures":3}},"system":{"cpu":{"events":3,"load":{"events":3,"memory":{"events":3,"network":{"events":21,"success":21},"process":{"events":27,"success":27},"process_summary":{"events":3,"socket_summary":{"events":3,"success":3}}},"system":{"load":{"1":0.06,"15":0.06,"5":0.08,"norm":{"1":0.015,"15":0.015,"5":0.02}}}}}}
Aug 13 11:04:21 HOSTNAME metricbeat[94021]: 2020-08-13T11:04:21.647+0530 INFO module/wrapper.go:259 Error fetching data for metricset postgresql.activity: error in QueryStats: Failed to obtain a connection with the database: pq: Ident authentication Failed for user "postgres"
Aug 13 11:04:21 HOSTNAME metricbeat[94021]: 2020-08-13T11:04:21.667+0530 INFO module/wrapper.go:259 Error fetching data for metricset postgresql.database: error in QueryStats: Failed to obtain a connection with the database: pq: Ident authentication Failed for user "postgres"
Aug 13 11:04:21 HOSTNAME metricbeat[94021]: 2020-08-13T11:04:21.669+0530 INFO module/wrapper.go:259 Error fetching data for metricset postgresql.bgwriter: error in QueryStats: Failed to obtain a connection with the database: pq: Ident authentication Failed for user "postgres"
有人可以帮我吗
解决方法
尝试使用此主机连接字符串格式进行连接
[postgres://] [user:pass @] host [:port] [?options]
来源:https://www.elastic.co/guide/en/beats/metricbeat/current/metricbeat-module-postgresql.html