From 4e88a5aa9c522cc5b13e7d56ebaa5d0d5b1617ff Mon Sep 17 00:00:00 2001 From: Mario Castro Date: Fri, 24 Jul 2020 10:42:48 +0200 Subject: [PATCH] [Metricbeat] Use MySQL Host Parser in Query metricset (#20191) (#20212) (cherry picked from commit 9dc48775f0475124704c95c2b0932cafbbcb27ed) # Conflicts: # metricbeat/module/mysql/_meta/config.epr.yml --- metricbeat/docs/modules/mysql.asciidoc | 6 ++++-- metricbeat/docs/modules/mysql/performance.asciidoc | 1 - metricbeat/docs/modules/mysql/query.asciidoc | 1 - metricbeat/metricbeat.reference.yml | 6 ++++-- metricbeat/module/mysql/_meta/config.reference.yml | 6 ++++-- metricbeat/module/mysql/_meta/config.yml | 4 +++- metricbeat/module/mysql/performance/manifest.yml | 2 +- metricbeat/module/mysql/query/query.go | 3 ++- metricbeat/modules.d/mysql.yml.disabled | 4 +++- x-pack/metricbeat/metricbeat.reference.yml | 6 ++++-- 10 files changed, 25 insertions(+), 14 deletions(-) diff --git a/metricbeat/docs/modules/mysql.asciidoc b/metricbeat/docs/modules/mysql.asciidoc index 21762cbeb669..f762f5c8642e 100644 --- a/metricbeat/docs/modules/mysql.asciidoc +++ b/metricbeat/docs/modules/mysql.asciidoc @@ -58,8 +58,10 @@ in <>. Here is an example configuration: metricbeat.modules: - module: mysql metricsets: - - "status" - # - "galera_status" + - status + # - galera_status + # - performance + # - query period: 10s # Host DSN should be defined as "user:pass@tcp(127.0.0.1:3306)/" diff --git a/metricbeat/docs/modules/mysql/performance.asciidoc b/metricbeat/docs/modules/mysql/performance.asciidoc index e0e47239f21e..d94b12a53fad 100644 --- a/metricbeat/docs/modules/mysql/performance.asciidoc +++ b/metricbeat/docs/modules/mysql/performance.asciidoc @@ -9,7 +9,6 @@ beta[] include::../../../module/mysql/performance/_meta/docs.asciidoc[] -This is a default metricset. If the host module is unconfigured, this metricset is enabled by default. ==== Fields diff --git a/metricbeat/docs/modules/mysql/query.asciidoc b/metricbeat/docs/modules/mysql/query.asciidoc index fd8cdf650f9c..31a8e1638c14 100644 --- a/metricbeat/docs/modules/mysql/query.asciidoc +++ b/metricbeat/docs/modules/mysql/query.asciidoc @@ -9,7 +9,6 @@ beta[] include::../../../module/mysql/query/_meta/docs.asciidoc[] -This is a default metricset. If the host module is unconfigured, this metricset is enabled by default. ==== Fields diff --git a/metricbeat/metricbeat.reference.yml b/metricbeat/metricbeat.reference.yml index 2badf80cefff..92aed4ead8fc 100644 --- a/metricbeat/metricbeat.reference.yml +++ b/metricbeat/metricbeat.reference.yml @@ -647,8 +647,10 @@ metricbeat.modules: #-------------------------------- MySQL Module -------------------------------- - module: mysql metricsets: - - "status" - # - "galera_status" + - status + # - galera_status + # - performance + # - query period: 10s # Host DSN should be defined as "user:pass@tcp(127.0.0.1:3306)/" diff --git a/metricbeat/module/mysql/_meta/config.reference.yml b/metricbeat/module/mysql/_meta/config.reference.yml index 6715260a5e98..03880a5ad6ab 100644 --- a/metricbeat/module/mysql/_meta/config.reference.yml +++ b/metricbeat/module/mysql/_meta/config.reference.yml @@ -1,7 +1,9 @@ - module: mysql metricsets: - - "status" - # - "galera_status" + - status + # - galera_status + # - performance + # - query period: 10s # Host DSN should be defined as "user:pass@tcp(127.0.0.1:3306)/" diff --git a/metricbeat/module/mysql/_meta/config.yml b/metricbeat/module/mysql/_meta/config.yml index 81db7e28eedc..367b32e91736 100644 --- a/metricbeat/module/mysql/_meta/config.yml +++ b/metricbeat/module/mysql/_meta/config.yml @@ -2,6 +2,8 @@ #metricsets: # - status # - galera_status + # - performance + # - query period: 10s # Host DSN should be defined as "user:pass@tcp(127.0.0.1:3306)/" @@ -15,4 +17,4 @@ #username: root # Password of hosts. Empty by default. - #password: secret \ No newline at end of file + #password: secret diff --git a/metricbeat/module/mysql/performance/manifest.yml b/metricbeat/module/mysql/performance/manifest.yml index b88a2694cf7f..51aa01614b54 100644 --- a/metricbeat/module/mysql/performance/manifest.yml +++ b/metricbeat/module/mysql/performance/manifest.yml @@ -1,4 +1,4 @@ -default: true +default: false input: module: mysql metricset: query diff --git a/metricbeat/module/mysql/query/query.go b/metricbeat/module/mysql/query/query.go index 24f09218d479..d7664cc86355 100644 --- a/metricbeat/module/mysql/query/query.go +++ b/metricbeat/module/mysql/query/query.go @@ -32,11 +32,12 @@ import ( "github.com/elastic/beats/v7/libbeat/common/cfgwarn" "github.com/elastic/beats/v7/metricbeat/helper/sql" "github.com/elastic/beats/v7/metricbeat/mb" + "github.com/elastic/beats/v7/metricbeat/module/mysql" ) func init() { mb.Registry.MustAddMetricSet("mysql", "query", New, - mb.DefaultMetricSet(), + mb.WithHostParser(mysql.ParseDSN), ) } diff --git a/metricbeat/modules.d/mysql.yml.disabled b/metricbeat/modules.d/mysql.yml.disabled index 9d30a9d4049e..58d92e8e3c29 100644 --- a/metricbeat/modules.d/mysql.yml.disabled +++ b/metricbeat/modules.d/mysql.yml.disabled @@ -5,6 +5,8 @@ #metricsets: # - status # - galera_status + # - performance + # - query period: 10s # Host DSN should be defined as "user:pass@tcp(127.0.0.1:3306)/" @@ -18,4 +20,4 @@ #username: root # Password of hosts. Empty by default. - #password: secret \ No newline at end of file + #password: secret diff --git a/x-pack/metricbeat/metricbeat.reference.yml b/x-pack/metricbeat/metricbeat.reference.yml index 082cf0845261..91cb2f554824 100644 --- a/x-pack/metricbeat/metricbeat.reference.yml +++ b/x-pack/metricbeat/metricbeat.reference.yml @@ -970,8 +970,10 @@ metricbeat.modules: #-------------------------------- MySQL Module -------------------------------- - module: mysql metricsets: - - "status" - # - "galera_status" + - status + # - galera_status + # - performance + # - query period: 10s # Host DSN should be defined as "user:pass@tcp(127.0.0.1:3306)/"