zqr10159 commented on code in PR #4032:
URL: https://github.com/apache/hertzbeat/pull/4032#discussion_r2845416057
##########
hertzbeat-manager/src/main/resources/define/app-mariadb.yml:
##########
@@ -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;
Review Comment:
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.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]