This is an automated email from the ASF dual-hosted git repository.
tomsun28 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hertzbeat.git
The following commit(s) were added to refs/heads/master by this push:
new 2389db7b3b [feat]:add db account monitoring metrics for postgresql.
(#4131)
2389db7b3b is described below
commit 2389db7b3ba9e040b45298b1b6bdc22c02059e32
Author: wy471x <[email protected]>
AuthorDate: Thu Jul 2 23:44:56 2026 +0800
[feat]:add db account monitoring metrics for postgresql. (#4131)
Co-authored-by: Duansg <[email protected]>
Co-authored-by: Tomsun28 <[email protected]>
---
.../src/main/resources/define/app-postgresql.yml | 96 ++++++++++++++++++++++
home/docs/help/postgresql.md | 18 +++-
.../current/help/postgresql.md | 18 +++-
3 files changed, 126 insertions(+), 6 deletions(-)
diff --git a/hertzbeat-manager/src/main/resources/define/app-postgresql.yml
b/hertzbeat-manager/src/main/resources/define/app-postgresql.yml
index 145d20d531..1af48baa9c 100644
--- a/hertzbeat-manager/src/main/resources/define/app-postgresql.yml
+++ b/hertzbeat-manager/src/main/resources/define/app-postgresql.yml
@@ -1076,3 +1076,99 @@ metrics:
privateKey: ^_^sshPrivateKey^_^
privateKeyPassphrase: ^_^sshPrivateKeyPassphrase^_^
shareConnection: ^_^sshShareConnection^_^
+
+ - name: users
+ i18n:
+ zh-CN: 用户信息
+ en-US: Users
+ ja-JP: ユーザー情報
+ priority: 16
+ fields:
+ - field: usename
+ type: 1
+ label: true
+ i18n:
+ zh-CN: 用户名
+ en-US: User Name
+ ja-JP: ユーザー名
+ - field: usesysid
+ type: 0
+ i18n:
+ zh-CN: 用户ID
+ en-US: User ID
+ ja-JP: ユーザーID
+ - field: usecreatedb
+ type: 1
+ i18n:
+ zh-CN: 创建数据库权限
+ en-US: Create DB Privilege
+ ja-JP: データベース作成権限
+ - field: usesuper
+ type: 1
+ i18n:
+ zh-CN: 超级用户权限
+ en-US: Superuser Privilege
+ ja-JP: スーパーユーザー権限
+ - field: valuntil
+ type: 1
+ i18n:
+ zh-CN: 密码有效期
+ en-US: Password Valid Until
+ ja-JP: パスワード有効期限
+ - field: days_left
+ type: 0
+ i18n:
+ zh-CN: 剩余天数
+ en-US: Days Left
+ ja-JP: 残り日数
+ - field: account_status
+ type: 1
+ i18n:
+ zh-CN: 账号状态
+ en-US: Account Status
+ ja-JP: アカウントのステータス
+ protocol: jdbc
+ jdbc:
+ host: ^_^host^_^
+ port: ^_^port^_^
+ timeout: ^_^timeout^_^
+ platform: postgresql
+ username: ^_^username^_^
+ password: ^_^password^_^
+ database: ^_^database^_^
+ queryType: multiRow
+ sql: |
+ SELECT
+ rolname AS usename,
+ oid AS usesysid,
+ CASE WHEN rolcreatedb THEN 'Y' ELSE 'N' END as usecreatedb,
+ CASE WHEN rolsuper THEN 'Y' ELSE 'N' END as usesuper,
+ rolvaliduntil AS valuntil,
+ CASE
+ WHEN rolvaliduntil IS NULL THEN NULL
+ WHEN rolvaliduntil = 'infinity'::timestamptz THEN NULL
+ WHEN rolvaliduntil = '-infinity'::timestamptz THEN NULL
+ ELSE EXTRACT(DAY FROM (rolvaliduntil - NOW()))::INTEGER
+ END as days_left,
+ CASE
+ WHEN rolvaliduntil IS NULL THEN 'OPEN'
+ WHEN rolvaliduntil = 'infinity'::timestamptz THEN 'OPEN'
+ WHEN rolvaliduntil = '-infinity'::timestamptz THEN 'EXPIRED'
+ WHEN rolvaliduntil < NOW() THEN 'EXPIRED'
+ ELSE 'OPEN'
+ END as account_status
+ FROM pg_roles
+ WHERE rolcanlogin = true
+ ORDER BY days_left ASC NULLS LAST;
+ url: ^_^url^_^
+ sshTunnel:
+ enable: ^_^enableSshTunnel^_^
+ host: ^_^sshHost^_^
+ port: ^_^sshPort^_^
+ timeout: ^_^sshTimeout^_^
+ username: ^_^sshUsername^_^
+ password: ^_^sshPassword^_^
+ privateKey: ^_^sshPrivateKey^_^
+ privateKeyPassphrase: ^_^sshPrivateKeyPassphrase^_^
+ shareConnection: ^_^sshShareConnection^_^
+
diff --git a/home/docs/help/postgresql.md b/home/docs/help/postgresql.md
index aad9939301..02f7615c88 100644
--- a/home/docs/help/postgresql.md
+++ b/home/docs/help/postgresql.md
@@ -1,7 +1,7 @@
---
-id: postgresql
-title: Monitoring:PostgreSQL database monitoring
-sidebar_label: PostgreSQL database
+id: postgresql
+title: Monitoring:PostgreSQL database monitoring
+sidebar_label: PostgreSQL database
keywords: [open source monitoring tool, open source database monitoring tool,
monitoring postgresql database metrics]
---
@@ -53,3 +53,15 @@ keywords: [open source monitoring tool, open source database
monitoring tool, mo
| Metric name | Metric unit | Metric help description |
|-------------|-------------|--------------------------------------|
| running | connections | Number of current client connections |
+
+#### Metric set:users
+
+| Metric name | Metric unit | Metric help description
|
+|-------------------|-------------|------------------------------------------------------------|
+| usename | none | Database user name
|
+| usesysid | none | User system ID
|
+| usecreatedb | none | Whether user can create databases (Y/N)
|
+| usesuper | none | Whether user is a superuser (Y/N)
|
+| valuntil | none | Password expiration time (timestamp)
|
+| days_left | days | Days remaining until password expires
|
+| account_status | none | Account status (OPEN/EXPIRED)
|
diff --git
a/home/i18n/zh-cn/docusaurus-plugin-content-docs/current/help/postgresql.md
b/home/i18n/zh-cn/docusaurus-plugin-content-docs/current/help/postgresql.md
index 6c5746df0e..578c876297 100644
--- a/home/i18n/zh-cn/docusaurus-plugin-content-docs/current/help/postgresql.md
+++ b/home/i18n/zh-cn/docusaurus-plugin-content-docs/current/help/postgresql.md
@@ -1,7 +1,7 @@
---
-id: postgresql
-title: 监控:PostgreSQL数据库监控
-sidebar_label: PostgreSQL数据库
+id: postgresql
+title: 监控:PostgreSQL数据库监控
+sidebar_label: PostgreSQL数据库
keywords: [开源监控系统, 开源数据库监控, PostgreSQL数据库监控]
---
@@ -53,3 +53,15 @@ keywords: [开源监控系统, 开源数据库监控, PostgreSQL数据库监控]
| 指标名称 | 指标单位 | 指标帮助描述 |
|---------|------|----------|
| running | 连接数 | 当前客户端连接数 |
+
+#### 指标集合:users
+
+| 指标名称 | 指标单位 | 指标帮助描述 |
+|----------------|------|----------------------|
+| usename | 无 | 数据库用户名 |
+| usesysid | 无 | 用户系统ID |
+| usecreatedb | 无 | 用户是否可以创建数据库(Y/N) |
+| usesuper | 无 | 用户是否为超级用户(Y/N) |
+| valuntil | 无 | 密码过期时间(时间戳) |
+| days_left | 天 | 密码剩余有效天数 |
+| account_status | 无 | 账号状态(OPEN/EXPIRED) |
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]