From 189b73df2b9e5fb31fa362ccaf2457e4b73628ac Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Wed, 9 Sep 2020 08:48:37 +0200 Subject: [PATCH] Sanitize event.host in Metricbeat (#21022) * Sanitize event.host * Update CHANGELOG * Fix: enable host parser (cherry picked from commit 3ecf7e6cbfa0284cf9740d584f4647dcad871412) --- CHANGELOG.next.asciidoc | 1 + metricbeat/mb/module/wrapper.go | 2 +- .../oracle/performance/_meta/cache_data.json | 13 ++++++----- .../cursor_by_username_and_machine_data.json | 11 +++++---- .../module/oracle/performance/_meta/data.json | 23 ++++++++++--------- .../module/oracle/performance/metricset.go | 3 ++- .../module/oracle/tablespace/_meta/data.json | 17 +++++++------- .../module/oracle/tablespace/metricset.go | 3 ++- 8 files changed, 40 insertions(+), 33 deletions(-) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index a0fbe4f50d2b..505e631cc599 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -761,6 +761,7 @@ field. You can revert this change by configuring tags for the module and omittin - Request prometheus endpoints to be gzipped by default {pull}20766[20766] - Add billing metricset into googlecloud module. {pull}20812[20812] {issue}20738[20738] - Release all kubernetes `state` metricsets as GA {pull}20901[20901] +- Sanitize `event.host`. {pull}21022[21022] *Packetbeat* diff --git a/metricbeat/mb/module/wrapper.go b/metricbeat/mb/module/wrapper.go index 2ea0d2b60d19..f0d1552c8158 100644 --- a/metricbeat/mb/module/wrapper.go +++ b/metricbeat/mb/module/wrapper.go @@ -392,7 +392,7 @@ func (r reporterV2) Event(event mb.Event) bool { } if event.Host == "" { - event.Host = r.msw.Host() + event.Host = r.msw.HostData().SanitizedURI } if event.Error == nil { diff --git a/x-pack/metricbeat/module/oracle/performance/_meta/cache_data.json b/x-pack/metricbeat/module/oracle/performance/_meta/cache_data.json index 9b109427e113..155852b7ccd9 100644 --- a/x-pack/metricbeat/module/oracle/performance/_meta/cache_data.json +++ b/x-pack/metricbeat/module/oracle/performance/_meta/cache_data.json @@ -6,7 +6,8 @@ "module": "oracle" }, "metricset": { - "name": "performance" + "name": "performance", + "period": 10000 }, "oracle": { "performance": { @@ -14,19 +15,19 @@ "cache": { "buffer": { "hit": { - "pct": 0.9636984728969045 + "pct": 0.970465382180896 } }, "get": { - "consistent": 477505, - "db_blocks": 66990 + "consistent": 604979, + "db_blocks": 88580 }, - "physical_reads": 19766 + "physical_reads": 20484 } } }, "service": { - "address": "oracle://sys:Oradoc_db1@localhost/ORCLPDB1.localdomain?connectionClass=\u0026poolIncrement=0\u0026poolMaxSessions=0\u0026poolMinSessions=0\u0026sysdba=1\u0026sysoper=0\u0026sysasm=0\u0026standaloneConnection=0\u0026enableEvents=0\u0026heterogeneousPool=0\u0026prelim=0", + "address": "localhost:32769", "type": "oracle" } } \ No newline at end of file diff --git a/x-pack/metricbeat/module/oracle/performance/_meta/cursor_by_username_and_machine_data.json b/x-pack/metricbeat/module/oracle/performance/_meta/cursor_by_username_and_machine_data.json index d849b506e1d9..d6cbefc6f35b 100644 --- a/x-pack/metricbeat/module/oracle/performance/_meta/cursor_by_username_and_machine_data.json +++ b/x-pack/metricbeat/module/oracle/performance/_meta/cursor_by_username_and_machine_data.json @@ -6,21 +6,22 @@ "module": "oracle" }, "metricset": { - "name": "performance" + "name": "performance", + "period": 10000 }, "oracle": { "performance": { "cursors": { - "avg": 0.6829268292682927, + "avg": 0.627906976744186, "max": 17, - "total": 28 + "total": 27 }, - "machine": "2ed9ac3a4c3d", + "machine": "f29609d6403a", "username": "Unknown" } }, "service": { - "address": "oracle://sys:Oradoc_db1@localhost/ORCLPDB1.localdomain?connectionClass=\u0026poolIncrement=0\u0026poolMaxSessions=0\u0026poolMinSessions=0\u0026sysdba=1\u0026sysoper=0\u0026sysasm=0\u0026standaloneConnection=0\u0026enableEvents=0\u0026heterogeneousPool=0\u0026prelim=0", + "address": "localhost:32769", "type": "oracle" } } \ No newline at end of file diff --git a/x-pack/metricbeat/module/oracle/performance/_meta/data.json b/x-pack/metricbeat/module/oracle/performance/_meta/data.json index 0c5347a1e29b..87f86acb15f4 100644 --- a/x-pack/metricbeat/module/oracle/performance/_meta/data.json +++ b/x-pack/metricbeat/module/oracle/performance/_meta/data.json @@ -6,33 +6,34 @@ "module": "oracle" }, "metricset": { - "name": "performance" + "name": "performance", + "period": 10000 }, "oracle": { "performance": { "cursors": { "cache_hit": { - "pct": 0.8311065930874237 + "pct": 0.8215208034433286 }, "opened": { - "current": 5, - "total": 6886 + "current": 32, + "total": 125460 }, "parse": { - "real": 1524, - "total": 4199 + "real": 39150, + "total": 63918 }, "session": { - "cache_hits": 5723 + "cache_hits": 103068 } }, - "io_reloads": 0.0015732643391367942, - "lock_requests": 0.5958019475347308, - "pin_requests": 0.8058170730696832 + "io_reloads": 0.009607787973500542, + "lock_requests": 0.5939075233457263, + "pin_requests": 0.7450330613301921 } }, "service": { - "address": "oracle://sys:Oradoc_db1@localhost/ORCLPDB1.localdomain?connectionClass=\u0026poolIncrement=0\u0026poolMaxSessions=0\u0026poolMinSessions=0\u0026sysdba=1\u0026sysoper=0\u0026sysasm=0\u0026standaloneConnection=0\u0026enableEvents=0\u0026heterogeneousPool=0\u0026prelim=0", + "address": "localhost:32769", "type": "oracle" } } \ No newline at end of file diff --git a/x-pack/metricbeat/module/oracle/performance/metricset.go b/x-pack/metricbeat/module/oracle/performance/metricset.go index 38d1cd4a9100..2c79b5813c3d 100644 --- a/x-pack/metricbeat/module/oracle/performance/metricset.go +++ b/x-pack/metricbeat/module/oracle/performance/metricset.go @@ -18,7 +18,8 @@ import ( // the MetricSet for each host defined in the module's configuration. After the // MetricSet has been created then Fetch will begin to be called periodically. func init() { - mb.Registry.MustAddMetricSet("oracle", "performance", New) + mb.Registry.MustAddMetricSet("oracle", "performance", New, + mb.WithHostParser(oracle.HostParser)) } // MetricSet holds any configuration or state information. It must implement diff --git a/x-pack/metricbeat/module/oracle/tablespace/_meta/data.json b/x-pack/metricbeat/module/oracle/tablespace/_meta/data.json index dac8c139cd80..81dce0bf3064 100644 --- a/x-pack/metricbeat/module/oracle/tablespace/_meta/data.json +++ b/x-pack/metricbeat/module/oracle/tablespace/_meta/data.json @@ -6,18 +6,19 @@ "module": "oracle" }, "metricset": { - "name": "tablespace" + "name": "tablespace", + "period": 10000 }, "oracle": { "tablespace": { "data_file": { - "id": 18, - "name": "/u02/app/oracle/oradata/ORCLCDB/orclpdb1/sysaux01.dbf", + "id": 3, + "name": "/u02/app/oracle/oradata/ORCL/sysaux01.dbf", "online_status": "ONLINE", "size": { - "bytes": 618659840, + "bytes": 744488960, "free": { - "bytes": 617611264 + "bytes": 743440384 }, "max": { "bytes": 34359721984 @@ -28,16 +29,16 @@ "name": "SYSAUX", "space": { "free": { - "bytes": 34799616 + "bytes": 39124992 }, "used": { - "bytes": 618659840 + "bytes": 744488960 } } } }, "service": { - "address": "oracle://sys:Oradoc_db1@localhost:1521/ORCLPDB1.localdomain?connectionClass=\u0026poolIncrement=0\u0026poolMaxSessions=0\u0026poolMinSessions=0\u0026sysdba=1\u0026sysoper=0\u0026sysasm=0\u0026standaloneConnection=0\u0026enableEvents=0\u0026heterogeneousPool=0\u0026prelim=0", + "address": "localhost:32769", "type": "oracle" } } \ No newline at end of file diff --git a/x-pack/metricbeat/module/oracle/tablespace/metricset.go b/x-pack/metricbeat/module/oracle/tablespace/metricset.go index 1729429d79a8..8fec8fd0a772 100644 --- a/x-pack/metricbeat/module/oracle/tablespace/metricset.go +++ b/x-pack/metricbeat/module/oracle/tablespace/metricset.go @@ -18,7 +18,8 @@ import ( // the MetricSet for each host defined in the module's configuration. After the // MetricSet has been created then Fetch will begin to be called periodically. func init() { - mb.Registry.MustAddMetricSet("oracle", "tablespace", New) + mb.Registry.MustAddMetricSet("oracle", "tablespace", New, + mb.WithHostParser(oracle.HostParser)) } // MetricSet holds any configuration or state information. It must implement