Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions hertzbeat-manager/src/main/resources/define/app-mariadb.yml
Original file line number Diff line number Diff line change
Expand Up @@ -933,3 +933,76 @@ metrics:
queryType: multiRow
sql: select sql_text, start_time, db, query_time from mysql.slow_log;
url: ^_^url^_^

- name: account_expiry
priority: 14
i18n:
zh-CN: 账户过期信息
en-US: Account Expiry Info
ja-JP: アカウント有効期限情報
fields:
- field: user
type: 1
label: true
i18n:
zh-CN: 用户名
en-US: User
ja-JP: ユーザー名
- field: host
type: 1
label: true
i18n:
zh-CN: 主机
en-US: Host
ja-JP: ホスト
- field: password_expired
type: 1
i18n:
zh-CN: 密码是否过期
en-US: Password Expired
ja-JP: パスワード期限切れ
- field: password_lifetime
type: 0
unit: days
i18n:
zh-CN: 密码生命周期(天)
en-US: Password Lifetime (days)
ja-JP: パスワード有効期限(日)
- field: password_last_changed
type: 1
i18n:
zh-CN: 密码最后修改时间
en-US: Password Last Changed
ja-JP: パスワード最終変更
- field: days_until_expiry
type: 0
unit: days
i18n:
zh-CN: 距离过期天数
en-US: Days Until Expiry
ja-JP: 有効期限までの日数
aliasFields:
- User
- Host
- password_expired
- password_lifetime
- password_last_changed
calculates:
- user=User
- host=Host
- password_expired=password_expired
- password_lifetime=password_lifetime
- password_last_changed=password_last_changed
- days_until_expiry=password_lifetime - DATEDIFF(CURDATE(), password_last_changed)
protocol: jdbc
jdbc:
host: ^_^host^_^
port: ^_^port^_^
platform: mariadb
username: ^_^username^_^
password: ^_^password^_^
database: ^_^database^_^
timeout: ^_^timeout^_^
queryType: multiRow
sql: SELECT User, Host, password_expired, IF(password_lifetime IS NULL OR password_lifetime = 0, 0, password_lifetime) as password_lifetime, password_last_changed FROM mysql.user WHERE User != '' ORDER BY password_last_changed ASC;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The current configuration performs redundant field mapping (e.g., user=User) and logic calculation in the application layer. This adds unnecessary overhead to the collector's expression engine.

I suggest moving this logic directly into the SQL statement using aliases and built-in functions. This follows the "calculation push-down" principle, improving efficiency and simplifying the YAML.

url: ^_^url^_^
13 changes: 13 additions & 0 deletions home/docs/help/mariadb.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,16 @@ keywords: [open source monitoring tool, open source database monitoring tool, mo
| innodb_data_writes | none | innodb average number of writes from file per second |
| innodb_data_read | KB | innodb average amount of data read per second |
| innodb_data_written | KB | innodb average amount of data written per second |

#### Metric set:account_expiry

| Metric name | Metric unit | Metric help description |
|-------------------------|-------------|---------------------------------------------------------------------------|
| user | none | Database user account name |
| host | none | Host from which the user can connect |
| password_expired | none | Whether the password has expired (Y/N) |
| password_lifetime | days | Password lifetime in days (0 = never expires) |
| password_last_changed | none | Timestamp when password was last changed |
| days_until_expiry | days | Number of days remaining until password expires (calculated field) |

**Note**: This metric helps monitor database account security by tracking password expiration dates. Configure alerts to notify administrators before accounts expire, ensuring uninterrupted database access and compliance with security policies.
Original file line number Diff line number Diff line change
Expand Up @@ -57,3 +57,16 @@ keywords: [开源监控系统, 开源数据库监控, MariaDB数据库监控]
| innodb_data_writes | 无 | innodb平均每秒从文件中写入的次数 |
| innodb_data_read | KB | innodb平均每秒钟读取的数据量,单位为KB |
| innodb_data_written | KB | innodb平均每秒钟写入的数据量,单位为KB |

#### 指标集合:account_expiry

| 指标名称 | 指标单位 | 指标帮助描述 |
|------------------------|------|------------------------------|
| user | 无 | 数据库用户账户名 |
| host | 无 | 用户可连接的主机 |
| password_expired | 无 | 密码是否已过期 (Y/N) |
| password_lifetime | 天 | 密码生命周期天数 (0 = 永不过期) |
| password_last_changed | 无 | 密码最后修改时间戳 |
| days_until_expiry | 天 | 距离密码过期还有多少天(计算字段) |

**说明**:此指标用于监控数据库账户安全,跟踪密码过期日期。可配置告警规则在账户过期前提前通知管理员,确保数据库访问不中断并符合安全策略要求。