数据采集 采集源配置 PostgreSQL 监控指标采集
PostgreSQL 监控指标采集
简介
采集 PostgreSQL 指标上报到 DataFlux 中,目前它适用于 Postgres 8.1+ 版本。它使用来自内置pg_stat_database
和pg_stat_bgwriter
视图的数据。
前置条件
- 已安装 DataKit(DataKit 安装文档)
配置
进入 DataKit 安装目录下的 conf.d/db 目录,复制 postgresql.conf.sample 并命名为 postgresql.conf。示例如下:
修改目标 PostgreSQL 服务器信息配置:
address = "host=localhost user=postgres sslmode=disable"
也可以通过连接字符串来配置
address = "postgres://[pqgotest[:password]]@localhost[/dbname]\?sslmode=[disable|verify-ca|verify-full]"
所有连接参数都是可选的。如果没有 dbname
参数,驱动程序将 默认使用与用户名相同 的数据库。此 dbname
仅用于实例化以及服务器的连接,并不限制我们尝试获取其指标的数据库。
可使用
ignored_databases = ["postgres", "template0", "template1"]
可显式忽略的数据库列表。如果未指定,则收集所有数据库的指标。不能与databases
一起使用。可使用
databases = ["app_production", "testing"]
获取指定的数据库的指标。如果未指定,则收集所有数据库的指标。不能与ignored_databases
一起使用。
配置好后,重启 DataKit 即可生效。
配置举例:
[[inputs.postgresql]]
address = "host=10.0.0.120 user=test01 port=5432 password=test01 sslmode=disabledbname=test01"
interval = "300s"
[inputs.postgresql.tags]
instance_name='DBA团队自建PostgreSQL实例'
project='SuperCloud'
采集指标
access log 指标
记录的指标取决于您的 postgres 版本。见表:
版本 | 9.2+ | 9.1 | 8.3-9.0 | 8.1-8.2 |
---|---|---|---|---|
datid | √ | √ | √ | √ |
datname | √ | √ | √ | √ |
numbackends | √ | √ | √ | √ |
xact_commit | √ | √ | √ | √ |
xact_rollback | √ | √ | √ | √ |
blks_read | √ | √ | √ | √ |
blks_hit | √ | √ | √ | √ |
tup_returned | √ | √ | √ | - |
tup_fetched | √ | √ | √ | - |
tup_inserted | √ | √ | √ | - |
tup_updated | √ | √ | √ | - |
tup_deleted | √ | √ | √ | - |
conflicts | √ | √ | - | - |
temp_files | √ | - | - | - |
temp_bytes | √ | - | - | - |
deadlocks | √ | - | - | - |
blk_read_time | √ | - | - | - |
blk_write_time | √ | - | - | - |
更多关于这些指标的信息请查阅 PostgreSQL Documentation。
error log 指标
暂无
标签
- 默认标签为host,表示所采集的PostgreSQL数据库的链接地址信息服务器名;
- 建议按照业务情况自定义标签,例如配置文件中[inputs.postgresql.tags]下面自定义标签:hostname,project,datname标签名称都是自定义的。