Feature/mariadb galera monitoring #24125
Draft
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What this PR does / why we need it:
Feature: MariaDB Galera Cluster Status Monitoring
This PR addresses issue #20755 by adding support for monitoring MariaDB Galera cluster status. It registers the standard Galera status variables as metrics in the Cloudpods monitoring system, enabling alerting and dashboards for cluster health. It also updates the Hostman service to support configuring Telegraf to collect these metrics from MySQL/MariaDB instances.
Implementation Details
1.
pkg/monitor/dbinit/measurements/mysql.go:Registered standard Galera status variables to
mysqlmeasurement definition:{ "wsrep_cluster_size", "wsrep_cluster_size", monitor.METRIC_UNIT_COUNT, }, { "wsrep_cluster_status", "wsrep_cluster_status", monitor.METRIC_UNIT_NULL, }, { "wsrep_ready", "wsrep_ready", monitor.METRIC_UNIT_NULL, }, { "wsrep_connected", "wsrep_connected", monitor.METRIC_UNIT_NULL, },2.
pkg/monitor/dbinit/measurements/metrics.csv:3.
pkg/hostman/options/options.go:TelegrafMysqlServersoption toSHostBaseOptionsto allow configuring MySQL connection strings for Telegraf.4.
pkg/hostman/hostinfo/hostinfo.go:OnCatalogChangedto readTelegrafMysqlServersand configure themysqlinput for Telegraf, specifically requestingwsrepstring fields.5.
pkg/hostman/system_service/telegraf.go:[[inputs.mysql]]configuration block intelegraf.conf.Does this PR need to be backport to the previous release branch?:
NONE
Verification
1.
pkg/monitor/dbinit/measurements/mysql_test.go:Added unit test to verify metric presence:
Automated Tests:
Run the verification test:
go test -v -run TestMysqlMetrics ./pkg/monitor/dbinit/measurements/Output:
2. Hostman Telegraf Configuration Verification:
Verified that
telegraf.confis correctly generated with[[inputs.mysql]]block whenTelegrafMysqlServersis configured.