From fba1021b4058dbc69949db6a641c4a61e60311e5 Mon Sep 17 00:00:00 2001 From: Yury Vidineev Date: Thu, 8 Dec 2022 14:00:21 -0800 Subject: [PATCH] add scrape of wsrep_start_position variable Signed-off-by: Yury Vidineev --- collector/global_variables.go | 5 +++-- collector/global_variables_test.go | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/collector/global_variables.go b/collector/global_variables.go index b2717fb9..33dc58e8 100644 --- a/collector/global_variables.go +++ b/collector/global_variables.go @@ -152,6 +152,7 @@ func (ScrapeGlobalVariables) Scrape(ctx context.Context, db *sql.DB, ch chan<- p "version": "", "version_comment": "", "wsrep_cluster_name": "", + "wsrep_start_position": "", "wsrep_provider_options": "", "tx_isolation": "", "transaction_isolation": "", @@ -192,8 +193,8 @@ func (ScrapeGlobalVariables) Scrape(ctx context.Context, db *sql.DB, ch chan<- p if textItems["wsrep_cluster_name"] != "" { ch <- prometheus.MustNewConstMetric( prometheus.NewDesc(prometheus.BuildFQName(namespace, "galera", "variables_info"), "PXC/Galera variables information.", - []string{"wsrep_cluster_name"}, nil), - prometheus.GaugeValue, 1, textItems["wsrep_cluster_name"], + []string{"wsrep_cluster_name", "wsrep_start_position"}, nil), + prometheus.GaugeValue, 1, textItems["wsrep_cluster_name"], textItems["wsrep_start_position"], ) } diff --git a/collector/global_variables_test.go b/collector/global_variables_test.go index 4f0ab36f..20904c67 100644 --- a/collector/global_variables_test.go +++ b/collector/global_variables_test.go @@ -47,6 +47,7 @@ func TestScrapeGlobalVariables(t *testing.T) { AddRow("version", "5.6.30-76.3-56"). AddRow("version_comment", "Percona XtraDB Cluster..."). AddRow("wsrep_cluster_name", "supercluster"). + AddRow("wsrep_start_position", "00000000-0000-0000-0000-00000000000000:-1"). AddRow("wsrep_provider_options", "base_dir = /var/lib/mysql/; base_host = 10.91.142.82; base_port = 4567; cert.log_conflicts = no; debug = no; evs.auto_evict = 0; evs.causal_keepalive_period = PT1S; evs.debug_log_mask = 0x1; evs.delay_margin = PT1S; evs.delayed_keep_period = PT30S; evs.inactive_check_period = PT0.5S; evs.inactive_timeout = PT15S; evs.info_log_mask = 0; evs.install_timeout = PT7.5S; evs.join_retrans_period = PT1S; evs.keepalive_period = PT1S; evs.max_install_timeouts = 3; evs.send_window = 4; evs.stats_report_period = PT1M; evs.suspect_timeout = PT5S; evs.use_aggregate = true; evs.user_send_window = 2; evs.version = 0; evs.view_forget_timeout = P1D; gcache.dir = /var/lib/mysql/; gcache.keep_pages_count = 0; gcache.keep_pages_size = 0; gcache.mem_size = 0; gcache.name = /var/lib/mysql//galera.cache; gcache.page_size = 128M; gcache.size = 128M; gcomm.thread_prio = ; gcs.fc_debug = 0; gcs.fc_factor = 1.0; gcs.fc_limit = 16; gcs.fc_master_slave = no; gcs.max_packet_size = 64500; gcs.max_throttle = 0.25; gcs.recv_q_hard_limit = 9223372036854775807; gcs.recv_q_soft_limit = 0.25; gcs.sync_donor = no; gmcast.listen_addr = tcp://0.0.0.0:4567; gmcast.mcast_addr = ; gmcast.mcast_ttl = 1; gmcast.peer_timeout = PT3S; gmcast.segment = 0; gmcast.time_wait = PT5S; gmcast.version = 0; ist.recv_addr = 10.91.142.82; pc.announce_timeout = PT3S; pc.checksum = false; pc.ignore_quorum = false; pc.ignore_sb = false; pc.linger = PT20S; pc.npvo = false; pc.recovery = true; pc.version = 0; pc.wait_prim = true; pc.wait_prim_timeout = P30S; pc.weight = 1; protonet.backend = asio; protonet.version = 0; repl.causal_read_timeout = PT30S; repl.commit_order = 3; repl.key_format = FLAT8; repl.max_ws_size = 2147483647; repl.proto_max = 7; socket.checksum = 2; socket.recv_buf_size = 212992;") mock.ExpectQuery(globalVariablesQuery).WillReturnRows(rows) @@ -67,7 +68,7 @@ func TestScrapeGlobalVariables(t *testing.T) { {labels: labelMap{}, value: 1, metricType: dto.MetricType_GAUGE}, {labels: labelMap{}, value: 2, metricType: dto.MetricType_GAUGE}, {labels: labelMap{"innodb_version": "5.6.30-76.3", "version": "5.6.30-76.3-56", "version_comment": "Percona XtraDB Cluster..."}, value: 1, metricType: dto.MetricType_GAUGE}, - {labels: labelMap{"wsrep_cluster_name": "supercluster"}, value: 1, metricType: dto.MetricType_GAUGE}, + {labels: labelMap{"wsrep_cluster_name": "supercluster", "wsrep_start_position": "00000000-0000-0000-0000-00000000000000:-1"}, value: 1, metricType: dto.MetricType_GAUGE}, {labels: labelMap{}, value: 134217728, metricType: dto.MetricType_GAUGE}, {labels: labelMap{"level": "REPEATABLE-READ"}, value: 1, metricType: dto.MetricType_GAUGE}, }