From f57196ed2143b1b653c4bf763151a785d73186ae Mon Sep 17 00:00:00 2001 From: Michael Katsoulis Date: Fri, 27 Sep 2024 12:28:47 +0300 Subject: [PATCH] Restore docker.network.in.* and docker.network.out.* fields in docker module (#40968) * Restore docker.network.in.* and docker.network.out.* fields in docker module * Update CHANGELOG.next.asciidoc * Change git email * Trigger tests * Add pre-commit step to beats pipelines (#40560) Added pre-commit check to beats pipelines to validate if no merge-conflicts exist * Remove extra punctuation in some fields description --------- Co-authored-by: Olga Naydyonock (cherry picked from commit fc17d84f0050a2d2bae0a61a7f2134f09cec683e) --- CHANGELOG.next.asciidoc | 1 + metricbeat/docs/fields.asciidoc | 98 +++++++++++++++++++ metricbeat/module/docker/fields.go | 2 +- .../module/docker/network/_meta/fields.yml | 44 +++++++++ metricbeat/module/docker/network/data.go | 12 +++ metricbeat/module/docker/network/helper.go | 11 +-- 6 files changed, 159 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.next.asciidoc b/CHANGELOG.next.asciidoc index 7588687a26b..8fd10ee5be0 100644 --- a/CHANGELOG.next.asciidoc +++ b/CHANGELOG.next.asciidoc @@ -338,6 +338,7 @@ https://github.com/elastic/beats/compare/v8.8.1\...main[Check the HEAD diff] - Add `metrics_count` to Prometheus module if `metrics_count: true` is set. {pull}40411[40411] - Added Cisco Meraki module {pull}40836[40836] - Added Palo Alto Networks module {pull}40686[40686] +- Restore docker.network.in.* and docker.network.out.* fields in docker module {pull}40968[40968] *Metricbeat* diff --git a/metricbeat/docs/fields.asciidoc b/metricbeat/docs/fields.asciidoc index a9a9a4608bd..eb2a1354647 100644 --- a/metricbeat/docs/fields.asciidoc +++ b/metricbeat/docs/fields.asciidoc @@ -14500,6 +14500,104 @@ type: keyword -- +[float] +=== in + +Incoming network stats per second. + + + +*`docker.network.in.bytes`*:: ++ +-- +Incoming bytes per seconds. + + +type: long + +format: bytes + +-- + +*`docker.network.in.dropped`*:: ++ +-- +Dropped incoming packets per second. + + +type: scaled_float + +-- + +*`docker.network.in.errors`*:: ++ +-- +Errors on incoming packets per second. + + +type: long + +-- + +*`docker.network.in.packets`*:: ++ +-- +Incoming packets per second. + + +type: long + +-- + +[float] +=== out + +Outgoing network stats per second. + + + +*`docker.network.out.bytes`*:: ++ +-- +Outgoing bytes per second. + + +type: long + +format: bytes + +-- + +*`docker.network.out.dropped`*:: ++ +-- +Dropped outgoing packets per second. + + +type: scaled_float + +-- + +*`docker.network.out.errors`*:: ++ +-- +Errors on outgoing packets per second. + + +type: long + +-- + +*`docker.network.out.packets`*:: ++ +-- +Outgoing packets per second. + + +type: long + +-- + [float] === inbound diff --git a/metricbeat/module/docker/fields.go b/metricbeat/module/docker/fields.go index 9c88da1e5b9..a313e328ed9 100644 --- a/metricbeat/module/docker/fields.go +++ b/metricbeat/module/docker/fields.go @@ -32,5 +32,5 @@ func init() { // AssetDocker returns asset data. // This is the base64 encoded zlib format compressed contents of module/docker. func AssetDocker() string { - return "eJzsnE9v47oRwO/5FIP0UOAhsdGipxwKvGa32KBv3wa7SXt4ePCjqbE9tURqScpe76cv+EeyLVGW/8hOgq4Pe4ismR+HM8MhOd5bmOPqDhLJ56iuAAyZFO/g+p37w/UVQIKaK8oNSXEHf78CAPAPQRtmNHCZpsgNJjBRMgvPBlcAClNkGu9gyq4ANBpDYqrv4LdrrdPr3+3fZlKZEZdiQtM7mLBU4xXAhDBN9J3TdAuCZbjBZz9mlVupShZ5+EuE0X4exESqjNk/AxOJAyZtiGtgY1mYIPbPGlQhBIkpcCkMI4FKD4KUTZpNouqb1ZMY2A64DUNWsiBDo4hXyu1n24zlp461jZZlTCRbz0q4Oa6WUtWf7UC0n3svEMyMGVgyDfgNeWGnnASYGTbGMYhzKWQG41wJM3gY1DtmEJYz9ARrE1q+oCmOYb2g0H1ap1TtJce1Uj5iSaJQa4zrpvxYtQ+PUIluGTJ9r1s37quHDZe+Y8xjocU/N4mUlGY0qVtiDZZKMY087GBznydpWOrh5ARYmjoHmVCKuvTXFkfdAlyeg+1LoFoTu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8RYY7pYta5oxXyA+Phq3TxWukRqsDg0yliWLQBGmZLf6ECSIr08klJUi9Zl9AguyOdL4EaWeqbbMmzV8UhPOj2DhN0ZDdtmHtKjpbOpJ9Drz75rSn/LwtfNRn6JDanu961KXRkOpe7vvVTTgzOLDOn5nBbsWMxoN68e5Tz0jtX//fC5KWe6wD7o4W6P63EjxtG2GLCv8eqFQKdSJ9z6iRME6UpONfExb9NhYY7hfecg6KuQXMp6ZCkW/dzH69vjO+diP4IwAA//+0neAX" } diff --git a/metricbeat/module/docker/network/_meta/fields.yml b/metricbeat/module/docker/network/_meta/fields.yml index 68af440a9bf..b931e6a89f6 100644 --- a/metricbeat/module/docker/network/_meta/fields.yml +++ b/metricbeat/module/docker/network/_meta/fields.yml @@ -9,6 +9,50 @@ type: keyword description: > Network interface name. + - name: in + type: group + description: > + Incoming network stats per second. + fields: + - name: bytes + type: long + format: bytes + description: > + Incoming bytes per seconds. + - name: dropped + type: scaled_float + description: > + Dropped incoming packets per second. + - name: errors + type: long + description: > + Errors on incoming packets per second. + - name: packets + type: long + description: > + Incoming packets per second. + - name: out + type: group + description: > + Outgoing network stats per second. + fields: + - name: bytes + type: long + format: bytes + description: > + Outgoing bytes per second. + - name: dropped + type: scaled_float + description: > + Dropped outgoing packets per second. + - name: errors + type: long + description: > + Errors on outgoing packets per second. + - name: packets + type: long + description: > + Outgoing packets per second. - name: inbound type: group description: > diff --git a/metricbeat/module/docker/network/data.go b/metricbeat/module/docker/network/data.go index 823b226d0f9..736a19553ab 100644 --- a/metricbeat/module/docker/network/data.go +++ b/metricbeat/module/docker/network/data.go @@ -37,6 +37,18 @@ func eventMapping(r mb.ReporterV2, stats *NetStats) { RootFields: rootFields, MetricSetFields: mapstr.M{ "interface": stats.NameInterface, + "in": mapstr.M{ + "bytes": stats.RxBytes, + "dropped": stats.RxDropped, + "errors": stats.RxErrors, + "packets": stats.RxPackets, + }, + "out": mapstr.M{ + "bytes": stats.TxBytes, + "dropped": stats.TxDropped, + "errors": stats.TxErrors, + "packets": stats.TxPackets, + }, "inbound": mapstr.M{ "bytes": stats.Total.RxBytes, "dropped": stats.Total.RxDropped, diff --git a/metricbeat/module/docker/network/helper.go b/metricbeat/module/docker/network/helper.go index 0f980fc2ab9..b5ab0a626b7 100644 --- a/metricbeat/module/docker/network/helper.go +++ b/metricbeat/module/docker/network/helper.go @@ -99,7 +99,9 @@ func (n *NetService) getNetworkStats(nameInterface string, rawNetStats types.Net netStats.TxErrors = n.getTxErrorsPerSecond(&newNetworkStats, &oldNetworkStat) netStats.TxPackets = n.getTxPacketsPerSecond(&newNetworkStats, &oldNetworkStat) } else { - n.NetworkStatPerContainer[myRawstats.Container.ID] = make(map[string]NetRaw) + if _, conExists := n.NetworkStatPerContainer[myRawstats.Container.ID]; !conExists { + n.NetworkStatPerContainer[myRawstats.Container.ID] = make(map[string]NetRaw) + } } n.NetworkStatPerContainer[myRawstats.Container.ID][nameInterface] = newNetworkStats @@ -121,13 +123,6 @@ func createNetRaw(time time.Time, stats *types.NetworkStats) NetRaw { } } -func (n *NetService) checkStats(containerID string, nameInterface string) bool { - if _, exist := n.NetworkStatPerContainer[containerID][nameInterface]; exist { - return true - } - return false -} - func (n *NetService) getRxBytesPerSecond(newStats *NetRaw, oldStats *NetRaw) float64 { duration := newStats.Time.Sub(oldStats.Time) return n.calculatePerSecond(duration, oldStats.RxBytes, newStats.RxBytes)