From fbb8022d95658dcc63302b22acae2cf07266c344 Mon Sep 17 00:00:00 2001 From: Greg Mascherino Date: Mon, 15 Jun 2020 16:12:16 -0600 Subject: [PATCH 1/2] Add tls.insecure-skip-verify flag to README.md Signed-off-by: Greg Mascherino --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 203bb1b9..4ea602f1 100644 --- a/README.md +++ b/README.md @@ -106,6 +106,7 @@ config.my-cnf | Path to .my.cnf file to read MySQL log.level | Logging verbosity (default: info) exporter.lock_wait_timeout | Set a lock_wait_timeout (in seconds) on the connection to avoid long metadata locking. (default: 2) exporter.log_slow_filter | Add a log_slow_filter to avoid slow query logging of scrapes. NOTE: Not supported by Oracle MySQL. +tls.insecure-skip-verify | Ignore tls verification errors. web.config.file | Path to a [web configuration file](#tls-and-basic-authentication) web.listen-address | Address to listen on for web interface and telemetry. web.telemetry-path | Path under which to expose metrics. From 047fd973586d631ef9e5ba3bc3b81bccba42644e Mon Sep 17 00:00:00 2001 From: Ali Orouji Date: Tue, 15 Feb 2022 16:31:36 +0100 Subject: [PATCH 2/2] set type of mysql_global_status_threads_* to gauge Signed-off-by: Ali Orouji --- collector/global_status.go | 11 ++++++++++- collector/global_status_test.go | 8 ++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/collector/global_status.go b/collector/global_status.go index 21920a71..86058543 100644 --- a/collector/global_status.go +++ b/collector/global_status.go @@ -34,7 +34,7 @@ const ( ) // Regexp to match various groups of status vars. -var globalStatusRE = regexp.MustCompile(`^(com|handler|connection_errors|innodb_buffer_pool_pages|innodb_rows|performance_schema)_(.*)$`) +var globalStatusRE = regexp.MustCompile(`^(com|handler|connection_errors|innodb_buffer_pool_pages|innodb_rows|performance_schema|threads)_(.*)$`) // Metric descriptors. var ( @@ -78,6 +78,11 @@ var ( "Total number of MySQL instrumentations that could not be loaded or created due to memory constraints.", []string{"instrumentation"}, nil, ) + globalThreadsDesc = prometheus.NewDesc( + prometheus.BuildFQName(namespace, globalStatus, "threads"), + "MySQL threads in each state.", + []string{"state"}, nil, + ) ) // ScrapeGlobalStatus collects from `SHOW GLOBAL STATUS`. @@ -168,6 +173,10 @@ func (ScrapeGlobalStatus) Scrape(ctx context.Context, db *sql.DB, ch chan<- prom ch <- prometheus.MustNewConstMetric( globalPerformanceSchemaLostDesc, prometheus.CounterValue, floatVal, match[2], ) + case "threads": + ch <- prometheus.MustNewConstMetric( + globalThreadsDesc, prometheus.GaugeValue, floatVal, match[2], + ) } } else if _, ok := textItems[key]; ok { textItems[key] = string(val) diff --git a/collector/global_status_test.go b/collector/global_status_test.go index 14456c91..e78f3492 100644 --- a/collector/global_status_test.go +++ b/collector/global_status_test.go @@ -50,6 +50,10 @@ func TestScrapeGlobalStatus(t *testing.T) { AddRow("Innodb_buffer_pool_pages_made_young", "15"). AddRow("Innodb_rows_read", "8"). AddRow("Performance_schema_users_lost", "9"). + AddRow("Threads_cached", "7"). + AddRow("Threads_connected", "18"). + AddRow("Threads_created", "25"). + AddRow("Threads_running", "1"). AddRow("Slave_running", "OFF"). AddRow("Ssl_version", ""). AddRow("Uptime", "10"). @@ -87,6 +91,10 @@ func TestScrapeGlobalStatus(t *testing.T) { {labels: labelMap{"operation": "made_young"}, value: 15, metricType: dto.MetricType_COUNTER}, {labels: labelMap{"operation": "read"}, value: 8, metricType: dto.MetricType_COUNTER}, {labels: labelMap{"instrumentation": "users_lost"}, value: 9, metricType: dto.MetricType_COUNTER}, + {labels: labelMap{"state": "cached"}, value: 7, metricType: dto.MetricType_GAUGE}, + {labels: labelMap{"state": "connected"}, value: 18, metricType: dto.MetricType_GAUGE}, + {labels: labelMap{"state": "created"}, value: 25, metricType: dto.MetricType_GAUGE}, + {labels: labelMap{"state": "running"}, value: 1, metricType: dto.MetricType_GAUGE}, {labels: labelMap{}, value: 0, metricType: dto.MetricType_UNTYPED}, {labels: labelMap{}, value: 10, metricType: dto.MetricType_UNTYPED}, {labels: labelMap{}, value: 11, metricType: dto.MetricType_UNTYPED},